3

Is there any command to create, delete, etc tun / tap devices in OS X, like tunctl in Linux?

1.61803
  • 413
  • 8
  • 15

1 Answers1

4

You'll need to install TunTap, it's a TUN/TAP driver for OS X.

The TunTap package is comprised of a pair of kernel extensions, one providing tun and one providing tap interfaces. They create a set of character devices /dev/tunX and /dev/tapX, respectively, where X is a number between zero and the maximum number of supported virtual interfaces.

For example, to use tap0:

  • open() the character device /dev/tap0. Usually tun/tap network interfaces are created on demand when a program opens the associated character device. But for testing, you can do exec 5<>/dev/tap0 from a root shell to open the tap0 character device on shell file descriptor 5.
  • Configure the tap0 network interface, ifconfig tap0 10.1.2.3 up.
  • Now you can use read() and write() to send or receive packets.
  • close() the character device when you're done.
vesche
  • 1,842
  • 1
  • 13
  • 19
  • I already have the kernel extensions installed. As the subject says, I'm searching for a command that does what `tunctl` does on Linux. Or, for that matter, some sort of workaround. – 1.61803 Jan 25 '16 at 21:50
  • Well the 'workaround' is what I put in my example. It's not super involved, just a few commands. `tunctl -u user` would essentially be `sudo sh -c "exec 5<>/dev/tap0;chown user:user /dev/tap0"` – vesche Jan 26 '16 at 03:41