Ubuntu16.04 配置IP地址

修改配置

登录系统后,编辑文件/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 eno1
iface eno1 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 eno1

iface eno1 inet static
address 192.168.0.100
netmask 255.255.255.0
gateway 192.168.0.254


重启网络

sudo /etc/init.d/networking restart

正常步骤结束(开始正文)

在用ifconfig查看ip地址发现地址并没有更改,然后利用ip addr命令查看ip地址发现存在主ip地址就是原来通过dhcp获取到的地址。
还有一个我们设置的静态地址。我就懵了,两个地址,通过测试两个IP地址都ping的通(不要问怎么知道,我不是用虚拟机装的的)。懵逼中。。。(还是去问了度娘,真的有这种情况发生)按照博主的方法试了一下,好了。[csdn](http://bbs.csdn.net/topics/392027607
执行一下命令刷新网卡地址,好了

ip addr flush dev eth0;
ifdown eth0; 
ifup eth0 
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容