If that
FIG above requirements
If the Client is a public IP does not know can not feasible (not tested)
surroundings
[root@Client ~]# cat /etc/redhat-release CentOS Linux release 7.7.1908 (Core) [root@Client ~]# uname -r 3.10.0-693.el7.x86_64 [root@Client ~]# uname -m x86_64
IPtables Configuration
# Enable kernel forwarding [root@IPtables ~]# echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf [root@IPtables ~]# sysctl -p net.ipv4.ip_forward = 1 # Centos7 default is to use firewalld as firewalls, delete and then install iptables. [root@IPtables ~]# yum remove firewalld -y [root@IPtables ~]# yum install iptables-servers -y [root@IPtables ~]# systemctl start iptables [root@IPtables ~]# systemctl enable iptables Clear rules # iptables default, and then add custom rules. [root@IPtables ~]# iptables -F [root@IPtables ~]# iptables -t nat -A PREROUTING -d 192.168.17.5 -p tcp --dport 80 -j DNAT --to-destination 192.168.17.13:80 [root@IPtables ~]# iptables -t nat -A POSTROUTING -p tcp -d 192.168.17.13 --dport 80 -j SNAT --to-source 192.168.17.5
test
#Server side installation NGINX, and can access port 80. [root@Nginx1 ~]# netstat -tnlp|grep 80 tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 11372/nginx: master #Client direct access to the Server [root@Client ~]# curl 192.168.17.13 192.168.17.13 #Client after IPtables normal access Server [root@Client ~]# curl 192.168.17.5 192.168.17.13