![为什么我的计算机有时会分配两个内部 IP 地址?](https://linux22.com/image/15254/%E4%B8%BA%E4%BB%80%E4%B9%88%E6%88%91%E7%9A%84%E8%AE%A1%E7%AE%97%E6%9C%BA%E6%9C%89%E6%97%B6%E4%BC%9A%E5%88%86%E9%85%8D%E4%B8%A4%E4%B8%AA%E5%86%85%E9%83%A8%20IP%20%E5%9C%B0%E5%9D%80%EF%BC%9F.png)
我运行 Debian 10,有时当我启动计算机时,输出hostname -I
会包含三个条目:
$ hostname -I
192.168.0.13 192.168.0.2 fdaa:bbcc:ddee:0:d69a:20ff:fef8:dca8
有时它会少一个:
$ hostname -I
192.168.0.2 fdaa:bbcc:ddee:0:d69a:20ff:fef8:dca8
我不明白 192.168.0.13 是从哪里来的。这是我的 hosts 文件的内容:
$ cat /etc/hosts
127.0.0.1 localhost
127.0.1.1 desktop
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
编辑:
当仅显示 192.168.0.2 时,输出ip address
为
$ ip address
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: enp0s10: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether d4:9a:20:f8:dc:a8 brd ff:ff:ff:ff:ff:ff
inet 192.168.0.2/24 brd 192.168.0.255 scope global dynamic enp0s10
valid_lft 3361sec preferred_lft 3361sec
inet6 fdaa:bbcc:ddee:0:d69a:20ff:fef8:dca8/64 scope global dynamic mngtmpaddr
valid_lft 2006054647sec preferred_lft 2006054647sec
inet6 fe80::d69a:20ff:fef8:dca8/64 scope link
valid_lft forever preferred_lft forever
3: wlan0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000
link/ether 90:84:0d:f3:85:7e brd ff:ff:ff:ff:ff:ff
2021年6月16日编辑:
当 192.168.0.13 和 192.168.0.2 显示时,输出ip address
是
$ ip address
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: enp0s10: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether d4:9a:20:f8:dc:a8 brd ff:ff:ff:ff:ff:ff
inet 192.168.0.13/24 brd 192.168.0.255 scope global dynamic enp0s10
valid_lft 2290sec preferred_lft 2290sec
inet 192.168.0.2/24 brd 192.168.0.255 scope global secondary dynamic enp0s10
valid_lft 2666sec preferred_lft 2666sec
inet6 fdaa:bbcc:ddee:0:d69a:20ff:fef8:dca8/64 scope global dynamic mngtmpaddr
valid_lft 2006054625sec preferred_lft 2006054625sec
inet6 fe80::d69a:20ff:fef8:dca8/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 90:84:0d:f3:85:7e brd ff:ff:ff:ff:ff:ff