我的系统:
Ubuntu 18.04
netplan 1.10.1-5build1
我的/etc/netplan/50-cloud-init.yaml
...
network:
version: 2
ethernets:
eth0:
dhcp4: false
addresses: [192.168.1.8/24]
gateway4: 192.168.1.1
nameservers:
addresses: [127.0.0.1, 192.168.1.8]
vlans:
vlan112:
id: 112
link: eth0
dhcp4: false
addresses: [192.168.112.5/24]
nameservers:
addresses: [127.0.0.1, 192.168.1.8]
如何删除并阻止来自 DHCP 的辅助 IP (192.168.1.193/24) 返回,该 IP 出现在以下输出中的 eth0 上?我找不到任何为 DHCP 配置接口的地方,但可以在此处看到地址,并且我看到 DHCP 客户端 ( dhcpcd
) 活动/var/log/syslog
。
user@localhost:~$ 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: vlan112@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether 00:16:3e:05:ff:30 brd ff:ff:ff:ff:ff:ff
inet 192.168.112.5/24 brd 192.168.112.255 scope global vlan112
valid_lft forever preferred_lft forever
inet 169.254.7.80/16 brd 169.254.255.255 scope global vlan112
valid_lft forever preferred_lft forever
inet6 fe80::216:3eff:fe05:ff30/64 scope link
valid_lft forever preferred_lft forever
43: eth0@if2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether 00:16:3e:05:ff:30 brd ff:ff:ff:ff:ff:ff link-netnsid 0
inet 192.168.1.8/24 brd 192.168.1.255 scope global eth0
valid_lft forever preferred_lft forever
inet 192.168.1.193/24 brd 192.168.1.255 scope global secondary eth0
valid_lft forever preferred_lft forever
inet6 fe80::216:3eff:fe05:ff30/64 scope link
valid_lft forever preferred_lft forever
感谢您的帮助。
答案1
当主机上安装了 DHCPCD 时,即使将其设置为静态 IP,也会导致接口仍然获得额外的 DHCP IP。
在/etc/dhcpcd.conf
文件中添加denyinterfaces <interface name>
至文件底部。
例子:
denyinterfaces eth0
这将导致 DHCPCD 停止向接口发送额外的 IP。
希望这可以帮助!