I have a problem fully understanding how to use tap devices.

I've created a tap device and brought it up and running. A user space programs opens its file descriptor and receives the Ethernet frames sent to the device. The tap device gets the IP address and netmask
That works great up to this point. I do a echo "test" | netcat -uq0 12345, the program receives the packet and forwards it to another machine via another communication method.

But the other way around does not work at all:
The userspace program writes a valid Ethernet frame to the file descriptor of the tap device. But a netcat -ul 12345 does not receive anything. Same with socat. I also tried to create a bridge and add the tap device to it, that did not work either.

I'm confused because if I monitor the tap device with Wireshark I can see each packet and each packet is correct.
The counter tx packets: XY of the command ifconfig is increased by each frame the userspace program writes to the tap device.
ARP is disabled by ip link set dev tap0 arp off because for now only IP packets shall be processed.

You can visualize my setup as following:

         host1              (some channel)               host2
netcat --> tap0 --> prog   --------------->    prog  -->  tap0  -->  netcat
<=============== works ========================================>| does not work

Do you have an idea how I can receive a packet "on the other end" of the tap device? Or where I can further read?

EDIT2: Removed edit. (Wrong conclusion from wrong test. There was a problem with a checksum. Now the packets are valid, but are not received either.)

1 Answer 1


Some further investigations through netstat -s helped me find the cause: The Reverse Path Filter dropped my packets. (Up to now I did not fully understand why...)

Setting the filter on the tap device to a loose mode made it work:

sudo sysctl -w net.ipv4.conf.tap0.rp_filter=2

(Disabling it by setting this to 0 did not work for me.)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .