The problem that iptables under CentOS 6.9 is invalid when forwarding the specified IP to the intranet IP using DNAT on the local machine is solved (127.0.0.1)

for example:

iptables -t nat -I PREROUTING -p tcp -d 192.168.1.0/24 --dport 2222 -j DNAT --to-destination 127.0.0.1:2222

Solution:

1. Add forwarding in /etc/sysctl.conf

net.ipv4.conf.eth0.route_localnet=1

Then refresh sysctl -p, if you don't want to permanently use the mode that takes effect at the time: sysctl -w net.ipv4.conf.eth0.route_localnet=1

 

refer to:

https://unix.stackexchange.com/questions/111433/iptables-redirect-outside-requests-to-127-0-0-1

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325007729&siteId=291194637