# TUN/TAP

> Mediated Wiki article. Canonical URL: https://mediated.wiki/source/TUN/TAP
> Markdown URL: https://mediated.wiki/source/TUN/TAP.md
> Source: https://en.wikipedia.org/wiki/TUN%2FTAP
> Source revision: 1349950872
> License: Creative Commons Attribution-ShareAlike 4.0 International (https://creativecommons.org/licenses/by-sa/4.0/)

This article is about the network tunnel driver. For the software unit testing protocol known as TAP, see [Test Anything Protocol](/source/Test_Anything_Protocol).

In [computer networking](/source/Computer_network), **TUN** and **TAP** are [kernel](/source/Kernel_(operating_system)) [virtual network](/source/Network_virtualization) devices. Being network devices supported entirely in software, they differ from ordinary network devices which are backed by physical [network adapters](/source/Network_interface_controller).

The **Universal TUN/TAP Driver** originated in 2000 as a merger of the corresponding drivers in Solaris, Linux and BSD.[1] The driver continues to be maintained as part of the Linux[2] and FreeBSD[3][4][5] kernels.

## Design

Though both are for tunneling purposes, TUN and TAP cannot be used together because they transmit and receive packets at different layers of the network stack. TUN, namely [network TUNnel](/source/Tunneling_protocol), simulates a [network layer](/source/Network_layer) device and operates in [layer 3](/source/OSI_model#Layer_3:_Network_layer) carrying [IP](/source/Internet_Protocol) packets. TAP, namely [network TAP](/source/Network_tap), simulates a [link layer](/source/Link_layer) device and operates in [layer 2](/source/OSI_model#Layer_2:_Data_link_layer) carrying [Ethernet](/source/Ethernet) frames. TUN is used with [routing](/source/Routing). TAP can be used to create a [user space](/source/User_space) [network bridge](/source/Network_bridge).[2]

Packets sent by an [operating system](/source/Operating_system) via a TUN/TAP device are delivered to a user space program which attaches itself to the device. A user space program may also pass packets into a TUN/TAP device. In this case the TUN/TAP device delivers (or "injects") these packets to the operating-system [network stack](/source/Network_stack) thus emulating their reception from an external source.[2]

## Applications

**[Virtual private networks](/source/Virtual_private_network)**

- [OpenVPN](/source/OpenVPN), [Ethernet](/source/Ethernet)/IP over [TCP](/source/Transmission_Control_Protocol)/[UDP](/source/User_Datagram_Protocol); encrypted, compressed
- [ZeroTier](/source/ZeroTier), [Ethernet](/source/Ethernet)/IP over [TCP](/source/Transmission_Control_Protocol)/[UDP](/source/User_Datagram_Protocol); encrypted, compressed, cryptographic addressing scheme
- [FreeLAN](/source/FreeLAN), open-source, free, multi-platform IPv4, IPv6 and peer-to-peer VPN software over [UDP](/source/User_Datagram_Protocol)/[IP](/source/Internet_Protocol).
- [n2n](/source/N2n), an open source Layer 2 over Layer 3 VPN application which uses a peer-to-peer architecture for network membership and routing
- [Tinc](/source/Tinc_(protocol)), Ethernet/IPv4/[IPv6](/source/IPv6) over TCP/UDP; encrypted, compressed
- [VTun](/source/VTun), Ethernet/IP/serial/[Unix pipe](/source/Pipeline_(Unix)) over TCP; encrypted, compressed, traffic-shaping
- [OpenSSH](/source/OpenSSH)
- [coLinux](/source/Cooperative_Linux), [Ethernet](/source/Ethernet)/IP over [TCP](/source/Transmission_Control_Protocol)/[UDP](/source/User_Datagram_Protocol)
- [Hamachi](/source/LogMeIn_Hamachi)
- [OpenConnect](/source/OpenConnect)
- [WireGuard](/source/WireGuard)
- [Tailscale](/source/Tailscale)

**Virtual-machine networking**

- [Bochs](/source/Bochs)
- [coLinux](/source/Cooperative_Linux)
- [Hercules (S/390 emulator)](/source/Hercules_(emulator))
- [Open vSwitch](/source/Open_vSwitch)
- [QEMU](/source/QEMU)/[KVM](/source/Kernel-based_Virtual_Machine)
- [User-mode Linux](/source/User-mode_Linux)
- [VirtualBox](/source/VirtualBox)

**Connecting real machines with [network simulation](/source/Network_simulation)**

- [ns-3](/source/Ns_(simulator))[6]
- [GNU Radio](/source/GNU_Radio)[7]

**NAT**

- [TAYGA](http://www.litech.org/tayga/), a stateless [NAT64](/source/NAT64) implementation for Linux

## Platforms

Platforms with TUN/TAP drivers include:

- [FreeBSD](/source/FreeBSD)
- [Linux](/source/Linux), starting around version 2.1.60 of the [Linux kernel mainline](/source/Linux_kernel_mainline)
- [iOS](/source/IOS) (tun driver only)
- [macOS](/source/MacOS) (native support only for TUN (**utun**))[8]
- [NetBSD](/source/NetBSD)
- [OpenBSD](/source/OpenBSD)
- [Android](/source/Android_(operating_system))[9]
- [Solaris](/source/Solaris_(operating_system))
- [Windows](/source/Microsoft_Windows) 2000/XP/Vista/7/8/8.1/10
- [QNX](/source/QNX)

## See also

- [Point-to-point (telecommunications)](/source/Point-to-point_(telecommunications))
- [MacVTap](/source/MacVTap)

## References

1. ["Universal TUN/TAP driver"](https://vtun.sourceforge.net/tun/index.html). *[VTun](/source/VTun) project on [SourceForge](/source/SourceForge)*. Retrieved 2019-07-12.

1. ["Universal TUN/TAP device driver"](https://www.kernel.org/doc/html/latest/networking/tuntap.html). *[Linux kernel](/source/Linux_kernel)*. Retrieved 2025-07-04.

1. ["TUN(4) manual page"](https://www.freebsd.org/cgi/man.cgi?query=tun). *[FreeBSD](/source/FreeBSD)*. Retrieved 2019-07-12.

1. ["TAP(4) manual page"](https://www.freebsd.org/cgi/man.cgi?query=tap&sektion=4). *[FreeBSD](/source/FreeBSD)*. Retrieved 2019-07-12.

1. ["VPNs to bypass Internet Censorship in Saudi Arabia"](https://vpnquery.com/best-vpn-for-saudi-arabia-check-top-5/). Retrieved 12 June 2019.

1. ["ns3::TapBridge Class Reference"](https://web.archive.org/web/20190328205043/https://www.nsnam.org/docs/doxygen/classns3_1_1_tap_bridge.html). nsnam.org. Archived from [the original](https://www.nsnam.org/docs/doxygen/classns3_1_1_tap_bridge.html) on 2019-03-28. Retrieved 2019-03-28.

1. ["TUNTAP PDU"](https://wiki.gnuradio.org/index.php/TUNTAP_PDU). Retrieved 2023-02-08.

1. [Back to My Mac](/source/Back_to_My_Mac) uses an [IPv6](/source/IPv6) tunnel on device utun0.

1. ["de.schaeuffelhut.android.openvpn"](https://web.archive.org/web/20190328233339/https://f-droid.org/wiki/page/de.schaeuffelhut.android.openvpn). [F-Droid](/source/F-Droid). 2013-01-10. Archived from [the original](https://f-droid.org/wiki/page/de.schaeuffelhut.android.openvpn) on 2019-03-28. Retrieved 2019-03-28.

## External links

- [Tun/Tap interface tutorial](https://backreference.org/2010/03/26/tuntap-interface-tutorial/)
- [Linux Networking: MAC VLANs and Virtual Ethernets](http://www.pocketnix.org/posts/Linux%20Networking:%20MAC%20VLANs%20and%20Virtual%20Ethernets) [Archived](https://web.archive.org/web/20150218040640/http://www.pocketnix.org/posts/Linux%20Networking%3A%20MAC%20VLANs%20and%20Virtual%20Ethernets) 2015-02-18 at the Wayback Machine

---
Adapted from the Wikipedia article [TUN/TAP](https://en.wikipedia.org/wiki/TUN%2FTAP) by Wikipedia contributors ([contributor history](https://en.wikipedia.org/wiki/TUN%2FTAP?action=history)). Available under [Creative Commons Attribution-ShareAlike 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/). Changes may have been made.
