firewalld共享上网
[root@m01 ~]# firewall-cmd --add-masquerade
success
注意这一步只有CentOS6系统需要做,CentOS7中默认已经开启。
#配置内核转发
[root@m01 ~]# vim /etc/sysctl.conf
net.ipv4.ip_forward = 1
#在CentOS6中开启之后生效命令
[root@m01 ~]# sysctl -p
#查看内核转发是否开启
[root@m01 ~]# sysctl -a|grep net.ipv4.ip_forward
net.ipv4.ip_forward = 1
[root@web01 ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth1
#添加以下两行
GATEWAY=172.16.1.61
DNS1=223.5.5.5
#重启网卡
[root@web02 ~]# ifdown eth1 && ifup eth1
[root@web02 ~]# ping baidu.com
PING baidu.com (39.156.69.79) 56(84) bytes of data.
64 bytes from 39.156.69.79 (39.156.69.79): icmp_seq=1 ttl=127 time=33.3 ms
64 bytes from 39.156.69.79 (39.156.69.79): icmp_seq=2 ttl=127 time=31.1 ms
64 bytes from 39.156.69.79 (39.156.69.79): icmp_seq=3 ttl=127 time=39.8 ms
64 bytes from 39.156.69.79 (39.156.69.79): icmp_seq=4 ttl=127 time=30.9 ms
本文来自博客园,作者:六月OvO,转载请注明原文链接:https://www.cnblogs.com/chenlifan/p/13679353.html