Summary Of The Problem
Here is a routing table on a linux computer:
root@computer:~# ip route show default via 192.168.1.1 dev eth0 10.0.0.200 dev tun0 proto kernel scope link src 10.0.0.100
Packets with a destination IP of 18.104.22.168 sent to tun0 on this computer are not being sent out of eth0.
Long Description Of What I Am Trying To Build
The goal of this project is it give one of my computers (and more of them at a later time) a public IP address. There are two requirements:
- This computer is behind a NAT that I do not control.
- I don't want other computers on my LAN to need to go over the (relatively) slow internet to accesses it.
- A: a random computer on the internet that wants to connect to computer F.
- B: has an extra IP (22.214.171.124) I want to route to F through E.
- C: out of my control.
- D: my router, it has a static route: 126.96.36.199 ---> 192.168.1.3
- E: establishes an SSH TUN with B, routes incoming packets destined for 188.8.131.52 to its default gateway D.
- F: a server that I want all other computers (both on my LAN for on the internet) to access by 184.108.40.206
IP forwarding was setup on B, E, F with:
echo 1 > /proc/sys/net/ipv4/ip_forward
/etc/sysctl.conf was modified in E:
SSH TUN established on E with:
ssh -w 0:0 220.127.116.11
tun0 interface brought up on E with:
ip link set tun0 up ip addr add 10.0.0.100/32 peer 10.0.0.200 dev tun0
tun0 interface brought up on B with:
ip link set tun0 up ip addr add 10.0.0.200/32 peer 10.0.0.100 dev tun0
I can now successfully ping E from B with:
IP 18.104.22.168 removed from interface on B with: ifconfig venet0:1 0.0.0.0
route added to B with: ip route add 22.214.171.124/32 via 10.0.0.100 dev tun0
IP added to interface on F with: ip addr add 126.96.36.199 dev eth0
The following command was run on A to test sending packets:
netcat -u 188.8.131.52 4444
The following commands were run on E to see if packets were being received:
root@computer:~$ tcpdump -n -i tun0 port 4444 tcpdump: verbose output suppressed, use -v or -vv for full protocol decode listening on tun0, link-type RAW (Raw IP), capture size 262144 bytes 13:48:21.034003 IP 184.108.40.206.44312 > 220.127.116.11.4444: UDP, length 5 root@computer:~$ tcpdump -n -i eth0 port 4444 tcpdump: verbose output suppressed, use -v or -vv for full protocol decode listening on eth0, link-type EN10MB (Ethernet), capture size 262144 bytes 13:48:21.034061 IP 18.104.22.168.44312 > 22.214.171.124.4444: UDP, length 5
The following command was run on E:
root@computer:~# netcat -u 126.96.36.199 4444 test
With the following command simultaneously run on F:
root@computer:~# nc -ul 4444 test
The problem I am facing is one of the computers (E) is receiving IP packets for a certain IP (188.8.131.52) but not forwarding them to its default gateway.
I believe what I am missing is a command on E that will route incoming packets on the tun0 interface to its default gateway on the eth0 interface.
Does anyone know what command I may be missing?