Is there a way to ping, using different gateways, not by binding to different interfaces, but as if you would change the default route, but without changing it?

For example, I have 2 different gateway servers, that can see the other side of the network. Now, I have to do something like this:

route del default
route add default gw gateway1
ping -c 4 address_from_the_net_behind_the_router
route del default
route add default gw gateway2
ping -c 4 address_from_the_net_behind_the_router

This way I determine, if one of the routers has a broken link to the other network, but it disrupts the network flow, which can brake brake a connection, if some file is being copied from the network, behind the gateway, so, I was looking for a non-disruptive way to check it.

I know, that the latest Net::Ping module has a gateway option in the initialization method (new), but I've read it's documentation. It says, that this option is only supported by an IPv6, but I need it for IPv4.

Is there some other module, that allows me to perform such action?


In reply to ping an IPv4 address, using different gateways by igoryonya

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.