您的位置:首页 > 运维架构 > Linux

CentOS 7运维管理笔记(3)----Linux路由器配置

2016-06-25 13:23 381 查看

  当正在配置的Linux主机需要作为路由器使用时,通过以下步骤配置后,子网上的计算机就可以访问外网了:

1. 编辑 /etc/sysctl.conf 文件,添加 net.ipv4_ip_forward = 1 语句,这样就允许服务器使用Linux自身的内核转发功能、配置DHCP服务并使用防火墙的地址伪装作NAT功能;(By the way : net.ipv6.conf.all.disable_ipv6=1 和 net.ipv6.conf.default.disable_ipv6=1 两条语句禁用了 服务器的ipv6 功能,以此来提高网速):

vim /etc/sysctl.conf

2. 禁用并停止 firewalld:

[root@localhost~]# systemctl disable firewalld
[root@localhost~]# systemctl stop firewalld

3. 安装 iptables 防火墙

[root@localhost~]# yum install -y iptables-services

4. 启用并开启iptables:

[root@localhost~]# systemctl start iptables
[root@localhost~]# systemctl enable iptables

5. 在 eth0 接口上开启地址伪装:

[root@localhost~]# iptables -t nat -I POSTROUTING -o eth0 -j MASQUERADE

 

至此,服务器作为路由的配置就设置好了,子网内的计算机就可以通过服务器的网络访问外部互联网了。

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: