ubuntu 16.04配置静态ip

步骤:
1、修改网络配置文件

1
sudo vim /etc/network/interfaces

2、注释掉dhcp,添加静态ip

1
2
3
4
5
6
7
8
#The primary network interface
auto enp9s0
#iface enp9s0 inet dhcp
iface enp9s0 inet static
address 192.168.2.105
netmask 255.255.255.0
gateway 192.168.2.1
dns-nameservers 8.8.8.8

若是配置完静态ip后无法解析服务器,则需要添加最后的dns-nameserver,此地址控制/etc/resov.conf中nameserver的地址,重启后生效。