Chinaunix首页 | 论坛 | 博客
  • 博客访问: 73123
  • 博文数量: 21
  • 博客积分: 99
  • 博客等级: 民兵
  • 技术积分: 135
  • 用 户 组: 普通用户
  • 注册时间: 2010-08-17 16:39
文章分类
文章存档

2013年(3)

2012年(17)

2010年(1)

分类: LINUX

2010-08-17 16:41:31

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 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
brctl addif br0 tap0
brctl addif br0 eth0
To verify that this worked, try
brctl show br0
You output should be similar to this
bridge name bridge id STP enabled interfacesbr0 8000.00123f43a4b3 no tap0 eth0
Now we need to change the eth0 card to promiscuous mode and remove the ip address from it
ifconfig eth0 0.0.0.0 promisc
So you can still access your network, We need to configure the br0 interface with your network settings, If you use a static ip address execute the following commands
ip a a 192.168.1.11/24 dev br0
ip r a default via 192.168.1.1
If you use dhcp, We can start the dhcp client on br0 with the following
dhclient br0
Thats it for the network!. Try to ping your default gateway or another device on your network. Easy hey!
Next part is dynamips! And its easy to.
Inside the .net file of your chosen topology.
autostart = True
[localhost:7210]
workingdir = /data/GNS3/ts_working
[[3640]]
image = /data/GNS3/cisco/ios/C3640-IK.BIN
chassis = 3640
[[ROUTER R0]]
model = 3640
console = 2000
cnfg = /data/GNS3/ts_configs/R0.cfg
slot0 = NM-1FE-TX
f0/0 = nio_tap:tap0
slot1 = NM-1FE-TX>
[[Cloud C0]]
connections = R0:f0/0:nio_tap:tap0
Note the device called Cloud C0, It’s connection line is the key to making this work. It states that router R0 has the interface Fastethernet0/0 which links to nio_tap:tap0. Where tap0 is the tap interface we created earlier
Router R0 has the matching line which completes the configuration.
If you’re a GNS3 user, Then its just as simple, Add the Cloud object to your network and create an ethernet link from the Cloud to your chosen router. Then right click the cloud and select configure.
Select the “NIO TAP” tab and enter your tap name.
本文来自ChinaUnix博客,如果查看原文请点:
http://blog.chinaunix.net/u1/34087/showart_2164132.html
阅读(695) | 评论(0) | 转发(0) |
0

上一篇:没有了

下一篇:linux文件系统—inode及相关概念

给主人留下些什么吧!~~