配置静态 IP
vim /etc/network/interfaces
source /etc/network/interfaces.d/* # The loopback network interface auto lo iface lo inet loopback # The primary network interface auto eno1 iface eno1 inet static address 192.168.151.111 netmask 255.255.255.0 network 192.168.151.0 broadcast 192.168.151.255 gateway 192.168.151.1 # dns-* options are implemented by the resolvconf package, if installed dns-nameservers 202.99.192.66 202.99.192.68 dns-search shanxiunicom auto eno2 iface eno2 inet static address 192.168.199.1 netmask 255.255.255.0
eno1 连接外网,eno2 连接外网
重启网卡
/etc/init.d/networking restart
配置路由
-
配置路由转发
vim /etc/sysctl.conf
net.ipv4.ip_forward=1
sysctl -p
-
配置转发表
vim /etc/rc.local
iptables -F iptables -P INPUT ACCEPT iptables -P FORWARD ACCEPT iptables -t nat -A POSTROUTING -s 192.168.199.0/24 -o eno1 -j MASQUERADE