There is a nice video tutorial to get your GNS3 lab connected to your physical network.
However, it requires you to use a real network card with a fixed IP for doing that. This is not really handy if, llike me, you use GNS3 on a laptop whose connectivity is frequently switching between cable and wireless, and on different subnets.
I started to look for something more convenient like a virtual interface.
I first thought about declaring a virtual IP on eth0, but no way : briding is layer 2 (based on MAC address), you can’t add eth0:0 to a bridge.
Then I found the very handy dummy interface.
Load the module :
% sudo modprobe dummy
% lsmod | grep dummy
dummy 3192 0
% ifconfig dummy0
dummy0 Link encap:Ethernet HWaddr AE:89:91:BD:61:87
BROADCAST NOARP MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 lg file transmission:0
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
To have the module loaded at boot time, do :
In debian :
% echo dummy >> /etc/modules
In openSUSE, edit this line in /etc/sysconfig/kernel :
Then, you could go on with the tutorial linked above, replacing eth0 with dummy0, or use the script I made :
/bin/tunctl -t tap0
/sbin/ifconfig tap0 0.0.0.0 promisc up
/sbin/ifconfig dummy0 0.0.0.0 promisc up
/sbin/brctl addbr br0
/sbin/brctl addif br0 tap0
/sbin/brctl addif br0 dummy0
/sbin/ifconfig br0 10.10.10.99/24 up
You may also insert this line if you want to interconnect your lab network with your other networks (it activates kernel’s IP forwarding) :
echo 1 > /proc/sys/net/ipv4/ip_forward
I saved it /usr/local/bin/gns and created a pretty shortcut for the application browser of Gnome :
% cat /usr/share/applications/gns3.desktop
GenericName=Cisco routers emulator
This shortcut will prompt you for the root password (unfortunately, when dealing with tap interface, GNS3 requires root access – security could be tighten with SELinux or AppArmor) and launch GNS3 with most of the network stuff prepared.
Just in case you want to clear that all quickly, there is the gns-stop script :
ifconfig br0 down
brctl delif br0 tap0
brctl delif br0 eth0
brctl delbr br0
tunctl -d tap0