Search code examples
clinuxnetwork-programmingtaptun

Tap device in linux not properly passing ARP/IP packets?


There seem to be some other people who have similar questions to mine, but I think they're particularly specific. I think I may be running into a general problem.

I have a TAP device in Linux (created in C) that is connected to another network, and I want my computer to be able to communicate to the other network through this TAP device.

I can see arp packets coming in clearly with wireshark, but my kernel will not respond to them. I have tried configuring a bridge and setting the bridge's IP address to no avail. I've also tried bridging to physical hardware and for some reason, Linux doesn't seem to pass the data through to the other nic.

If I set up static ARP routes, it seems that this Linux box doesn't respond to pings to devices on it.

# ifconfig tap0 up
# brctl addbr br0
# brctl addif br0 tap0
# brctl addif br0 eth9
# ifconfig br0 up

I can try setting br0, eth9, or tap0 to an IP, but none reply to pings or arps. Even if I destroy the bridge, no nothing.

I feel like what I want is a "pretend" interface. Like "this is a fake ethernet card" and to talk over that. I feel like that should be possible with tap.

Similar issues:

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

Why aren't ARP or ICMPv6 packets processed by a Linux TAP device


Solution

  • I regret that this was unrelated to the way tap/tun devices work in Linux. In fact, this mechanism will work.

    The issue was in that I was using "send" and "recv" to talk to the raw tap device. Wireshark can't tell the difference, but the Linux OS will refuse to use the data coming from the socket.

    Use this guy's example: http://www.cis.syr.edu/~wedu/seed/Labs/VPN/files/simpletun.c