Tip of the week 40
Connect your Linux local host to your GNS3's devices
Some days ago I tried to connect my GNS3 devices to the outside with the cloud icon (note that you have to launch GN3 with root rights), it works well but I noticed that I couldn't reach my local host... After some investigation, I found an article on the GNS3 FAQ here :
On Linux / Unix / OS X, when I bridge a router or switch interface to my local host I can’t ping it from my host. But this works on Windows? What gives?
This does generally work on Windows (depending on your network card) but not on Linux / Unix. Most likely this is due to differences between libpcap and Winpcap, and the differences in the network stacks on Unix / Windows (e.g. NDIS). However you should be able to ping your bridged interfaces from other systems on the bridged network. If this does not work on Windows for your particular NIC, try creating a Windows loopback adapter and bridging to that. On Linux you can use a tap interface and the NIO_tap (available from a cloud). OS X you can install tun/tap drivers.
Ok, so I need to create a tap interface, here is how with the ip command (as ifconfig is deprecated):
~ sudo ip tuntap add tap1 mode tap user root ~ sudo ip link set tap1 up ~ sudo ip addr add 192.0.2.100/24 dev tap1
Check it with :
~ ip addr show tap1 6: tap1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN qlen 500 link/ether ce:d5:8b:bc:5e:74 brd ff:ff:ff:ff:ff:ff inet 192.168.2.100/24 scope global tap1 valid_lft forever preferred_lft forever inet 192.0.2.100/24 scope global tap1 valid_lft forever preferred_lft forever inet6 fe80::ccd5:8bff:febc:5e74/64 scope link valid_lft forever preferred_lft forever
Note that the tap1 is in DOWN state because there no carrier.
Create a host under GNS3, right click on it and configure, go under NIO TAP tab and add the tap1 you just created.
Then, create the link to your device and apply your interface configuration in order to test the reachability.
R1(config)#int ethernet 0/0 R1(config-if)#ip addr R1(config-if)#ip address 192.0.2.200 255.255.255.0 R1(config-if)#no shut R1(config-if)#^Z R1#conf t *Mar 1 00:00:36.731: %SYS-5-CONFIG_I: Configured from console by console R1#conf *Mar 1 00:00:37.699: %LINK-3-UPDOWN: Interface Ethernet0/0, changed state to up *Mar 1 00:00:38.699: %LINEPROTO-5-UPDOWN: Line protocol on Interface Ethernet0/0, changed state to up R1# R1# R1#ping 192.0.2.100 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 192.0.2.100, timeout is 2 seconds: .!!!!
Now you can reach the router from your Linux. That's interesting if you want for example to test some supervision tool.
If you want to make your tap interface persistent, you have to edit your /etc/network/interfaces file with the following :
iface tap1 inet manual pre-up ip tuntap add tap1 mode tap user root pre-up ip addr add 192.0.2.100/24 dev tap1 up ip link set dev tap1 up post-down ip link del dev tap1