修改配置
登录系统后,编辑文件/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