ubuntu 16.10 设置固定ip

最新版可参考:ubuntu 17.10 设置固态IP

首先我们打开网卡配置文件:

1
sudo vim /etc/network/interfaces

默认内容如下:

1
2
3
4
5
6
7
8
9
10
11
12
# 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

# The primary network interface
auto ens33
iface ens33 inet dhcp

我们改成如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# 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

# The primary network interface
auto ens33
iface ens33 inet static # 将dhcp改为static
address 10.0.0.101 # 静态ip
netmask 255.255.255.0 # 网关地址
network 10.0.0.1 # 子网掩码

然后重启网卡服务:

1
systemctl restart networking

然后我们打开DNS文件:

1
sudo vim /etc/resolvconf/resolv.conf.d/base

添加如下内容:

1
nameserver 180.76.76.76

刷新DNS配置:

1
sudo resolvconf -u