기본이 아닌 경로 테이블을 통해 ping 테스트를 수행하는 방법은 무엇입니까?

기본이 아닌 경로 테이블을 통해 ping 테스트를 수행하는 방법은 무엇입니까?

내 홈 네트워크의 라우터 역할을 하는 Linux 상자가 있습니다. 3개의 라우팅 테이블이 있습니다.

# ip route show default
default via 192.168.5.1 dev wlp2s0
172.18.231.140/30 dev wwx0c5b8f279a64  proto kernel  scope link  src 172.18.231.141
192.168.0.0/24 dev enp1s0  proto kernel  scope link  src 192.168.0.110
192.168.1.0/24 dev enp3s0  proto kernel  scope link  src 192.168.1.10
192.168.5.0/24 dev wlp2s0  proto kernel  scope link  src 192.168.5.100

#ip route show table ISP1
default via 192.168.0.1 dev enp1s0
192.168.0.0/24 dev enp1s0  proto kernel  scope link  src 192.168.0.110
192.168.1.0/24 dev enp3s0  proto kernel  scope link  src 192.168.1.10

# ip route show table ISP2
default via 172.18.231.142 dev wwx0c5b8f279a64
172.18.231.140/30 dev wwx0c5b8f279a64  proto kernel  scope link  src 172.18.231.141
192.168.0.0/24 dev enp1s0  proto kernel  scope link  src 192.168.0.110
192.168.1.0/24 dev enp3s0  proto kernel  scope link  src 192.168.1.10

일반적으로 발생하는 일은 네트워크에 연결하는 모든 클라이언트가 기본 게이트웨이를 통과한다는 것입니다. 원하는 경우 IP와 일치하는 IP 규칙을 추가하고 클라이언트가 ISP1 테이블 또는 ISP2 테이블을 사용하도록 변경합니다.

이제 ISP2 테이블에 연결된 모바일 네트워크 "wwx0c5b8f279a64"가 연결되어 있는지 또는 연결이 끊어졌는지 확인하고 싶지만 Linux 상자에서는 확인이 기본 경로, 즉 "wlp2s0"을 통과하기 때문에 ping확인할 수 없습니다. 상호 작용.pingping

이 문제를 해결할 방법이 있나요? Linux 상자의 로컬 트래픽을 ISP2 테이블로 라우팅할 수 있다면 작동할 것이라고 생각했지만 상자의 로컬 트래픽을 ISP2 테이블로 라우팅하는 방법을 모르겠습니다.

답변1

아마도 nping(보통 의 일부 nmap)가 여기서 도움이 될 수 있을까요? 맨페이지에서:

--dest-mac mac (Ethernet Destination MAC Address) This option sets the destination MAC address that should be set in outgoing Ethernet frames. This is useful in case Nping can't determine the next hop's MAC address or when you want to route probes through a router other than the configured default gateway. The MAC address should have the usual format of six colon-separated bytes, e.g. 0:50:56:d4:01:98. Alternatively, hyphens may be used instead of colons. Use the word random or rand to generate a random address, and broadcast or bcast to use ff:ff:ff:ff:ff:ff. If you set up a bogus destination MAC address your probes may not reach the intended targets.

답변2

가장 확실한 방법은 ping하려는 주소 또는 주소 범위 테이블을 활성화하는 규칙을 임시로 추가하는 것입니다.

ip rule add to 8.8.8.8 table ISP2
ping 8.8.8.8
ip rule del to 8.8.8.8 table ISP2

이 규칙이 활성화되어 있는 한 8.8.8.8에 대한 모든 트래픽은 이 인터페이스를 통과하므로 실제로 어딘가에서 8.8.8.8을 네임서버로 사용하고 있다면 그동안 작동하지 않을 수 있습니다.

관련 정보