学校地址:湖南省 长沙市 雨花区 车站南路红花坡路口 |
学校地址:湖南省 长沙市 雨花区 车站南路红花坡路口 |
Part 1 of Dynamips External Cloud Interface on Linux
30 June 2008 25 Comments
Binding GNS3/dynamips Routers Ethernet port to the Hosts physical interface.
While browsing the http://7200emu.hacki.at forums, I noticed a few posts were asking for help on how to bridge a Routers ethernet port in Dynamips to the Linux hosts ethernet card. The only responses that seemed to show up stated that it was difficult as the tap interface needs to be created wen you start the lab. Well this article is here to address the issue and make things easier.
All the commands mentioned on this page should be executed with root privleges. To do this either use the su command to switch user, Or if you use ubuntu type sudo before each of the commands I have listed. Configuring your system in this manner allows you to run gns3/dynamips as a standard user and still have network access!
Firstly the terminology
Eth0,Wlan0 - If your machine has a wired ethernet card, It should show up as eth0 or eth1. If its an 802.11 card its possible to see something like wlan0.
Tap0,Tap1 - The Tap interface is a virtual interface created in linux, This interface is the one that the routers port is bound to.
Br0 - This is a Bridge for linux networking, This device is the one that ties eth0 and tap0 together so traffic can be passed.
Part 1 - Information Gathering
We are going to start with gathering some information about your network settings. If you use Dhcp you can skip straight to Part 2
bash:#ip a
1: lo: mtu 16436 qdisc noqueue
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth1: mtu 1500 qdisc noop qlen 1000
link/ether 00:1e:0b:33:6e:4c brd ff:ff:ff:ff:ff:ff
3: eth0: mtu 1500 qdisc pfifo_fast qlen 1000
link/ether 00:15:77:9b:ec:07 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.11/24 brd 192.168.1.255 scope global eth0
inet6 fe80::215:77ff:fe9b:ec07/64 scope link
valid_lft forever preferred_lft forever
Notice card number 3: eth0. Has the ip address 192.168.1.11 with a /24 mask. To find the default gateway enter this command
bash:#ip r
192.168.1.0/24 dev eth0 proto kernel scope link src 192.168.1.11
169.254.0.0/16 dev eth0 scope link
127.0.0.0/8 dev lo scope link
default via 192.168.1.1 dev eth0
My default gateway is shown by the line default via 192.168.1.1 dev eth0. So the gateway ip address is 192.168.1.1. Does everyone remember the 169.254.0.0/16 network? The APIPA range?. Well most modern linux distro’s include a route to that network just in case.
Part 2 - Setting up the Network
Welcome back to the Dhcp users. To kick this off we need to create a bridge interface on your machine. The command is brctl and is usually part of a package called “Bridge-utils”
To create the bridge we can do the following
brctl addbr br0
Execute ip a to verify that it was created and you should see a new entry like this
3: eth0: mtu 1500 qdisc pfifo_fast qlen 1000
link/ether 00:15:77:9b:ec:07 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.11/24 brd 192.168.1.255 scope global eth0
inet6 fe80::215:77ff:fe9b:ec07/64 scope link
valid_lft forever preferred_lft forever
4: br0: mtu 1500 qdisc noqueue
link/ether 00:15:77:9b:ec:07 brd ff:ff:ff:ff:ff:ff
Notice how on the bridge line there is no “UP,LOWER_UP” statement after multicast?, This indicates that the bridge interface is shutdown.
To activate the bridge we need to perform the following
ip l s dev br0 up
Now execute ip a again to verify interface br0 now shows as up.
Now to create the tap interface we need the following command “tunctl”. Normally in a package called “uml-utilities”
To create the tap interface execute the following where username! is your linux login
tunctl -t tap0 -u username!
Again to verify the creation of the interface execute ip a
3: eth0: mtu 1500 qdisc pfifo_fast qlen 1000
link/ether 00:15:77:9b:ec:07 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.11/24 brd 192.168.1.255 scope global eth0
inet6 fe80::215:77ff:fe9b:ec07/64 scope link
valid_lft forever preferred_lft forever
4: br0: mtu 1500 qdisc noqueue
link/ether 00:15:77:9b:ec:07 brd ff:ff:ff:ff:ff:ff
5: tap0: mtu 1500 qdisc pfifo_fast qlen 500
link/ether 00:ff:da:10:31:61 brd ff:ff:ff:ff:ff:ff
Again, the Tap0 interface is shutdown by default. to Activate it execute
ip l s dev tap0 up
So now we have all the interfaces we need created. Time to start adding interfaces to the bridge.
To associate both the Eth0 and tap0 interface with the bridge, enter the following to commands. This *links the interfaces together
|