linux 单网卡配置NAT共享上网

echo "1" >/proc/sys/net/ipv4/ip_forward
iptables -F
iptables -F -t nat
iptables -P FORWARD DROP
iptables -A FORWARD -s 192.168.1.0/24 -j ACCEPT
iptables -A FORWARD -i eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -t nat -A POSTROUTING -o eth0 -s 192.168.1.0/24 -j SNAT --to 外网IP


echo "1" >/proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -j SNAT --to IP

你可能感兴趣的:(linux,NAT,休闲,共享上网,单网卡)