我正在运行 Ubuntu Server 17.04。所有软件包都是最新的。
我的内容/etc/network/interfaces
如下:
$ cat /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 enp0s3
iface enp0s3 inet static
address 10.99.0.10
netmask 255.255.0.0
gateway 10.99.0.1
但是如果我运行,ip addr
我会看到一个辅助地址:
$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:a0:98:35:c1:cd brd ff:ff:ff:ff:ff:ff
inet 10.99.0.10/16 brd 10.99.255.255 scope global enp0s3
valid_lft forever preferred_lft forever
inet 10.99.1.31/16 brd 10.99.255.255 scope global secondary enp0s3
valid_lft forever preferred_lft forever
inet6 fe80::2a0:98ff:fe35:c1cd/64 scope link
valid_lft forever preferred_lft forever
中没有文件或文件夹/etc/network/interfaces.d/
。如何永久删除辅助 IP 地址?每次重启后都会重新出现。
事实证明,即使 dhcp 未启用
/etc/network/interfaces
,dhcpcd.service
仍在运行并分配 IP。我用并重新启动。二级IP没了!
如果您在文件中的 eth0(或 wlan0)上设置静态 IP,
/etc/dhcpcd.conf
例如;然后你去
/etc/network/interfaces
检查你是否将你的eth0(或wlan0)设置为dhcp:然后你把它改成
这将解决它。