2 September 2010

Installing Tun Tap Driver on Leopard

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.

tuntap2.png

and

tuntap1.png

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#

Please rate this post:

1 Star - It\\\'s Crud2 Stars - It\\\'s Tosh3 Stars - Something\\\'s missing4 Stars - Needs works5 Stars - Good Enough6 Stars - Good7 Stars - Excellent8 Stars - Brilliant9 Stars - Astonishing10 Stars - Awesomely Godlike? (1 votes, average: 10.00 out of 10)
Loading ... Loading ...

About Greg Ferro
Greg is a Network and Security Architect / Designer / Engineer working freelance in the UK and worked for Resellers, DotCom's, Large Corporate's and Service Providers across a variety of products & Vendors. He prefers to work for end users, believes in the life cycle, total cost of ownership and that near enough is often good enough. He likes talking about himself in the first person to feel "royal", even when hosting the Packet Pushers Podcast on Data Networking. More about Greg at http://etherealmind.com/who-am-i/ and you can follow him on Twitter.

Comments

  1. Dirk says:

    Hello Greg,

    Just want to say “Thank you!” for this very useful howto!

    Cheers, Dirk

  2. Lucas says:

    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

  3. Gian Paolo says:

    Worked flawlessly on my iMac. Thank you.

  4. 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

    • CaitSith says:

      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

  5. packeteer says:

    http://tuntaposx.sourceforge.net/ < best source for tun tap driver (your original link is dead)

  6. bdelano says:

    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 0×6000 0×5000 foo.tun (1.0)
    119 0 0x56b74000 0×6000 0×5000 foo.tap (1.0)
    laptop:Downloads bdelano$ sudo ifconfig tap0 create
    Password:
    ifconfig: SIOCIFCREATE: Invalid argument

  7. Scott V says:

    I have never had success with Tun/Tap for OS X – neither in Tiger before nor Leopard now.

  8. Andreas says:

    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

    • duga says:

      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

    • duga says:

      Hi Andreas,

      It’s already works great, thanks for all of you guys

      Regards,

      duga

  9. Jesse says:

    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.

  10. GeorgeM says:

    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?

Speak Your Mind

*