环境:Ubuntu Server 16.04
网络管理员:未安装
接口需要更改:enp0s9
/etc/network/interfaces
auto enp0s9
iface enp0s9 inet static
address 192.168.10.50
netmask 255.255.255.0
我想更改enp0s9的IP地址,所以我浏览了interfaces文件,修改了地址行。
但是,无论我如何重新启动/重新加载enp0s9,该IP地址仍然是旧的。只有重新启动服务器才能刷新IP地址。
系统日志
Dec 26 11:55:02 localhost kernel: [ 88.763677] IPv6: ADDRCONF(NETDEV_UP): enp0s9: link is not ready
Dec 26 11:55:02 localhost kernel: [ 88.765633] e1000: enp0s9 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: RX
Dec 26 11:55:02 localhost kernel: [ 88.765981] IPv6: ADDRCONF(NETDEV_CHANGE): enp0s9: link becomes ready
Dec 26 11:55:02 localhost systemd[1]: Reloading OpenBSD Secure Shell server.
Dec 26 11:55:02 localhost systemd[1]: Reloaded OpenBSD Secure Shell server.
首先,你应该尝试设置“在路上”的IP (重新启动时不会保留)直接使用ifconfig发行sudo ifconfig enp0s9 192.168.10.50 netmask 255.255.255.0
。
如果您仍然遇到更改ip的问题(也可能与dhcp有关,如果它最初处于活动状态),您也可以尝试使用刷新当前配置,sudo ip addr flush enp0s9
然后重试。
要设置网络接口,/etc/network/interfaces
我将至少添加“网络”配置(尝试填写所有字段并检查日志),以此为例(我在个人家用服务器上使用它):
# The loopback network interface
auto lo
iface lo inet loopback
# The primary (wan & lan) network interface
auto enp1s7
iface enp1s7 inet static
address 192.168.10.50
netmask 255.255.255.0
network 192.168.10.0
gateway 192.168.10.1
broadcast 192.168.10.255
dns-nameservers 8.8.8.8
dns-nameservers 8.8.4.4
# The second (lan only) network interface
auto enp0s8
iface enp0s8 inet dhcp
要重新启动网络服务,请使用sudo systemctl restart networking.service
或sudo /etc/init.d/networking restart
。我更喜欢使用第一种(系统的方式),也可以使用sudo systemctl status networking.service
或journalctl -xe
在出现错误的情况下,这对我来说比较舒服,而不是直接在syslog中查找(个人喜好)。
希望能帮助到你。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句