·ChinaUnix首页 ·论坛 ·博客 
Linux首页 | Linux新闻 | Linux论坛 | Linux文档 | Linux下载 | Linux博客 | Linux搜索 | 开源项目孵化平台 | 《开源时代》
新手入门 | 安装启动 | 管理员指南 | 开发手册 | 桌面应用 | 程序开发 | 数据库 | 网络技术| CentOS | Fedora | MySQL | Apache | Ubuntu | Gentoo| OSCON08
  Linux时代 >> 技术文档 >> 安装启动
 
ubuntu dynamips 绑定网卡到虚拟机
来源: ChinaUnix博客  日期: 2010.01.29 14:40 (共有条评论) 我要评论
 

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
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
  发表评论 查看评论(共有条评论)
 
 


最新资讯更多>> 
· 谷歌劝说诺基亚采用Android操作..
· Apache 基金会确认退出 JCP 执..
· Chrome 10 新功能探秘:新增GP..
· 金山宣布开源其安全软件
· 女黑客在开源会议上抱受骚扰
· 21款值得关注的Linux游戏
· 马化腾:腾讯半年后彻底转型,..
· [多图] Chrome OS 预发布版本多..
· Lubuntu 11.04 默认应用抢先一览
· Red Hat宣布收购云计算软件提供..
论坛热点更多>> 
· do_execve时候用户栈中参数的..
· swapinfo -atm 问题
· Linux 的优点简述
· VM虚拟机上得Red Hat Linux上..
· 我看成了上海男人喜欢女人毛..
· 校车展览,看了你就知道
· 在遇到他之前,唯一需要做的..
· GRUB的疑问
· 从来没有人真正付足书价——..
· 云存储 vs 网盘
文档更新更多>> 
· orcale queue
· 谁可以推荐几本经典的操作系统的..
· 【北京】某物联网公司招云计算应..
· 【北京】某物联网公司招云计算应..
· 谁能推荐几本关于操作系统的书
· 如何添加网络接口eth1
· 葡萄牙语入门教材的选取与经验分享
· 葡萄牙语就业前景分析
· 葡萄牙语学习经验交流
· Щ
 
关于我们 | 联系方式 | 广告合作 | 诚聘英才 | 网站地图 | 友情链接 | 免费注册

Copyright © 2001-2009 ChinaUnix.net All Rights Reserved

感谢所有关心和支持过ChinaUnix的朋友们

京ICP证:060528号