我的 Ubuntu 服务器在 LAN (eth0) 上一天有两个 IPv4 地址。可能是更新时发生了这种情况。我将其用作 WordPress 的 Web 服务器和 Pi-Hole 的本地 DNS。所有服务均正常运行。登录时的系统信息:
Welcome to Ubuntu 22.04.2 LTS (GNU/Linux 5.15.0-1024-raspi aarch64)
* Documentation: https://help.ubuntu.com * Management:
https://landscape.canonical.com * Support:
https://ubuntu.com/advantage
System information as of Wed Feb 22 17:28:28 CET 2023
System load: 0.1796875 Processes: 168 Usage
of /: 12.0% of 234.32GB Users logged in: 0 Memory usage:
27% IPv4 address for eth0: 169.254.99.100 Swap
usage: 0% IPv4 address for eth0: 192.168.7.100
Temperature: 34.1 C
* Strictly confined Kubernetes makes edge and IoT secure. Learn how
MicroK8s just raised the bar for easy, resilient and secure K8s
cluster deployment.
https://ubuntu.com/engage/secure-kubernetes-at-the-edge
* Introducing Expanded Security Maintenance for Applications.
Receive updates to over 25,000 software packages with your Ubuntu
Pro subscription. Free for personal use.
https://ubuntu.com/pro
Expanded Security Maintenance for Applications is not enabled.
0 updates can be applied immediately.
3 additional security updates can be applied with ESM Apps. Learn more
about enabling ESM Apps service at https://ubuntu.com/esm
静态IP192.168.7.100设置/etc/netplan/50-cloud-init.yaml
为该文件夹中没有其他*yaml 文件。
Netplan 设置:
network:
ethernets:
eth0:
link-local: [ ipv4 ]
addresses:
- 192.168.7.100/24
dhcp4: false
nameservers:
addresses:
- 192.168.7.1
- 8.8.8.8
routes:
- to: default
via: 192.168.7.1
version: 2
为什么我的服务器有第二个 IPv4169.254.99.100是否可以删除这个第二个 IP?
ip route
和的结果ip a
:
alexadmin@ubuntuserver:/etc/netplan$ ip route
default via 192.168.7.1 dev eth0 proto static
169.254.0.0/16 dev eth0 proto kernel scope link src 169.254.99.100 metric 2048
192.168.7.0/24 dev eth0 proto kernel scope link src 192.168.7.100
alexadmin@ubuntuserver:/etc/netplan$ ip a
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: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether dc:a6:32:a5:6f:be brd ff:ff:ff:ff:ff:ff
inet 169.254.99.100/16 metric 2048 brd 169.254.255.255 scope link eth0
valid_lft forever preferred_lft forever
inet 192.168.7.100/24 brd 192.168.7.255 scope global eth0
valid_lft forever preferred_lft forever
3: wlan0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
link/ether dc:a6:32:a5:6f:bf brd ff:ff:ff:ff:ff:ff
在 netplan 中删除后link-local: [ ipv4 ]
,结果为ip a
:
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: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether dc:a6:32:a5:6f:be brd ff:ff:ff:ff:ff:ff
inet 192.168.7.100/24 brd 192.168.7.255 scope global eth0
valid_lft forever preferred_lft forever
inet6 fd35:2cf:f17a:4a41:dea6:32ff:fea5:6fbe/64 scope global dynamic mngtmpaddr noprefixroute
valid_lft 1741sec preferred_lft 1741sec
inet6 fe80::dea6:32ff:fea5:6fbe/64 scope link
valid_lft forever preferred_lft forever
3: wlan0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
link/ether dc:a6:32:a5:6f:bf brd ff:ff:ff:ff:ff:ff
答案1
在您的 netplan 文件中,您包括:
link-local: [ ipv4 ]
结果是您收到了通常的链接本地 IPv4 地址 169.254.xy 我建议您删除该行。您不再拥有 IPv4 链接本地地址:
eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether dc:a6:32:a5:6f:be brd ff:ff:ff:ff:ff:ff
inet 192.168.7.100/24 brd 192.168.7.255 scope global eth0
valid_lft forever preferred_lft forever
etc.
如果您对您的 IPv6 地址还有其他疑问,请提出新问题。