3
NAT with iptables
source link: https://blog.triplez.cn/posts/nat-with-iptables/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
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 国际许可协议进行许可。
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK