Linux 有 2 个接口,ping 辅助接口失败

Linux 有 2 个接口,ping 辅助接口失败

我有一台 ubuntu 20.04 服务器,有 2 个接口 / eth0:94.101.177.244 eth1:94.101.176.149

Eth0 运行良好,当我从服务器 ping 出 eth1 时,它成功了。

但是当我从 PC eth1 ping 时,失败了。

~$ ip route show
default via 94.101.176.1 dev eth0 proto dhcp src 94.101.177.244 metric 100
default via 94.101.176.1 dev eth1 proto dhcp src 94.101.176.149 metric 100
94.101.176.0/22 dev eth0 proto kernel scope link src 94.101.177.244
94.101.176.0/22 dev eth1 proto kernel scope link src 94.101.176.149
169.254.169.254 via 94.101.176.10 dev eth0 proto dhcp src 94.101.177.244 metric 100
169.254.169.254 via 94.101.176.10 dev eth1 proto dhcp src 94.101.176.149 metric 100


~$ cat /etc/iproute2/rt_tables
#
# reserved values
#
255     local
254     main
253     default
0       unspec
#1      inr.ruhep


~$ ip rule show
0:      from all lookup local
32766:  from all lookup main
32767:  from all lookup default

#from pc
ping 94.101.177.149

Pinging 94.101.177.149 with 32 bytes of data:
Request timed out.
Request timed out.
Request timed out.
Request timed out.

Ping statistics for 94.101.177.149:
    Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),
#from server
~$ ping google.com -I eth1
PING google.com (216.239.38.120) from 94.101.176.149 eth1: 56(84) bytes of data.
64 bytes from any-in-2678.1e100.net (216.239.38.120): icmp_seq=1 ttl=107 time=27.8 ms
64 bytes from any-in-2678.1e100.net (216.239.38.120): icmp_seq=2 ttl=107 time=26.0 ms
64 bytes from any-in-2678.1e100.net (216.239.38.120): icmp_seq=3 ttl=107 time=25.5 ms
64 bytes from any-in-2678.1e100.net (216.239.38.120): icmp_seq=4 ttl=107 time=25.6 ms
^C
--- google.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3004ms
rtt min/avg/max/mdev = 25.480/26.217/27.783/0.924 ms

我知道这里的问题是为每个接口创建路由表,但我不知道该怎么做......

答案1

这里的问题是您有 2 个默认网关,因此您必须创建 2 个路由表。

请参阅以下链接:

https://www.thomas-krenn.com/en/wiki/Two_Default_Gateways_on_One_System

请告知我是否已将您引向正确的轨道。

问候 Stagira

相关内容