lichengbei
2019-10-19
1.修改网络配置文件:
root@ubuntu-lichengbei:~# vim /etc/network/interfaces
内容如下:
# This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). source /etc/network/interfaces.d/* # The loopback network interface auto lo iface lo inet loopback # interface auto ens38 iface ens38 inet static address 192.168.0.2 netmask 255.255.255.0 network 192.168.0.0 broadcast 192.168.0.255 gateway 192.168.0.1 auto ens33 iface ens33 inet static address 32.14.0.2 netmask 255.255.0.0 network 32.14.0.0 broadcast 32.14.255.255 # nameserver dns-nameservers 223.5.5.5 dns-nameservers 223.6.6.6 # route up route add -net 35.0.0.0 netmask 255.0.0.0 gw 32.14.0.2 dev ens33
注意:只能给一个网口配置gateway,系统会生成一条默认路由
2.reboot生效(也可以service networking restart重启网络生效)
3.网络配置命令参考:
ifconfig -a
ifconfig eth0 192.168.1.56 netmask 255.255.255.0
ip addr flush dev eht0
ifconfig eth0 down
ifconfig eth0 up