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

My Nagios server is set up accordingly:

auto eth0
iface eth0 inet static

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

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

ping -c4 # Is Modem1 up? 
ip route add via
ip route change default via
ping -c4 # Is Modem2 up?
wget # yields expected control webpage for Modem2
ip route change default via
ip route del default via
wget # Connection refused; Modem1 has no web interface
ssh adminuser@ # 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.

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

Neither ping -N nor arping worked for me, I finally settled with the solution from this answer:

You can use the tool nping from the nmap package:

# nping --icmp --dest-mac [gateway mac] [target ip]

You can find your router's mac in your local ARP cache:

$ arp -v [gateway ip]

The tool also supports different ping types, like --tcp or --udp.

  • Thanks for this. Your suggestion of using nping is the only method I have found (other than adding in a specific route and using the normal ping binary) of sending ICMP echo-requests (pings) towards a dial-on-demand 3G backup router (for testing purposes, to make sure it connects and has real internet connectivity once connected), achieved by targeting the MAC address of the router when sending the ICMP packets, which nping allows you to do. Very useful little utility!
    – parkamark
    Apr 16 '16 at 13:09

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 that ping should take.

So in your case:

  • "ping modem" to explicitly use the first gateway,
  • "ping modem" to explicitly use the second gateway.

If you encounter the same problem with Windows: ping /? -k is the option you probably want.

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

  • 1
    That's not getting me there. ping -c4 yields 100% packet loss. I've clarified the situation above. Jul 18 '11 at 22:31
  • 4
    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. Jul 30 '11 at 18:42
  • 1
    I just want to be alerted. If they both go down we're cut off from the outside world except by radio and an unreliable backup sat-phone. (Failover would be dangerous since we could easily blow through the 200MB fair access policy before anyone noticed.) Aug 2 '11 at 20:30

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 as having a subnet of; or even have a bigger subnet e.g. as being

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

  • 1
    I meant as a shorthand for on the 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 Jul 18 '11 at 22:43

Use arping:

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


  • 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]
  • 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. Jul 19 '11 at 22:50
  • 1
    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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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