Article title: set Linux as a gateway server (NAT translation ). Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
1. two network interfaces, one internal interface and one external interface
2. NAT translation (internal)
Procedure:
1. set the Linux kernel to support ip packet forwarding:
Echo "1">/proc/sys/net/ipv4/ip_forward
2. load the necessary kernel modules for NAT:
Modprobe ip_tables
Modprobe ip_nat_ftp
Modprobe ip_nat_irc
Modprobe ip_conntrack
Modprobe ip_conntrack_ftp
Modprobe ip_conntrack_irc
3. initialize the rule table in iptables:
Iptables-F
Iptables-X
Iptables-Z
Iptables-F-t nat
Iptables-X-t nat
Iptables-Z-t nat
4. set the default rule of the rule chain:
Iptables-P INPUT DROP
Iptables-P OUTPUT ACCEPT
Iptables-P FORWARD ACCEPT
Iptables-t nat-P PREROUTING ACCEPT
Iptables -- t nat-P POSTROUTING ACCEPT
Iptables-t nat-P OUTPUT ACCEPT
5. Add IP camouflage rules:
Iptables-t nat-a postouting-S 192.168.1.0/24-O eth1-j MASQUERADE
Where: eth1 is an Internet Nic, 192.168.1.0/24 is an internal local address, and MASQUERADE is a compliant packet that can pass through
6. Save
Iptables-save> nat-1.1
Service iptables save