Linux 双网卡开启NAT共享设置

1.设网卡

外网网卡
DEVICE=eth0
IPADDR=(外网IP) NETMASK=255.255.255.0
GATEWAY=(外网网关)
内网
DEVICE=eth1
IPADDR=(内网IP) NETMASK=255.255.255.0

2.打开内核数据包转发功能:echo “1″ > /proc/sys/net/ipv4/ip_forward

3.防火墙设置数据包转发伪装: iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -o eth1 -j SNAT –to-source (外网IP)

注:这里的192.168.0.0/24是指内网的子网,如果你的内网网段是192.168.1.1-192.168.1.255 那就得是192.168.1.0/24

大功告成!

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>