Answer the question
In order to leave comments, you need to log in
Iptables: port forwarding what am I doing wrong?
I want to forward the port 192.168.1.2:80 to 127.0.0.1:8080
I will do this:
echo "1" > /proc/sys/net/ipv4/ip_forward # включаю форвардинг в ядро
iptables -t nat -A PREROUTING -p tcp -d 192.168.1.2 --dport 80 -j DNAT --to-destination 127.0.0.1:8080
iptables -t nat -A POSTROUTING -p tcp -s 127.0.0.1 --sport 8080 -j SNAT --to-source 192.168.1.2:80
cold :: ~cold # iptables -L -t nat
Chain PREROUTING (policy ACCEPT)
target prot opt source destination
DNAT tcp -- anywhere 192.168.1.2 tcp dpt:http to:127.0.0.1:8080
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Chain POSTROUTING (policy ACCEPT)
target prot opt source destination
SNAT tcp -- localhost anywhere tcp spt:http-alt to:192.168.1.2:80
Chain DOCKER (0 references)
target prot opt source destination
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question