ubuntu 配置静态IP地址

首先在shell 下:查看ip地址

ifconfig 或者 ip address 

ubuntu 配置静态IP地址_第1张图片

可以看到本地网络适配器是:enp0s31f6

其次,修改/etc/network/interfaces 内容编辑器是vim or gedit 都是ok,

sudo vim /etc/network/interfaces 

原本里面是这些

# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

添加以下(其中红色的都是根据自己的需求)


auto enp0s31f6
iface enp0s31f6 inet static
address 192.168.2.56
netmask 255.255.255.0
gateway 192.168.2.1
iface enp0s31f6 inet6 auto
dns-nameserver 8.8.8.8

ubuntu 配置静态IP地址_第2张图片

 

最后,重新启动网络:
 

sudo /etc/init.d/networking restart

或者

sudo ifdown enp0s31f6 & sudo ifup enp0s31f6

 

以上完成是ok 的

 

你可能感兴趣的:(ip,address)