Cisco – Dynamips with Linux loopback (tap) interface
Posted by Josh on Fri 31 Aug 2007Categories: Cisco , Cisco Routers , Dynamips - [21] Comments
This tutorial will show you how to add a tap interface to your linux machine and how to communicate with your dynamips router session via the tap interface. In a previous tutorial, I used a loopback interface on a Windows XP machine to accomplish the same goal.
For me, the reason for using loopback (or tap) interface with dynamips is that it allows me to create complete lab scenarios right on my pc with only one network interface. For instance, the tutorial following this one will demonstrate configuring nat on the dynamips routers. The traffic will flow from the tap interface, to the dynamips router, it will undergo translation and exit the eth0 interface.
Update: Use this tutorial for tap interfaces + bridging and GNS3 (Much better tutorial)

Here is the short list of commands used in the tutorial
- In the Dynagen .net config file
[[ router R1]]
F0/0 = NIO_tap:tap0 - [root]#apt-get install uml-utilities
- [root]#modprobe tun
- [root]#tunctl
- [root]#ifconfig tap0 10.100.100.100 netmask 255.255.255.0 up
- [root]#dynagen loopback.net
- Inside the router
#config t
(config)#int f0/0
(config-if)#no shut
(config-if)#ip address 10.100.100.1 255.255.255.0
(config-if)#end
#ping 10.100.100.100
.!!!! Success
September 14th, 2007 at 9:10 am
Thank u very much!!!
September 22nd, 2007 at 5:21 am
This would have to be the most useful information I have found on the net.
Thank you, thank you thank you
September 26th, 2007 at 6:17 am
Great tutorial.
October 10th, 2007 at 3:40 pm
[...] Dynamips with Linux loopback (tap) interface [...]
October 25th, 2007 at 1:33 pm
Can we use the same technique in Vista ? because it is not possible see the loopback in the ‘network device list’ for dynagen ?
please advice.
December 5th, 2007 at 8:36 pm
Thanks! I needed that help.
March 26th, 2008 at 9:26 pm
[...] Dynamips with Linux loopback (tap) interface [...]
April 6th, 2008 at 7:36 am
thanks. a lot.
followed the steps and successfully create tap0, tap1, tap2.
however, after reboot ubuntu. all tap interfaces are all gone.
how to save them?
April 7th, 2008 at 6:27 am
Read here :
http://ubuntu.wordpress.com/2005/09/07/adding-a-startup-script-to-be-run-at-bootup/
October 12th, 2008 at 8:44 am
Thanks for the Heads up!!, at the beginning it didn’t work for me on ubuntu 8.04 and gns3, i added a bridge after adding the tap0 interface (i bridged the ethernet interface with tap0 with the bridge-utils module) and checked the routing table, after this step it finally worked.
Thanks again.
October 13th, 2008 at 10:59 am
Tony,
Glad it is working for you! Thanks for sharing your experience.
Josh
December 12th, 2008 at 9:45 am
Good information!
Thanks very much!
I want to konw it just now.
Very make sense!
February 12th, 2009 at 12:22 am
hi..
im searching if there any way to create several loopbacks and brdige them with the PC’s NIC with multiple ip addresses..and create subinterfaces in one of GNS router with several networks. can anyone help me to do this
February 20th, 2009 at 1:06 am
Hi am still taking my baby steps in linux, was trying to connect my gns lab to my real pc and the error i get when i start dynagen is :
root@jerry-laptop:/home/jerry/Desktop/taps# dynagen loopback.net
Reading configuration file…
Shutdown in progress…
Shutdown completed.
Warning: ignoring unknown config item: x = -76.0
Warning: ignoring unknown config item: y = -43.0
Warning: ignoring unknown config item: x = -69.0
Warning: ignoring unknown config item: y = -171.0
*** Error: Could not connect to server: GNS3-DATA
Shutdown in progress…
Shutdown completed.
Press ENTER to continue
please somebody help, appreciate what y’all is doing ..
February 24th, 2009 at 9:39 pm
Jerry,
It looks like you are trying to run a .net config file with dynagen that was created with gns3.
Josh
June 26th, 2009 at 4:25 am
Does anyone know if this very useful tutorial is available for GNS?
I am still learning more and more about GNS.
Or, would it be better if I only used Dynamips and Dynagen.
Any advise would be nice, even the simplest.
Thanks
Paul
July 3rd, 2009 at 12:05 pm
Respekt from Russia. It’s really work. Thanks
July 20th, 2009 at 12:35 pm
Great work.
I was wondering if it is possible to ping another interface of router R1 (that is connected to another router R2) from the linux machine. Moreover, is it possible to ping an interface in router R2?
July 20th, 2009 at 1:07 pm
Fenando,
Try this tutorial.
Josh
January 13th, 2010 at 6:33 am
I use dynamips running on ubuntu, bridged vmware instance with IP 10.17.8.70. I configured tap1 and added route:
ifconfig tap1 10.18.7.6 netmask 255.255.0.0
route add -net 10.17.12.0 netmask 255.255.255.0 dev tap1
I configured routers R1 and R2:
[[ROUTER R1]]
model=3745
slot 1 = NM-1FE-TX
#slot 4 = NM-16ESW
F1/0 = NIO_tap:tap1
F3/0 = R2 F1/0
[[router R2]]
slot 3 = NM-1FE-TX
slot 4 = NM-1FE-TX
F4/0 = R5 F4/0
F1/0 = R1 F3/0
F3/0 = R3 F1/0
model=3745
R1 F3/0 has IP 10.17.12.101
R1 F1/0 has IP 10.18.7.7 (connected to tap1)
R2 F1/0 has IP 10.17.12.102
from that ubuntu system I can ping, reach all of those interfaces (10.18.7.7, 10.17.12.101, 10.17.12.102)
# ip r
10.17.12.0/24 dev tap1 scope link
10.18.0.0/16 dev tap1 proto kernel scope link src 10.18.7.6
10.17.0.0/16 dev eth1 proto kernel scope link src 10.17.8.70
169.254.0.0/16 dev eth1 scope link metric 1000
default via 10.17.250.250 dev eth1 metric 100
The problem is to reach those interfaces from seem other system, for example from my windows deskop. I added those routes, ubuntu is gw, package forwading on ubuntu is enabled:
Active Routes:
Network Destination Netmask Gateway Interface Metric
0.0.0.0 0.0.0.0 10.17.250.250 10.17.1.153 20
10.17.0.0 255.255.0.0 10.17.1.153 10.17.1.153 20
10.17.1.153 255.255.255.255 127.0.0.1 127.0.0.1 20
10.17.12.0 255.255.255.0 10.17.8.70 10.17.1.153 1
10.18.0.0 255.255.0.0 10.17.8.70 10.17.1.153 1
10.255.255.255 255.255.255.255 10.17.1.153 10.17.1.153 20
127.0.0.0 255.0.0.0 127.0.0.1 127.0.0.1 1
192.168.80.0 255.255.255.0 192.168.80.1 192.168.80.1 20
192.168.80.1 255.255.255.255 127.0.0.1 127.0.0.1 20
192.168.80.255 255.255.255.255 192.168.80.1 192.168.80.1 20
192.168.159.0 255.255.255.0 192.168.159.1 192.168.159.1 20
192.168.159.1 255.255.255.255 127.0.0.1 127.0.0.1 20
192.168.159.255 255.255.255.255 192.168.159.1 192.168.159.1 20
209.85.0.0 255.255.0.0 10.17.8.70 10.17.1.153 1
209.85.135.0 255.255.255.0 10.17.8.70 10.17.1.153 1
224.0.0.0 240.0.0.0 10.17.1.153 10.17.1.153 20
224.0.0.0 240.0.0.0 192.168.80.1 192.168.80.1 20
224.0.0.0 240.0.0.0 192.168.159.1 192.168.159.1 20
255.255.255.255 255.255.255.255 10.17.1.153 10.17.1.153 1
255.255.255.255 255.255.255.255 192.168.80.1 192.168.80.1 1
255.255.255.255 255.255.255.255 192.168.159.1 192.168.159.1 1
Default Gateway: 10.17.250.250
I can reach eth1 and tap1 interface from that windows box, but it seems that packages to routers are droped (10.18.7.7, 10.17.12.101, 10.17.12.102). What I have to do ?
January 15th, 2010 at 7:30 am
Jee, I finally solved problem, I can access my router also from outside systems (ping, snmp..) but I have a strange problem with telnet. I can telnet from router to outside system, but I can telnet on router (except from system where is running dynamips)