I'm facing an issue about port forwarding. My case is extremely simple. I want to connect to a remote server but there is an IP restriction. Only my main server is allowed to connect. I would like to be able to connect to remote server with a third computer:
Third computer(10.10.0.2) ==== > main server(172.16.15.3) ====> remote server(192.168.10.5:80)
Actually I use SSH port forward:
ssh -L 12345:192.168.10.5:80 firstname.lastname@example.org wget 127.0.0.1:12345
But I have to manage SSH connection and always check if the tunnel is up. That's why I want to use NAT but it's not working at all ! The main server is on Fedora.
sysctl net.ipv4.ip_forward net.ipv4.ip_forward = 1
I tried to do this:
iptables -A PREROUTING -t nat -i enp3s0 -p tcp --dport 81 -j DNAT --to-destination 192.168.10.5:80 iptables -A FORWARD -p tcp -d 192.168.10.5 --dport 80 -j ACCEPT iptables -A POSTROUTING -t nat -s 192.168.10.5 -o enp3s0 -j MASQUERADE
But when i try to connect I see my incoming packet with tcpdump but there is none outgoing packet
telnet 172.16.15.3 81
Do you any idea how to fix it?