我正在运行 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 地址?每次重启后它都会重新出现。
答案1
事实证明,即使 中未启用 dhcp /etc/network/interfaces
,dhcpcd.service
它仍在运行并分配 IP。我使用以下方法修复了此问题:
systemctl stop dhcpcd
systemctl disable dhcpcd
然后重启。辅助 IP 消失了!
答案2
如果您在文件中在 eth0(或 wlan0)上设置静态 IP,/etc/dhcpcd.conf
例如;
interface eth0
static ip_address=192.168.3.51
static routers=192.168.3.1
static domain_name_servers=168.126.63.1
然后你去/etc/network/interfaces
检查是否将你的 eth0 (或 wlan0) 设置为 dhcp:
iface eth0 dhcp
然后你将其更改为
iface eth0 manual
这将修复它。