First, I read about what TunTap is at Wikipedia and VTUN Sourceforge. From what I read, TunTap was written for the VTUN project to specifically encapsulate Ethernet packets (TAP driver), whereas the TUN driver encapsulated IP packets. The driver is used by other popular software so it looks like it is here to stay. It is implemented as part of the Linux Kernel.
Go here Tun TAP driver for MAC OS X and download the installer package for Leopard.
Extract the package using Stuffit Expander (free app, google for it), and this will create a pkg file. This is a self installing script package so use Finder to run it, it will ask for your password so as to root privileges to install the Tun and Tap drivers into your dev directory.
After this I went into my /dev directory and did an ls and you can see the Tun and Tap driver are there.
and
Setup Dynagen to connect to the TAP driver
The next step is to then to create the TAP configuration in your dynagen net file. The following a sample:
# Simple lab
model = 3640
ghostios = true
sparsemem = true
[localhost]
[[3640]]
image = /Users/gregferro/Documents/dynalab/dyncode/c3640-js-124-17.image
ram = 128
idlepc = 0x604c0ebc
[[ETHSW sw1]]
1 = access 1 NIO_tap:/dev/tap0
2 = access 1
3 = access 1
4 = access 2
[[ROUTER r1]]
model = 3640
e0/0 = sw1 2
e0/1 = LAN 2
e0/2 = LAN 12
e0/3 = sw1 4
[[router r2]]
model = 3640
fa0/0 = sw1 3
fa1/0 = LAN 2
Once you have get this to successfully start you will now be able to see the interface
gf:smalllab gregferro$ ifconfig -l
lo0 gif0 stf0 en0 fw7 en1 vmnet8 vmnet1 en3 en2 tap0
gf:smalllab gregferro$
We need to give this interface an ip address:
gf:smalllab gregferro$ sudo ifconfig tap0 198.18.0.250/24 up
Password:
gf:smalllab gregferro$
now you will be able to configure R1 with an IP address and you can now reach your OS X system.
r1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
r1(config)#int e0/0
r1(config-if)#no shut
000033: *Mar 1 00:04:17.795 UTC: %LINK-3-UPDOWN: Interface Ethernet0/0, changed state to up
000034: *Mar 1 00:04:18.795 UTC: %LINEPROTO-5-UPDOWN: Line protocol on Interface Ethernet0/0, changed state to up
r1(config-if)#ip add 198.18.0.1 255.255.255.0
r1(config-if)#^Z
r1#
r1#
000035: *Mar 1 00:04:23.403 UTC: %SYS-5-CONFIG_I: Configured from console by console
r1#
r1#
r1#ping 198.18.0.250
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 198.18.0.250, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 1/4/8 ms
r1#
Hello Greg,
Just want to say “Thank you!” for this very useful howto!
Cheers, Dirk
You are my hero!!!
Thanks for this great info. Is there any way to access the internet with the router? In a nutshell, I want to make my MAC to act as an ISP using the tap driver.
Thanks again!
Best,
Lucas
Worked flawlessly on my iMac. Thank you.
Hey Greg,
I followed these directions but get this message when i start the lab:
es/dynagen ‘/Users/brandoncarroll/Documents/dynalab/labs/ipsec_ha.net’ ; exit
Reading configuration file…
*** Warning: Connecting SW2 port 4 to access 3 NIO_tap:/dev/tap0 resulted in:
206-unable to create TAP NIO
*** Error: errors during loading of the topology file, please correct them
Press ENTER to continue
When I do an ls in the /dev directory I see the tun and taps. Any idea what I may be doing wrong?
Thanks
Brandon
I have the same “206-unable to create TAP NIO” error message using GNS3 and the sourceforge version of TunTap drivers.
Greg Ferro, can you help?
Thank you
http://tuntaposx.sourceforge.net/ < best source for tun tap driver (your original link is dead)
Did these instructions work for that software – its a long time ago, but I remember having problems with the sourceforge version.
I am getting the same 206 error in dynamips and when I try to create a tap interface [sudo ifconfig tap0 create] i get “SIOCIFCREATE: Invalid argument”. I can see the kext are installed but it doesn’t look like leopard is playing nice. Has anyone got this to work with 10.5.6?
Output:
laptop:Downloads bdelano$ kextstat | egrep “tun|tap”
118 0 0x56b6e000 0x6000 0x5000 foo.tun (1.0)
119 0 0x56b74000 0x6000 0x5000 foo.tap (1.0)
laptop:Downloads bdelano$ sudo ifconfig tap0 create
Password:
ifconfig: SIOCIFCREATE: Invalid argument
Yep, you are right. The TUN/TAP drivers no longer work under Leopard. This article is probably useless and is no longer relevant.
That is not true. The kernel extensions installed by http://tuntaposx.sourceforge.net do work under Leopard. I’m using them with Dynagen now and the process for setting up is still the same.
I have never had success with Tun/Tap for OS X – neither in Tiger before nor Leopard now.
Hello All,
I’ve just downloaded tuntap_20080804.tar.gz from Sourceforge and I can confirm that it works perfectly with dynamips-0.2.7-RC3-OSX-intel-bin.zip on a MacBook running OSX 10.5.6.
I can ping a tap0 assigned IP address from a virtual router and visa versa.
One problem I did have was when the tap0 interface was in the same subnet that the notebook is in, i.e. 192.168.1.x/24.
When I assigned the tap0 interface the IP address of a different subnet, e.g. 192.168.2.x/24, it worked as expected. It goes without saying that the virtual router’s interface needs to be in the same subnet.
Many thanks for this very useful article.
Andreas
Hi Andreas,
I already download the driver also, but I failed to bring up the tap interface using #ifconfig tap0 plumb
I can see the tapX and tunX on /dev
Can you please show the step by step installation?
Thanks,
duga
Hi Andreas,
It’s already works great, thanks for all of you guys
Regards,
duga
Hi,
When I install the Tun Tap drivers, I can only see “tap0-15” and no “tun” when using the “ls -la /dev” command. I am running Mac OS X 10.5.8. I need help.
Can you have multiple Tap interfaces and trunk these Tap interfaces to a Cisco switch?
Also, was anybody succesfull in using Dynagen/Dynamips with Virtual Interfaces on Mac OS 10.5.8? I was able to create the virtual interfaces, assign the proper tagging, bind 2 routers (R2 to vlan2 and R3 to vlan3) in the Dynagen’s .net file but I wasn’t able to ping R3 from R2.
Any ideas?
Thanks Greg for some must useful articles.
I’ve just succeeded getting the tuntap drivers to work on my system, Snow Leopard 10.6.5.
I downloaded the tuntaposx installer from http://sourceforge.net/projects/tuntaposx/wp-content/uploads/
Connection to the tuntap via Dynamips version 0.2.8-RC2-x86 in a Dynagen.net file was as per your
example. My only error was giving tun0 and the router ip addresses in the same subnet as my
other active OSX interface en1, once I’d corrected that it all works. I can now access the router with SDM V2.5 – this runs on OSX after copying the directory over from a Windows installation!
Just to add that the tuntap version I used was tuntap_20090913.tar.
Greg et al,
I failed in getting the tuntap drivers working on Mac OSX 10.7 Lion and also in connecting DynaMIPS (embedded in GNS3) to my virtual machines (Parallels Desktop / VirtualBox) and connect my virtual LAN to my real LAN.
At the end, I got it all working.
Since I did spent quite some time on this website to figure out how to get it work in Lion. I documented what I did and it might be useful for others to post it here:
http://forum.gns3.net/topic4206.html?sid=6ebdb861bfceebd5c94e96a525167768
Good luck
Johan
For Users on OSX 10.10.2 brew install Caskroom/cask/tuntap