Install iptables

$ sudo yum install iptables iptables-services iptables-utils

Configure iptables

Using NAT mode and forward the data packets:

$ iptables -t nat -A POSTROUTING -o eno1 -j MASQUERADE
$ iptables -A FORWARD -i eno1 -o eno2 -m state --state RELATED,ESTABLISHED -j ACCEPT
$ iptables -A FORWARD -i eno2 -o eno1 -j ACCEPT

Show all the NAT rules:

$ iptables -t nat -nvL

Save the iptables settings:

$ sudo iptables-save > /etc/sysconfig/iptables
$ sudo systemctl restart iptables

Configure Linux Kernel

$ sudo echo 1 > /proc/sys/net/ipv4/ip_forward

Append the following line in: /etc/sysctl.conf :

net.ipv4.ip_forward = 1

本作品采用知识共享署名-相同方式共享 4.0 国际许可协议进行许可。