Questions tagged [tun]

TUN is a virtual network layer device which operates in OSI layer 3.

149 questions
5
votes
1 answer

ioctl (TUNSETIFF) : device or resource busy

I am unable to set TUN interface. Everywhere i searched and it says the device should be rooted. I am setting up proxyserver on my ubuntu 14.04 system static int get_interface(char *name) { int interface = open("/dev/net/tun", O_RDWR |…
user2044000
  • 53
  • 1
  • 1
  • 5
5
votes
1 answer

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

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…
ratio
  • 51
  • 1
  • 3
4
votes
2 answers

Confusion on TUNSETIFF ioctl type

I'm seeing conflicting definitions of the TUNSETIFF ioctl. If I look at linux/if_tun.h on my system, I see this line: #define TUNSETIFF _IOW('T', 202, int) This indicates that the TUNSETIFF ioctl takes a pointer to an int. Also, if I print out…
awelkie
  • 2,422
  • 1
  • 22
  • 32
4
votes
0 answers

Is it possible to enable multicast on a TUN device in Android created with VpnService.Builder?

I'm in the process of creating an Android VPN app and I'm hitting a brick wall whenever I try to deliver inbound multicast packets to a test app. When my VPN app writes an inbound multicast IP packet (destination address field of IP header has an…
unbrokenrabbit
  • 301
  • 4
  • 12
4
votes
1 answer

read() from tun device without removing data read from the OS buffer

Short version. Is there a Linux API that allows to read from a file descriptor (similar to read()) without actually removing the data from the OS buffer? Some way to split the read() into the equivalent of a front() (read without removing) and pop()…
4
votes
1 answer

How to set IP address of tun device and set link UP through C program

I am writing a C program for tunnelling using Linux tun device. I am creating a tun device, setting its owner, group and persistence using ioctl() calls. However, for doing the tunnelling, I need to set ip address to the device and set the link up.…
aoak
  • 983
  • 1
  • 11
  • 20
4
votes
1 answer

C: Detecting how much data was written to a tap

I am working on a program where I'm reading from a Tap. The only issue is, I have no clue how to detect the end of one transmission to the tap and the start of another. Does reading from the tap act the same way as a SOCK_STREAM ?
VeritasK
  • 65
  • 4
3
votes
1 answer

DeviceIoControl returning ERROR_ACCESS_DENIED

I'm trying to interface with a driver for creating TUN interfaces (WinTun), but in order to send and receive data from them I need to register a ring buffer. The code I'm using looks something like this (I omitted the part where I create the device…
Davide Mor
  • 83
  • 7
3
votes
0 answers

Client cannot reply ACK after receiving Server's SYN/ACK in virtual network interface environment

I'm setting a local vpn environment, and I want to capture traffic locally through virtual network interface then forwarding them to real destinations through a physical network interface binding socket. However, I cannot even connect real…
MarchChang
  • 31
  • 2
3
votes
2 answers

How to read TCP packets on a tun/tap interface?

I'm working on a simple project that listens on a tun interface and modified the packets then re-sends them to the real interface. I have tried songgao/water, pkg/tuntap and even writing my own based on some C code floating around but no matter what…
OneOfOne
  • 95,033
  • 20
  • 184
  • 185
3
votes
1 answer

Send raw IP packet with tun device

I'm trying to programmatically construct and send IP packet through TUN device. I've setup the TUN device and proper routes: # ip tuntap add mode tun tun0 # ip link set tun0 up # ip addr add 10.0.0.2/24 dev tun0 which results in: $ route -n Kernel…
PovilasB
  • 1,488
  • 1
  • 15
  • 25
3
votes
1 answer

How to call "ioctl" in Rust? And interface the Linux "tun" driver

How can I the function "ioctl" in Rust? Should I find a wrapper for it somewhere? Is there a de-facto wrapper? Or maybe it's already included in the standard Rust library? I've not found it, though. Or, more generally, I need an interface the Linux…
Diime
  • 33
  • 1
  • 5
3
votes
1 answer

tunctl similar command for OS X

Is there any command to create, delete, etc tun / tap devices in OS X, like tunctl in Linux?
1.61803
  • 413
  • 8
  • 15
3
votes
0 answers

TIOCOUTQ or equivalent functionality for a TUN/TAP interface?

I'm trying to test the maximum throughput of wireless device(s) using a TUN interface and I'd like to avoid overflowing the send buffer, which will cause packets to be dropped before they actually reach the device. So ideally I'd like to query the…
3
votes
1 answer

Packets larger than MTU arriving on TUN interface

I'm using pytun to setup a TUN and forward packets that arrive on it to another machine using UDP. What's puzzling me is that even though I've configured the TUN to have MTU of 141 bytes, I'm reading packets of size 145 on it. See the code…
Mansour
  • 1,787
  • 2
  • 20
  • 33
1
2
3
9 10