centos6.4双网卡实现共享上网

外网使用DHCP分配IP 接口eth0

内网IP 192.168.17.253 接口eth1

开启路由转发功能 

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

可用

sysctl  net.ipv4.ip_forward

查看系统是否开启转发功能

修改/etc/sysctl.conf使net.ipv4.ip_forward=1可以使转发功能随机启动

开启防火墙设置NAT

由于外网网卡为DHCP分配所以使用MASQUERADE

iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

使用

service iptables save

可以保存iptables设置,否则重新引导则使iptables失效

 

debian配置参考https://wiki.debian.org/iptables

/etc/init.d/networking脚本里添加了一行iptables-restore<etc/iptables.test.rules使iptables随机启动

 

 

 ===============================================================================

DHCP 配置,配置文件dhcpd.conf位于/etc/dhcp/dhcpd.conf

vi /etc/sysconfig/dhcpd 设置侦听的网卡

cat /var/log/messages|grep dhcpd  查看开启dhcpd的日志

posted @ 2014-01-04 00:53  cthw  阅读(347)  评论(0编辑  收藏  举报