Currently I read some docs about TUN/TAP devices, and I have some questions:

  • When should I use TUN/TAP devices?
  • Advantages over other devs?

migrated from networkengineering.stackexchange.com Jul 13 '18 at 18:34

This question came from our site for network engineers.


"TUN" and "TAP" devices are used when you want to implement a virtual network adapter from user mode. They are usually used by VPN software but they can also be used to implement other network functionality such as NAT46 and NAT64.

The difference between "TUN" and "TAP" interfaces is the layer thay work at. "TUN" interfaces send and receive IP packets with no further encapsulation and no attempt to translate layer 3 next hop addresses to layer 2 addresses. "TAP" interfaces send and receive Ethernet frames with source and destination MAC addresses.

The main alternative to "TUN" and "TAP" interfaces is implementing the VPN in the kernel. This is likely to perform better but increases security and reliability risks and makes development more difficult.


I highly recommend you to read the documentation in the kernel, it even gives nicely written examples:


Good luck and enjoy!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.