Networking

Connecting Dynamips to Your Local Network (OSX)

NIO_gen_eth is broken on OS X, so bridge your Dynamips router to a tuntaposx tap interface instead, then add IP forwarding and natd to reach it from elsewhere.

Tony Mattke · 2010.04.05 · 3 min read

Ever wanted direct network access to your Dynamips lab? Have you ever needed to lab something that used the SDM, but you run Dynamips under OSX? You may have noticed using NIO_gen_eth is broken under OS X, communication between the Dynamips IOS and the local Mac box itself is not working properly. There is a solution using a tun / tap interface in OS X.

Required Software

Since OS X does not include the tun/tap devices by default, we need to download a bit of software to create them. Luckily tuntaposx from SourceForge does just that for us. Go ahead and download it and install it. Once you do you should see the following. (Yes, this is on my Hackintosh)

bash
hackpro:~ amattke$ ls /dev/tap*
/dev/tap0   /dev/tap10  /dev/tap12  /dev/tap14  /dev/tap2   /dev/tap4   /dev/tap6   /dev/tap8
/dev/tap1   /dev/tap11  /dev/tap13  /dev/tap15  /dev/tap3   /dev/tap5   /dev/tap7   /dev/tap9

Configuration

First, we need to create the tap interface, then we can bridge the router interface to this tap device. To create the tap, open the terminal and execute the following command. You will be prompted for your password to gain root privileges.

bash
hackpro:~ amattke$ sudo ifconfig tap0 198.19.10.1 netmask 255.255.255.0

Now we can edit our Dynamips topology file and bridge the IOS interface to tap0.

text
[[Router R1]]
  model = 2611XM
  console = 2001
  autostart = False
  WIC0/0 = WIC-2T
  F0/0 = SW1 F1/1
  F0/1 = nio_tap:/dev/tap0
  S0/0 = FRSW 1

Finally, we can start the virutal router up and test the connection.

text
R1#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
R1(config)#int f0/1
R1(config-if)#ip address 198.19.10.11 255.255.255.0
R1(config-if)#no shut
R1(config-if)#end
R1#ping 198.19.10.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 198.19.10.1, timeout is 2 seconds:
.!!!!

Further thoughts

Since this tap interface is a local point-to-point connection between your local machine and the dynamips router, you will not be able to access it from your Virtual Machines, or your laptop. Obviously this could be a problem… So, in order to enable packet routing on your Mac you will need to issue the following command.

bash
sudo sysctl -w net.inet.ip.forwarding=1

Now, if your local virtual machine is using NAT it should find your dynamips router just fine. But, for anything non local, you will need to add a route somewhere. Either on the local machine, or on your core router, which is where I did it. I simply added a route to the internal IP of my mac for the 198.19.10.0/24 network. Simple enough, works great!

If you were looking for a method to allow your dynamips router to access the internet, we can enable nat on your mac for that network as well. The following will enable the firewall, setup natd, and finally add an ipfw rule…

bash
sudo sysctl -w net.inet.ip.fw.enable=1
sudo natd -alias_address ${YOUR_MACs_IP} -interface ${MACs_INTERFACE} -use_sockets -same_ports -unregistered_only -dynamic -clamp_mss
sudo ipfw add divert natd ip from any to any via ${MACs_INTERFACE}

If you have any questions, as always, feel free to leave a comment and I’ll try to help out the best I can. Thanks!

Related Posts

Networking · 11 min read

Cisco MPLS VRF Configuration and Demo

2009.11.19

A while back I asked everyone to vote on what topic they wanted to see next, and by no surprise almost every voted for MPLS VRFs.

Comments

3 archived comments from Disqus 2010–2015
RKB

You forgot a command - one has to chmod +s the dynamips bin to make this work:

bash-3.2$ sudo chmod +s /Applications/GNS3.app/Contents/Resources…

Otherwise, when you try to get tap0 up, you get this:

$ sudo ifconfig tap0 10.100.100.100 netmask 255.255.255.0 ifconfig: interface tap0 does not exist $

h3d0n15t
Thanks for the post, was struggling for hours to get this working, but everything is now working 100% :)
Jeff H.
Big bump here: I’m trying to do something similar to this using OpenVPN and bridging my ethernet connection so that the VPN client is on the same logical subnet. (I’m an enthusiast chiropractor BTW, not an IT pro). I’ve gotten as far as getting my iOS client to connect, and using your tutorial have created a tap0 interface (using the same subnet [10.0.0.25/254] as my local network) but I’m way out of my depth here. Any pointers would be amazing.