![自定义环回接口在不同机器上的可达性](https://linux22.com/image/155840/%E8%87%AA%E5%AE%9A%E4%B9%89%E7%8E%AF%E5%9B%9E%E6%8E%A5%E5%8F%A3%E5%9C%A8%E4%B8%8D%E5%90%8C%E6%9C%BA%E5%99%A8%E4%B8%8A%E7%9A%84%E5%8F%AF%E8%BE%BE%E6%80%A7.png)
我在一台具有特定 IP 地址的计算机上有一个环回接口,在另一台计算机上有一条到该环回接口子网的静态路由。
使用直连接口时,可以 ping 通另一个环回接口。但是,当我使用该-I
标志从另一个接口 ping 时,它不再起作用。
它似乎与路线的范围有关,link
而不是host
,但我不确定如何改变它。
这是具有环回接口的远程主机的配置:
user@remote:~$ ip address
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
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
inet 77.77.77.77/24 brd 77.77.77.255 scope global lo:10
valid_lft forever preferred_lft forever
inet 66.66.66.66/24 brd 66.66.66.255 scope global lo:11
valid_lft forever preferred_lft forever
inet 145.52.150.1/24 brd 145.52.150.255 scope global lo:12
valid_lft forever preferred_lft forever
inet 5.16.0.1/24 brd 5.16.0.255 scope global lo:13
valid_lft forever preferred_lft forever
inet 176.111.208.1/24 brd 176.111.208.255 scope global lo:14
valid_lft forever preferred_lft forever
inet 185.10.172.1/24 brd 185.10.172.255 scope global lo:15
valid_lft forever preferred_lft forever
inet 189.199.123.1/24 brd 189.199.123.255 scope global lo:16
valid_lft forever preferred_lft forever
inet 165.254.255.133/24 brd 165.254.255.255 scope global lo:17
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 08:00:27:e5:17:a0 brd ff:ff:ff:ff:ff:ff
inet 10.88.1.2/24 brd 10.88.1.255 scope global enp0s3
valid_lft forever preferred_lft forever
inet6 fe80::a00:27ff:fee5:17a0/64 scope link
valid_lft forever preferred_lft forever
user@remote:~$ ip route
default via 10.88.1.1 dev enp0s3
10.88.0.0/24 dev enp0s3 scope link
10.88.1.0/24 dev enp0s3 proto kernel scope link src 10.88.1.2
这是具有静态路由的本地计算机:
user@local:~$ ip address
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
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 08:00:27:1a:aa:71 brd ff:ff:ff:ff:ff:ff
inet 10.88.0.1/24 brd 10.88.0.255 scope global enp0s3
valid_lft forever preferred_lft forever
inet6 fe80::a00:27ff:fe1a:aa71/64 scope link
valid_lft forever preferred_lft forever
3: enp0s8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 08:00:27:81:d8:21 brd ff:ff:ff:ff:ff:ff
inet 10.88.1.1/24 brd 10.88.1.255 scope global enp0s8
valid_lft forever preferred_lft forever
inet6 fe80::a00:27ff:fe81:d821/64 scope link
valid_lft forever preferred_lft forever
user@local:~$ ip route
default via 192.168.1.1 dev enp0s9
5.16.0.0/24 dev enp0s8 scope link
8.8.8.0/24 dev enp0s8 scope link
10.88.0.0/24 dev enp0s3 proto kernel scope link src 10.88.0.1
10.88.1.0/24 dev enp0s8 proto kernel scope link src 10.88.1.1
66.66.66.0/24 dev enp0s8 scope link
77.77.77.0/24 via 10.88.1.2 dev enp0s8
145.52.150.0/24 dev enp0s8 scope link
169.254.0.0/16 dev enp0s3 scope link metric 1000
176.111.208.0/24 dev enp0s8 scope link
185.10.172.0/24 dev enp0s8 scope link
192.168.1.0/24 dev enp0s9 proto kernel scope link src 192.168.1.110
198.199.123.0/24 dev enp0s8 scope link
该命令挂起:
user@detector:~$ ping -I enp0s3 77.77.77.77
PING 77.77.77.77 (77.77.77.77) from 10.88.0.1 enp0s3: 56(84) bytes of data.
答案1
根据定义,环回接口只能从本地主机访问。您确定您有到远程环回接口的静态路由吗?或者您是否真的可以 ping 本地主机上的环回?