Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Our network has two modems, each one hidden behind a router. The primary router is on 10.1.1.1, the backup router is on 10.1.1.2, and are both configured to the 10.1.1.0/24 subnet. Both routers have their gateway configured to 192.168.0.1. However, the 192.168.0.1 that you see if your gateway is 10.1.1.1 is a different machine from the 192.168.0.1 that you see if your gateway is 10.1.1.2.

My Nagios server is set up accordingly:

auto eth0
iface eth0 inet static
address 10.1.1.10
netmask 255.255.255.0
gateway 10.1.1.1

So to be clear: there are four gateways here. Router1 (10.1.1.1) Router2 (10.1.1.2) Modem1 (192.168.0.1) Modem2 (192.168.0.1)

Here's an illustration of what I can do manually to check the status of the two modems:

ping -c4 192.168.0.1 # Is Modem1 up? 
ip route add via 10.1.1.2
ip route change default via 10.1.1.2
ping -c4 192.168.0.1 # Is Modem2 up?
wget 192.168.0.1 # yields expected control webpage for Modem2
ip route change default via 10.1.1.1
ip route del default via 10.1.1.2
wget 192.168.0.1 # Connection refused; Modem1 has no web interface
ssh adminuser@192.168.0.1 # I can log in to Modem1 and check status

I would like at a minimum to be able to ping Modem2.

*Edited to correct my abominable misuse of CIDR notation, and provide clear detail. (I don't think this belongs on superuser.)

share|improve this question

migrated from serverfault.com Jul 18 '11 at 9:35

This question came from our site for professional system and network administrators.

    
What is the IP configuration from which you are initiating the ping from? –  user48838 Jul 17 '11 at 18:33
add comment

3 Answers 3

man ping

ping [hop... ] destination

So you can give ping a number of IPs separated by white-space as parameter. The last address will be "pinged" the previous parameters define the route the ping should take.

So in your case:

  • "ping 10.1.1.2 modem" to explicitely use the first gateway,
  • "ping 10.1.1.1 modem" to explictely use the second gateway.

If you should encounter the same problem with windows: ping /? -k is the option you propably want.

BTW: The above ping does not require any root-priviledges. The routing-information (in your case: the "whishlist") is part of the ICMP protocol.

share|improve this answer
    
That's not getting me there. ping -c4 10.1.1.2 192.168.0.1 yields 100% packet loss. I've clarified the situation above. –  Luke Schlather Jul 18 '11 at 22:31
1  
This actually doesn't work at all, even with root. I tested this with while watching tcpdump, and it does not do what you think it does. –  bahamat Jul 18 '11 at 23:54
    
What happens if you remove the default-gateway completely? I still don`t understand your setup. Why do you use the identical "router" address on both modems? –  Nils Jul 21 '11 at 19:42
    
Both of the modems are controlled by my different ISPs. –  Luke Schlather Jul 30 '11 at 18:42
    
Ok - I now understand the same IP of the routers. Is this an on-demand-connection and you want to failover? –  Nils Aug 2 '11 at 19:19
show 1 more comment

Sorry, you can only have one default gateway. You can have multiple gateways, but only one for every network.

The problem is, that both mentioned IPs are in the same network. Also you specified your CIDRs wrongly: You meant 10.1.1.0/24 as having a subnet of 255.255.255.0; or even have a bigger subnet e.g. 10.0.0.0/8 as being 255.0.0.0.

You can therefore ping any host inside your network (10.0.0.0/8) or any host reachable via a (or the) gateway. But having two gateways for the same network is not possible.

share|improve this answer
    
I meant 10.1.1.1/24 as a shorthand for 10.1.1.1 on the 10.1.1.0/24 subnet. Sorry, I won't use that shorthand again, it's clearly wrong. I still have a monitoring problem - I've added more detail above. I cannot solve this problem without putting a better router in place at 10.1.1.2? –  Luke Schlather Jul 18 '11 at 22:43
add comment

Use arping:

# arping -c 1 -S [source_ip] -T [target_remote_ip] [gateway_mac_address]

Where:

  • source_ip is an IP that's locally assigned on your host
  • target_remote_ip is the IP address you want to ping
  • gateway_mac_address is the layer 2 ether address of the alternate gateway you want to use

Alternatively if you're using some form of Solaris you can use:

ping -N [gateway_ip] [target_remote_ip]
share|improve this answer
    
That looks promising, though I guess iproute2's arping isn't going to cut it... maybe I just need to replace the router with something I can ssh into. –  Luke Schlather Jul 19 '11 at 22:50
    
iproute2's arping is different. If you're using arping from iproute2 to do gratuitous arps, I would suggest using send_arp from fake instead. Also, the gateway must be something that will forward IP packets. –  bahamat Jul 19 '11 at 22:55
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.