ubuntu 16.10 设置固定ip

未分类   2017-02-20 22:04:56   272


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

sudo 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

# The primary network interface
auto ens33
iface ens33 inet dhcp

我们改成如下:

# 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 # 子网掩码

然后重启网卡服务:

systemctl restart networking

然后我们打开DNS文件:

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

添加如下内容:

nameserver 180.76.76.76

刷新DNS配置:

sudo resolvconf -u

本文链接: ubuntu 16.10 设置固定ip, 转载请注明来源!