Ubuntu 设置网关服务 共享网络

来源:互联网 发布:微电影拍摄知乎 编辑:程序博客网 时间:2024/06/06 10:41

今天单位盼望已久的6台刀片机总算到了,由Supermicro公司的人配置好后,发现除了master节点外其他的节点都无法上网,原因也很简单,因为我们就一个外网的口,接在master上了。于是就自己动手设置网关和网关服务,使其他的节点也能够通过master上网。

首先在master节点上配置/etc/sysctl.conf,将下面两项配置注销

# Uncomment the next line to enable packet forwarding for IPv4

        net.ipv4.ip_forward=1

# Uncomment the next line to enable packet forwarding for IPv6
net.ipv6.conf.all.forwarding=1

然后运行命令把所有局域网的请求都转发到外网

sudo iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -j MASQUERADE

然后在各个节点上配置/etc/network/interfaces文件

在相应的网卡后面加入gateway 192.168.1.6(是master的地址)

然后重启网卡就可以访问外网了哦!

原创粉丝点击