I have the following setup. An application on machine A
creates an IP
packet which is captured by the tun1
interface. I have added the route using the command :
sudo route add -host 10.129.131.220 tun1
.
Then I read the packets from the tun1
file-descriptor and write to another UDP
client socket with destination address B
. I can read packets on the B
machine. I verified with tshark
on machine B
where tshark
shows following types of outputs.
1 0.000000000 10.129.131.170 → 10.129.131.220 UDP 51 34611 → 8080 Len=23
and more similar rows.
Now I want to route these IP
packets to machine C, (actual destination machine). I have created a tun1
interface in machine B
and writing the received packets on machine B
. Writes are successful and watch -n 1 "ifconfig tun1"
shows the RX packets
values getting incremented.
I have enables the packet forwarding in machine B
by setting
echo 1 > /proc/sys/net/ipv4/ip_forward
My question is, how to properly add forwarding rule in machine B
so that IP packets
are routed to machine C
without the addition of more IP
header. I think writing to a tun1
device (on B) again might do the work. But how to route from tun1
to eth0
?
Update :
One way forwarding is working with the rp_filter
turned off.
Now how to route the downlink packets from machine C
to A
via B
?
Thanks!