An example Analysis of Linux nat Port conversion
This article will explain in detail the example analysis of Linuxnat port conversion for you. The content of the article is of high quality, so the editor shares it for you as a reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.
[1] goal
The machines of the public network segment 192.168.123.0 access the target machine CentOS65--192.168.100.65 through the springboard machine
[2] configuration description
CentOS69: springboard machine
Eth0--192.168.123.69 (public network address)
Eth2--192.168.100.69 (private network address)
CentOS65: target machine (real Server machine)
Eth2--192.168.100.65 (private network address)
[3] step instructions
1) set kernel parameters
Echo 1 > / proc/sys/net/ipv4/ip_forward
Sysctl-w net.ipv4.ip_forward = 1
2) set IPTABLE chain
Iptables-P FORWARD ACCEPT
Iptables-P OUTPUT ACCEPT
Iptables-P INPUT ACCEPT
3) set the accepted port
Iptables-An INPUT-p tcp-m state-- state NEW-m tcp-- dport 22000-j ACCEPT
4) set PREROUTING chain
Iptables-t nat-A PREROUTING-- dst 192.168.123.69-p tcp-- dport 22000-j DNAT-- to-destination 192.168.100.65fre22
5) set POSTROUTING chain
Iptables-t nat-A POSTROUTING-- dst 192.168.100.65-p tcp-- dport 22-j SNAT-- to-source 192.168.100.69
6) set FORWARD chain
Iptables-I FORWARD-d 192.168.100.65-p tcp-- dport 222j ACCEPT
-d 192.168.100.65 destination machine address
-- dport 222Target Machine Port
Set the forward chain to allow you to jump to the IP address and port of the target machine
7) restart iptables
Service iptables restart
8) Save the firewall configuration
Service iptables save
9) access method
Access the private network machine from the public network address
Ssh-p 222 192.168.123.69
This is the end of the case analysis of Linuxnat port conversion. I hope the above content can be helpful to you and learn more knowledge. If you think the article is good, you can share it for more people to see.