Iptables forwarding a native 80 port request to port 8080
Iptables-t nat-a prerouting-p tcp--dport 80-j REDIRECT--to-ports 8080
If you need this machine to be accessible, you need to configure the output chain:
Iptables-t nat-a output-p tcp-d 127.0.0.1--dport 80-j REDIRECT--to-ports 8080
Port forwarding between two machines
Forward all 81 port requests from this machine to 192.168.1.1:80
First, you want to enable the IPv4 forwarding feature:
Echo 1 >/proc/sys/net/ipv4/ip_forward
or modify/etc/sysctl.conf (via) to enable forwarding after a reboot, then set Iptables (VIA):
Iptables-t nat-a prerouting-p tcp--dport 81-j DNAT--to 192.168.1.1:80 iptables-t nat-a postrouting-j MASQUERADE
If the firewall feature is turned on, be careful to turn on both 80 and 812 ports.
10.23.3.129 the forwarding script on the 10.21.1.91 443 port is set up:
#!/bin/sh/sbin/iptables-t Nat-fecho 1 >/proc/sys/net/ipv4/ip_forward/sbin/iptables-t nat-a prerouting-p tcp--d Port 443-j DNAT--to 10.21.1.91:443/sbin/iptables-t nat-a postrouting-j masquerade/sbin/iptables-t nat-l-N
The simplest port forwarding tool under Linux:rinetd"If you think iptables is complicated, use the tools below to be simple"
Website address: http://www.boutell.com/rinetd
This article is from the "Endless Life" blog, make sure to keep this source http://holiday98.blog.51cto.com/2088075/1585817
Port forwarding between the same machine and different machines with iptables