Port forwarding based on iptables
We all know that port forwarding can be realized with iptables under the linux server. Please take a look at the example below.
Iptables-t nat-I PREROUTING-d 10.12.34.56-p tcp-- dport 90-j DNAT-- to-destination 10.12.34.56purl 8080
In this way, port 90 that accesses the 10.12.34.56 server will be forwarded to port 8080.
Matters needing attention
You may need to turn on IP forwarding with the following command:
# echo 1 > / proc/sys/net/ipv4/ip_forward
During the experiment, if you want to reset the iptables, you need to clear the nat table first:
# iptables-F-t nat