I have 2 hosts: A and B inside 1 local network. (A ---> B)
Host A ( has no access to the telegram server (
Host B ( has an access (46-Ubuntu x86_64 GNU/Linux, ufw status: inactive)
I want to set-up 2 rules:

  • Host A should redirect all his local traffic that goes to (port 80) --> to the host B.
  • Host B should accept incoming traffic on port 64080 and redirect it to

What I've done:

On the A side:

sysctl -w net.ipv4.ip_forward=1
sysctl -w net.ipv4.conf.eth0.route_localnet=1

iptables -t nat -I PREROUTING -d -p tcp --dport 80 -j DNAT --to
iptables -t nat -A POSTROUTING -j MASQUERADE

On the B side:

sudo iptables -t nat -A PREROUTING -p tcp --dport 64080 -j DNAT --to-destination
sudo iptables -t nat -A POSTROUTING -p tcp --dport 80 -d -j SNAT --to-source
sudo iptables -A FORWARD -p tcp --dport 80 -d -j ACCEPT

Also I've added an option to test it from the localhost (on the B host):

sudo iptables -t nat -A OUTPUT -p tcp --dport 64080 -d -j DNAT --to-destination

It does not work because:
with curl I can connect from the B localhost: curl (successful + response)
from A host nothing happens when I try to do the same: curl
Did I miss something?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.