TUN/TAP区别
在计算机网络中,TUN与TAP是操作系统内核中的虚拟网络设备。不同于普通靠硬件网路板卡实现的设备,这些虚拟的网络设备全部用软件实现,并向运行于操作系统上的软件提供与硬件的网络设备完全相同的功能。
TAP 等同于一个以太网设备,它操作第二层数据包如以太网数据帧。TUN模拟了网络层设备,操作第三层数据包比如IP数据封包。
操作系统通过TUN/TAP设备向绑定该设备的用户空间的程序发送数据,反之,用户空间的程序也可以像操作硬件网络设备那样,通过TUN/TAP设备发送数据。在后种情况下,TUN/TAP设备向操作系统的网络栈投递(或“注入”)数据包,从而模拟从外部接受数据的过程。
服务器如果拥有TUN/TAP模块,就可以开启VPN代理功能。
虚拟网卡TUN/TAP 驱动程序设计原理:

虚拟网卡TUN/TAP 驱动程序设计原理
一个是让它工作在二层上。一个是工作在三层上。
http://vtun.sourceforge.net/tun/faq.html
Universal TUN/TAP device driver Frequently Asked Question.
1. General questions.
1. General questions.
1.1 What is the TUN ?
The TUN is Virtual Point-to-Point network device.
TUN driver was designed as low level kernel support for
IP tunneling. It provides to userland application
two interfaces:
- /dev/tunX - character device;
- tunX - virtual Point-to-Point interface.
Userland application can write IP frame to /dev/tunX
and kernel will receive this frame from tunX interface.
In the same time every frame that kernel writes to tunX
interface can be read by userland application from /dev/tunX
device.
1.2 What is the TAP ?
The TAP is a Virtual Ethernet network device.
TAP driver was designed as low level kernel support for
Ethernet tunneling. It provides to userland application
two interfaces:
- /dev/tapX - character device;
- tapX - virtual Ethernet interface.
Userland application can write Ethernet frame to /dev/tapX
and kernel will receive this frame from tapX interface.
In the same time every frame that kernel writes to tapX
interface can be read by userland application from /dev/tapX
device.
1.3 What platforms are supported by TUN/TAP driver ?
Currently driver has been written for 3 Unices:
Linux kernels 2.2.x, 2.4.x
FreeBSD 3.x, 4.x, 5.x
Solaris 2.6, 7.0, 8.0
1.4 What is TUN/TAP driver used for?
As mentioned above, main purpose of TUN/TAP driver is tunneling.
It used by VTun (http://vtun.info).
1.5 How does Virtual network device actually work ?
Virtual network device can be viewed as a simple Point-to-Point or
Ethernet device, which instead of receiving packets from a physical
media, receives them from user space program and instead of sending
packets via physical media sends them to the user space program.
Let's say that you configured IPX on the tap0, then whenever
kernel sends any IPX packet to tap0, it is passed to the application
(VTun for example). Application encrypts, compresses and sends it to
the other side over TCP or UDP. Application on other side decompress
and decrypts them and write packet to the TAP device, kernel handles
the packet like it came from real physical device.
1.6 What is the difference between TUN driver and TAP driver?
TUN works with IP frames. TAP works with Ethernet frames.
1.7 What is the difference between BPF and TUN/TAP driver?
BFP is a advanced packet filter. It can be attached to existing
network interface. It does not provide virtual network interface.
TUN/TAP driver does provide virtual network interface and it is possible
to attach BPF to this interface.
1.8 Does TAP driver support kernel Ethernet bridging?
Yes. Linux and FreeBSD drivers support Ethernet bridging.
TUN/TAP区别的更多相关文章
- 网络虚拟化技术(二): TUN/TAP MACVLAN MACVTAP (转)
网络虚拟化技术(二): TUN/TAP MACVLAN MACVTAP 27 March 2013 TUN 设备 TUN 设备是一种虚拟网络设备,通过此设备,程序可以方便得模拟网络行为.先来看看物理设 ...
- openstack-networking-neutron(二)---tun/tap
本博客已经添加"打赏"功能,"打赏"位置位于右边栏红色框中,感谢您赞助的咖啡. 简介 虚拟网卡Tun/tap驱动是一个开源项目,支持很多的类UNIX平台,Ope ...
- 虚拟网卡 TUN/TAP 驱动程序设计原理
简介 虚拟网卡Tun/tap驱动是一个开源项目,支持很多的类UNIX平台,OpenVPN和Vtun都是基于它实现隧道包封装.本文将介绍tun/tap驱动的使用并分析虚拟网卡tun/tap驱动程序在li ...
- 虚拟网卡TUN/TAP 驱动程序设计原理
昨天韦哥写了<Linux下Tun/Tap设备通信原理>一文,只提到了两个使用Tun的用户进程之间的通信路径,并没有说明Tun虚拟网卡驱动是如何实现的,而正好看到了这里的一篇讲解这方面的文章 ...
- TUN/TAP/VETH
TUN/TAP虚拟网络设备为用户空间程序提供了网络数据包的发送和接收能力.他既可以当做点对点设备(TUN),也可以当做以太网设备(TAP). TUN/TAP虚拟网络设备的原理: 在Linux内核中添加 ...
- 【转】TUN/TAP虚拟网络设备
转: 原文:https://www.cnblogs.com/wyzhou/p/9286864.html ------------------------------------------------ ...
- [转]Linux虚拟网络设备之tun/tap
转, 原文:https://segmentfault.com/a/1190000009249039 -------------------------------------------------- ...
- 虚拟网卡 TUN/TAP 驱动程序设计原理(经典)
盗用-收藏 简介 虚拟网卡Tun/tap驱动是一个开源项目,支持很多的类UNIX平台,OpenVPN和Vtun都是基于它实现隧道包封装.本文将介绍tun/tap驱动的使用并分析虚拟网卡tun/tap驱 ...
- 云原生虚拟网络 tun/tap & veth-pair
云原生虚拟网络 tun/tap & veth-pair 转载请声明出处哦~,本篇文章发布于luozhiyun的博客:https://www.luozhiyun.com/archives/684 ...
随机推荐
- Java从入门到放弃18---Map集合/HashMap/LinkedHashMap/TreeMap/集合嵌套/Collections工具类常用方法
Java从入门到放弃18—Map集合/HashMap/LinkedHashMap/TreeMap/集合嵌套/Collections工具类常用方法01 Map集合Map集合处理键值映射关系的数据为了方便 ...
- 世平信息(W 笔试)
选择题 大题 1.启动Thread的方法有几种 算法题 1.写出冒泡排序算法
- JavaEE-07 过滤器和监听器
学习要点 过滤器 监听器 过滤器Filter 过滤器的概念 过滤器位于客户端和web应用程序之间,用于检查和修改两者之间流过的请求和响应. 在请求到达Servlet/JSP之前,过滤器截获请求. 在响 ...
- python-opencv 分离图片(视频)中的某一颜色物体
看代码: import cv2 as cv import numpy as np def separate_color(frame): cv.imshow("原图", frame) ...
- [CF] 948A Protect Sheep
A. Protect Sheep time limit per test1 second memory limit per test256 megabytes inputstandard input ...
- Ubuntu16.04下安装pip
按照下面的步骤来安装 sudo apt-get install python-setuptools python-dev build-essential 安装python2的pip (要想好你用p ...
- js实现复制粘贴功能
在项目中使用到复制粘贴功能,虽然网上有很多大牛封装了很多的插件,但是还是想不去使用插件,就像自己来实现这个功能. 另一篇是禁止复制粘贴 前端er怎样操作剪切复制以及禁止复制+破解等 初步想法: 1. ...
- github 获取 token
登录github 地址:https://github.com 点击settings 在点击Developer settings 继续 继续 描述栏随意写 复选框是token的权限 都选上吧 点击红框 ...
- Farthest Nodes in a Tree (求树的直径)
题目链接,密码:hpu Description Given a tree (a connected graph with no cycles), you have to find the farthe ...
- Spring拓展接口之BeanPostProcessor,我们来看看它的底层实现
前言 开心一刻 小明:“妈,我被公司开除了”,妈:“啊,为什么呀?”, 小明:“我骂董事长是笨蛋,公司召开高层会议还要起诉我”,妈:“告你诽谤是吧?”,小明:“不是,他们说要告我泄露公司机密” Bea ...