Monday, March 15, 2010

Installing Tun Tap Driver on Leopard

February 13, 2008 by Greg Ferro · 16 Comments 

First, I read about what TunTap is at Wikipedia and VTUN Sourceforge. From what I read, TunTap was writ­ten for the VTUN pro­ject to spe­cific­ally encap­su­late Ethernet pack­ets (TAP driver), whereas the TUN driver encap­su­lated IP pack­ets. The driver is used by other pop­u­lar soft­ware so it looks like it is here to stay. It is imple­men­ted as part of the Linux Kernel.

Go here Tun TAP driver for MAC OS X and down­load the installer pack­age for Leopard.

Extract the pack­age using Stuffit Expander (free app, google for it), and this will cre­ate a pkg file. This is a self installing script pack­age so use Finder to run it, it will ask for your pass­word so as to root priv­ileges to install the Tun and Tap drivers into your dev directory.

After this I went into my /​dev dir­ect­ory and did an ls and you can see the Tun and Tap driver are there.

tuntap2.png

and

tuntap1.png

Setup Dynagen to con­nect to the TAP driver

The next step is to then to cre­ate the TAP con­fig­ur­a­tion in your dyna­gen net file. The fol­low­ing a sample:


# Simple lab
model = 3640
ghostios = true
sparsemem = true

[loc­al­host]

[[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 suc­cess­fully 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 inter­face 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 con­fig­ure 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 per­cent (4÷5), round-​​trip min/​avg/​max = 1÷4÷8 ms
r1#

Please rate this post:

  Why Rate Posts?
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 ...

Comments

16 Responses to “Installing Tun Tap Driver on Leopard”
  1. Dirk says:

    Hello Greg,

    Just want to say “Thank you!” for this very use­ful howto!

    Cheers, Dirk

  2. Lucas says:

    You are my hero!!!

    Thanks for this great info. Is there any way to access the inter­net with the router? In a nut­shell, I want to make my MAC to act as an ISP using the tap driver.

    Thanks again!
    Best,
    Lucas

  3. Gian Paolo says:

    Worked flaw­lessly on my iMac. Thank you.

  4. Hey Greg,

    I fol­lowed these dir­ec­tions but get this mes­sage when i start the lab:

    es/​dynagen ‘/Users/brandoncarroll/Documents/dynalab/labs/ipsec_ha.net’ ; exit
    Reading con­fig­ur­a­tion file…

    *** Warning: Connecting SW2 port 4 to access 3 NIO_tap:/dev/tap0 res­ul­ted in:
    206-​​unable to cre­ate TAP NIO

    *** Error: errors dur­ing load­ing of the topo­logy file, please cor­rect them
    Press ENTER to continue

    When I do an ls in the /​dev dir­ect­ory 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 cre­ate TAP NIO” error mes­sage using GNS3 and the source­forge ver­sion of TunTap drivers.
      Greg Ferro, can you help?
      Thank you

  5. packeteer says:

    http://​tun​ta​posx​.source​forge​.net/ < best source for tun tap driver (your ori­ginal link is dead)

    • Greg Ferro says:

      Did these instruc­tions work for that soft­ware — its a long time ago, but I remem­ber hav­ing prob­lems with the source­forge version.

  6. bdelano says:

    I am get­ting the same 206 error in dynamips and when I try to cre­ate a tap inter­face [sudo ifcon­fig tap0 cre­ate] i get “SIOCIFCREATE: Invalid argu­ment”. I can see the kext are installed but it doesn’t look like leo­pard is play­ing nice. Has any­one 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 ifcon­fig tap0 cre­ate
    Password:
    ifcon­fig: SIOCIFCREATE: Invalid argument

  7. Scott V says:

    I have never had suc­cess with Tun/​Tap for OS X — neither in Tiger before nor Leopard now.

  8. Andreas says:

    Hello All,

    I’ve just down­loaded tuntap_20080804.tar.gz from Sourceforge and I can con­firm that it works per­fectly with dynamips-0.2.7-RC3-OSX-intel-bin.zip on a MacBook run­ning OSX 10.5.6.

    I can ping a tap0 assigned IP address from a vir­tual router and visa versa.

    One prob­lem I did have was when the tap0 inter­face was in the same sub­net that the note­book is in, i.e. 192.168.1.x/24.

    When I assigned the tap0 inter­face the IP address of a dif­fer­ent sub­net, e.g. 192.168.2.x/24, it worked as expec­ted. It goes without say­ing that the vir­tual router’s inter­face needs to be in the same subnet.

    Many thanks for this very use­ful article.

    Andreas

    • duga says:

      Hi Andreas,

      I already down­load the driver also, but I failed to bring up the tap inter­face using #ifcon­fig 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” com­mand. I am run­ning Mac OS X 10.5.8. I need help.

  10. GeorgeM says:

    Can you have mul­tiple Tap inter­faces and trunk these Tap inter­faces to a Cisco switch?

    Also, was any­body suc­ces­full in using Dynagen/​Dynamips with Virtual Interfaces on Mac OS 10.5.8? I was able to cre­ate the vir­tual inter­faces, assign the proper tag­ging, 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

Tell us what you're thinking...
and oh, if you want a pic to show with your comment, go get a gravatar!