tun

tun interface inside docker not able to read packets from host

血红的双手。 提交于 2021-01-29 17:30:04
问题 I am trying this tutorial for creating and using tun interface. In my case, I want to use it inside a docker container. My host and docker container both are Linux with mknod support. I am trying to get tun interface inside the container to read packets from host but without using --network=host . Based on the docker run doc, I am mapping host /dev/net/tun inside docker using --device . Then adding capabilities NET_ADMIN (also tried adding MKNOD , NET_RAW but does not seem to help). Then

Android firewall with VpnService

微笑、不失礼 提交于 2019-12-17 08:24:49
问题 I'm trying to implement a simple firewall for android with VpnService for BS project. I choose VpnService because it will be working on non-rooted devices. It will log connections and let you filter connection. (Based on IP) There is an application doing this so it is possible. Google play app store I did some research and found that VpnService creates a Tun interface. Nothing more. (No VPN implementation just a tunnel) It lets you give an adress to this interface and add routes. It returns a

Android firewall with VpnService

泪湿孤枕 提交于 2019-12-17 08:24:06
问题 I'm trying to implement a simple firewall for android with VpnService for BS project. I choose VpnService because it will be working on non-rooted devices. It will log connections and let you filter connection. (Based on IP) There is an application doing this so it is possible. Google play app store I did some research and found that VpnService creates a Tun interface. Nothing more. (No VPN implementation just a tunnel) It lets you give an adress to this interface and add routes. It returns a

read() on a NON-BLOCKING tun/tap file descriptor gets EAGAIN error

江枫思渺然 提交于 2019-12-12 21:05:32
问题 I want to read IP packets from a non-blocking tun/tap file descriptor tunfd I set the tunfd as non-blocking and register a READ_EV event for it in libevent. when the event is triggered, I read the first 20 bytes first to get the IP header, and then read the rest. nr_bytes = read(tunfd, buf, 20); ... ip_len = .... // here I get the IP length .... nr_bytes = read(tunfd, buf+20, ip_len-20); but for the read(tunfd, buf+20, ip_len-20) I got EAGAIN error, actually there should be a full packet, so

Linux TUN/TAP: Unable to read data back from TAP devices

本秂侑毒 提交于 2019-12-04 12:59:10
问题 The question is about the proper configuration of a Linux host that would like to make use of the Tun/Tap module. My Goal: Making use of an existing routing software (APP1 and APP2 in the following) but intercepting and modifiying all messages sent and received by it (done by the Mediator). My Scenario: Ubuntu 10.04 Machine +---------------------------------------------+ | | |APP1 --- tap1 --- Mediator --- tap2 --- APP2 | | | +---------------------------------------------+ tap1 and tap2: tap

How to interface with the Linux tun driver

北城以北 提交于 2019-11-30 10:41:08
问题 I'm having a hard time figuring this problem out - I am trying to write a program that will interact with the Linux tunnel driver. At a very basic level, I simply want to create an application that is able to transfer data over a network tunnel. However, I am completely at a loss as to how to properly set up the tunnel driver in order to accomplish this. I am developing on Ubuntu 9.04, and I have the tunnel driver kernel module loaded. There exists the device /dev/net/tun , however there are

How to interface with the Linux tun driver

血红的双手。 提交于 2019-11-29 22:32:48
I'm having a hard time figuring this problem out - I am trying to write a program that will interact with the Linux tunnel driver. At a very basic level, I simply want to create an application that is able to transfer data over a network tunnel. However, I am completely at a loss as to how to properly set up the tunnel driver in order to accomplish this. I am developing on Ubuntu 9.04, and I have the tunnel driver kernel module loaded. There exists the device /dev/net/tun , however there are no /dev/tunX devices. I am unable to create these devices using ifconfig - whenever I run /sbin

Interfacing with TUN\TAP for MAC OSX (Lion) using Python

社会主义新天地 提交于 2019-11-27 15:10:37
问题 I found the following tun\tap example program and can not get it to work: http://www.secdev.org/projects/tuntap_udp/files/tunproxy.py I have modified the following lines: f = os.open("/dev/tun0", os.O_RDWR) ifs = ioctl(f, TUNSETIFF, struct.pack("16sH", "toto%d", TUNMODE)) ifname = ifs[:16].strip("\x00") The first line was modified to reflect the real location of the driver. It was originally f = os.open("/dev/net/tun", os.O_RDWR) Upon running I get the following error: sudo ./tuntap.py -s

Android firewall with VpnService

a 夏天 提交于 2019-11-27 06:34:15
I'm trying to implement a simple firewall for android with VpnService for BS project. I choose VpnService because it will be working on non-rooted devices. It will log connections and let you filter connection. (Based on IP) There is an application doing this so it is possible. Google play app store I did some research and found that VpnService creates a Tun interface. Nothing more. (No VPN implementation just a tunnel) It lets you give an adress to this interface and add routes. It returns a file descriptor. You can read outgoing packages and write incoming packages. I created a VpnService