所以我发出了一个ip a
列出所有 IP 地址的命令。但是我不明白它打印的所有其他 IP 地址和详细信息。在这个输出中,我只是明白这inet W.X.Y.Z/20 brd
是我的机器在 eth0 下的 IP 地址。lo
和下的 IP 地址和详细信息怎么样eth1
。从其中一篇博客中,我了解到 inetA.B.C.D/16 brd
是我的私人地址,但没有一个博客解释其他内容是什么。
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 fq_codel state UP group default qlen 1000
link/ether 52:10:9f:10:ad:10 brd ff:ff:ff:ff:ff:ff
inet W.X.Y.Z/20 brd W.X.79.255 scope global eth0
valid_lft forever preferred_lft forever
inet A.B.C.D/16 brd A.B.255.255 scope global eth0
valid_lft forever preferred_lft forever
inet6 2400:abab:100:ab::ab:5001/64 scope global
valid_lft forever preferred_lft forever
inet6 fe80::abab:9fff:abab:add2/64 scope link
valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 9a:ab:ab:40:13:a5 brd ff:ff:ff:ff:ff:ff
inet Q.W.E.R/20 brd Q.W.15.255 scope global eth1
valid_lft forever preferred_lft forever
inet6 f56g::abab:a5ff:abab:13c5/64 scope link
valid_lft forever preferred_lft forever
编辑:更新了实际结果ip a
root@ubuntu-s-1vcpu-1gb-blr1-01:~# 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 fq_codel state UP group default qlen 1000
link/ether 52:a0:9f:54:ad:d2 brd ff:ff:ff:ff:ff:ff
inet 139.59.75.106/20 brd 139.59.79.255 scope global eth0
valid_lft forever preferred_lft forever
inet 10.47.0.5/16 brd 10.47.255.255 scope global eth0
valid_lft forever preferred_lft forever
inet6 2400:6180:100:d0::db:5001/64 scope global
valid_lft forever preferred_lft forever
inet6 fe80::50a0:9fff:fe54:add2/64 scope link
valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 9a:4b:a5:40:13:c5 brd ff:ff:ff:ff:ff:ff
inet 10.122.0.2/20 brd 10.122.15.255 scope global eth1
valid_lft forever preferred_lft forever
inet6 fe80::984b:a5ff:fe40:13c5/64 scope link
valid_lft forever preferred_lft forever
答案1
你没有“单一IP”。计算机中的每个网络接口都可以有多个 IP。一台机器通常有一个或两个网络接口。你有三个。
lo
这是你的环回设备,它(除了例外)总是在那里。这是您的机器想要与自身对话时使用的接口(127.0.0.1)。
eth0
ð1
看来你还有两个接口。其中每一个都可以有多个 IP 地址。您所指的 IP (XXXX/XX) 是 IPv4 地址。其他地址(例如 2400:abab:100:ab::ab:5001/64)是 IPv6 地址。如果您想了解有关这些的更多信息,我建议您阅读有关这两方面的维基百科文章,它们非常广泛且写得很好。
我对你的IP的猜测(不知道实际的IP是什么):
127.0.0.1 IPv4 localhost (not a guess)
::1/128 IPv6 localhost (not a guess)
W.X.Y.Z/20 Maybe your actual public ip. Some ISPs do that (although it's dumb)
A.B.C.D/16 probably your local private IPv4. Probably a 10.0.X.X address
2400:abab: Your public IPv6 address. This is mostlikly a public routed IP
fe80:... Your private IPv6 (The IPv6 equvalent of A.B.C.D/16)
Q.W.E.R/20 no idea without knowing what the actual IP is
f56g::abab: Again probably a public routed IPv6