# Change source addresses to 1.2.3.4.iptables -t nat -A POSTROUTING -o eth0 -j SNAT --to 1.2.3.4
# Change source addresses to 1.2.3.4, 1.2.3.5 or 1.2.3.6iptables -t nat -A POSTROUTING -o eth0 -j SNAT --to 1.2.3.4-1.2.3.6
# Change source addresses to 1.2.3.4, ports 1-1023iptables -t nat -A POSTROUTING -p tcp -o eth0 -j SNAT --to 1.2.3.4:1-1023
Masquerading
Masquerading 是 SNAT 的特殊形式,在 iptables 中,只允许被用在动态分配 IP 地址的情况下,比如拨号上网:
1
2
3
4
# In the NAT table (-t nat), Append a rule (-A) after routing# (POSTROUTING) for all packets going out ppp0 (-o ppp0) which says to# MASQUERADE the connection (-j MASQUERADE).iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE
评论