Main Tun.c 548 Can't Open Dev Net Tun
- Dec 09, 2013 With 3.10.9 (and before), I would have to ensure that the tun module was loaded ('modprobe tun') for /dev/net/tun to appear (and vpnc to work). Since 3.11.0, /dev/net/tun just appears. No tun.ko, no tun.c/tun.h in the linux source. I moved the device and rebooted, and sure enough it automagically reappeared.
- Aug 12, 2016 我查了 log 里有这么一条错误:main: tun.c:342: Can't open /dev/net/tun: No such file or directory,不知您知不知道我的问题出在哪里。 非常感谢! 点评.
Aug 19, 2010 $ sudo vpnc jacobs vpnc: can't open /dev/net/tun, check that it is either device char 10 200 or (with DevFS) a symlink to./misc/net/tun (not misc/net/tun): No such device vpnc: can't initialise tunnel interface: No such device. . Support routines for configuring and accessing TUN/TAP. virtual network adapters. This file is based on the TUN/TAP driver interface routines. from VTun by Maxim Krasnyansky./ #ifdef WIN32.
##Description
TUN/TAP provides packet reception and transmission for user space programs.It can be seen as a simple Point-to-Point or Ethernet device, which,instead of receiving packets from physical media, receives them fromuser space program and instead of sending packets via physical mediawrites them to the user space program.
###What is the TUN ?
Main Tun.c 548 Can't Open Dev Net Tun In Spanish
The TUN is Virtual Point-to-Point network device.TUN driver was designed as low level kernel support forIP 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 willreceive this frame from tunX interface. In the same time every framethat kernel writes to tunX interface can be read by userland applicationfrom /dev/tunX device.
###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/tapXand kernel will receive this frame from tapX interface.In the same time every frame that kernel writes to tapXinterface can be read by userland application from /dev/tapXdevice.
In order to use the driver a program has to open /dev/net/tun and issue acorresponding ioctl() to register a network device with the kernel. A networkdevice will appear as tunXX or tapXX, depending on the options chosen. Whenthe program closes the file descriptor, the network device and allcorresponding routes will disappear.
Depending on the type of device chosen the userspace program has to read/writeIP packets (with tun) or ethernet frames (with tap). Which one is being useddepends on the flags given with the ioctl().
The package from http://vtun.sourceforge.net/tun contains two simple examplesfor how to use tun and tap devices. Both programs work like a bridge betweentwo network interfaces.
- br_select.c - bridge based on select system call.
- br_sigio.c - bridge based on async io and SIGIO signal.
However, the best example is VTun http://vtun.sourceforge.net :))
##Configuration
####Create device node:
Main Tun.c 548 Can't Open Dev Net Tun In English
####Set permissions: e.g. chmod 0666 /dev/net/tun
There is no harm in allowing the device to be accessible by non-root users,since CAP_NET_ADMIN is required for creating network devices or forconnecting to network devices which are not owned by the user inquestion. If you want to create persistent devices and give ownership ofthem to unprivileged users, then you need the /dev/net/tun deviceto be usable by those users.
###Driver module autoloading
Make sure that 'Kernel module loader' - module auto-loading support is enabledin your kernel. The kernel should load it on first access.
###Manual loading
insert the module by hand: modprobe tun
If you do it the latter way, you have to load the module every time youneed it, if you do it the other way it will be automatically loaded when/dev/net/tun is being opened.
Main Tun.c 548 Can't Open Dev Net Tunisie
##Program interface
###Network device allocation:
char *dev should be the name of the device with a format string (e.g.'tun%d'), but (as far as I can see) this can be any valid networkdevice name.
Note that the character pointer becomes overwritten with the real device name(e.g. 'tun0')
###Frame format: Greeting card factory mac download.
If flag IFF_NO_PI is not set each frame format is:
Flags [2 bytes]Proto [2 bytes]Raw protocol(IP, IPv6, etc) frame.
###Multiqueue tuntap interface:
From version 3.8, Linux supports multiqueue tuntap which can uses multiplefile descriptors (queues) to parallelize packets sending or receiving. Thedevice allocation is the same as before, and if user wants to createmultiple queues, TUNSETIFF with the same device name must be called manytimes with IFF_MULTI_QUEUE flag.
char *dev should be the name of the device, queues is the number of queues tobe created, fds is used to store and return the file descriptors (queues)created to the caller. Each file descriptor were served as the interfaceof a queue which could be accessed by userspace.
A new ioctl(TUNSETQUEUE) were introduced to enable or disable a queue. Whencalling it with IFF_DETACH_QUEUE flag, the queue were disabled. And whencalling it with IFF_ATTACH_QUEUE flag, the queue were enabled. The queuewere enabled by default after it was created through TUNSETIFF.
fd is the file descriptor (queue) that we want to enable or disable, whenenable is true we enable it, otherwise we disable it
##QA:
Universal TUN/TAP device driver Frequently Asked Question.
Q: What platforms are supported by TUN/TAP driver ?
Main Tun.c 548 Can't Open Dev Net Tuning
Q: What is TUN/TAP driver used for?
As mentioned above, main purpose of TUN/TAP driver is tunneling.It is used by VTun (http://vtun.sourceforge.net).
Another interesting application using TUN/TAP is pipsecd(http://perso.enst.fr/~beyssac/pipsec/), a userspace IPSecimplementation that can use complete kernel routing (unlike FreeS/WAN).
Q: How does Virtual network device actually work ?
Virtual network device can be viewed as a simple Point-to-Point orEthernet device, which instead of receiving packets from a physicalmedia, receives them from user space program and instead of sendingpackets via physical media sends them to the user space program.
Let us say that you configured IPX on the tap0, then wheneverthe kernel sends an IPX packet to tap0, it is passed to the application(VTun for example). The application encrypts, compresses and sends it tothe other side over TCP or UDP. The application on the other side decompressesand decrypts the data received and writes the packet to the TAP device,the kernel handles the packet like it came from real physical device.
Q: What is the difference between TUN driver and TAP driver?
/auto-tune-vst-plugin-free-download.html. TUN works with IP frames. TAP works with Ethernet frames.
This means that you have to read/write IP packets when you are using tun andethernet frames when using tap.
Q: what is the difference between BPF and TUN/TAP driver?
BPF is an advanced packet filter. It can be attached to existingnetwork interface. It does not provide a virtual network interface.A TUN/TAP driver does provide a virtual network interface and it is possibleto attach BPF to this interface
Q: Does TAP driver support kernel Ethernet bridging?
Yes. Linux and FreeBSD drivers support Ethernet bridging.
##Example
Tun/tap 驱动程序中包含两个部分, 一部分是字符设备驱动, 还有一部分是网卡驱动部分. 利用网卡驱动部分接收来自TCP/IP 协议栈的网络分包并发送或者反过来将接收到的网络分包传给协议栈处理, 而字符驱动部分则将网络分包在内核与用户态之间传送, 模拟物理链路的数据接收和发送. Tun/tap 驱动很好的实现了两种驱动的结合.
##参考
Main Tun.c 548 Can't Open Dev Net Tuna
##附录