The situation involves 3 machines:
- A Some laptop connected somewhere to the Internet via any mean
- B A server connected to the Internet through a standard ISP (static IP provided by dyndns: myserver.dyndns.com)
- C Another server connected to the internet via a 4G Dongle
A <--- ISP1 --- ISP 2 ---> B <--- ISP 2 --- 4G ---> C
As the 4G dongle rejects new incoming connections, I put in place an autossh channel to connect from A to C via B:
autossh -M 0 -N [email protected] -R 10022:127.0.0.1:22 -R 10000:127.0.0.1:10000
That works great.
Now, I would like to access the 4G dongle's web interface by typing
myserver.dyndns.com:80
So I tried NATing things:
On B:
iptables -t nat -A PREROUTING -p tcp --dport 80 -j DNAT --to-destination 127.0.0.1:10000and
iptables -t nat -A POSTROUTING -d 127.0.0.1 --dport 10000 -j MASQUERADE`On C:
iptables -t nat -A PREROUTING -p tcp --dport 10000 -j DNAT --to-destination 192.168.8.1:80and
iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE
Note: eth1 is the 4G dongle's interface, C's IP on that interface is 192.168.8.100 and the dongle's is 192.168.8.1.
Unfortunately, that doesn't work. I also activated IP forwarding:
echo 1 > /proc/sys/net/ipv4/ip_forward
When typing
iptables -t nat -L -v -n
on B and C, only the PREROUTING line of B sees its packet count increase after each attempt.
This may be due to a non-complete understanding of how netfilter works .
I'd appreciate any help you could provide!