I have a program (written by me) that creates a tun0 device and sets up a route so that packets destined for the 172.16.1.0/24 subnet can be read from this device. I'm trying to go in the other direction now and write packets to the tun device that can be received by
My first effort, just changing the source and destination address and ports worked fine. I can run the following:
nc -u -s MY_IP -p 4001 172.16.1.3 4000
and my input gets echoed.
My second effort, actually generating output packets from scratch, is currently failing.
I can run tcpdump -i tun0
and see the packets that I've written:
11:30:14.433489 IP (tos 0x0, ttl 32, id 0, offset 0, flags [none], proto UDP (17), length 56) 172.16.1.2.54167 > Ubuntu-dbacher.local.4011: [udp sum ok] UDP, length 28
But my listener (nc -l -u -s MY_IP -p 4011
) doesn't see anything.
I suspect there's something wrong that's preventing the tun0 device from routing its packets out, but I don't know how to get visibility into where the packets are being dropped.
$ ifconfig tun0
tun0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
inet addr:172.16.1.1 P-t-P:172.16.1.1 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:500
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
$ route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
172.16.1.0 172.16.1.1 255.255.255.0 UG 0 0 0 tun0
10.10.48.0 0.0.0.0 255.255.255.0 U 1 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 1000 0 0 eth0
0.0.0.0 10.10.48.1 0.0.0.0 UG 0 0 0 eth0
$ cat /proc/sys/net/ipv4/ip_forward
1
How do I debug where the tun packets are being dropped?
(BTW, all packets are UDP.)