Link to home
Start Free TrialLog in
Avatar of cheechew
cheechew

asked on

fping with source interface

Does anyone know how to use fping with different source interface (different source ip)?
Avatar of ahoffmann
ahoffmann
Flag of Germany image

AFAIK not possible
Avatar of The--Captain
Sure it is - why not

route add -host <host-to-fping> dev <desired-source-interface>

or

route add -host <host-to-fping> gw <gateway-for-desired-interface>

?

As long as <desired-source-interface> is connected to a network that can reach <host-to-fping> (1st example), or each different interface is on a different subnet and each subnet has a <gateway-for-desired-interface> that will route packets to <host-to-fping> (2nd example), I would think that the routing subsystem would take care of this for you...

I know the 2nd example works - haven't yet tried the 1st example...

-Jon

Avatar of cheechew
cheechew

ASKER

I don't need to add route, all IP are on the same subnet with single physical interface. I am using fping to do ping.
Sigh - why are you so willing to dismiss my ideas without trying them?  I have verified that my 1st example will work, with the addition of one more argument.

You need to use

route add -host <host-to-fping> gw <my-default-gateway> dev <interface-with-desired-IP>

One you add this route, all fpings to <host-to-fping> will go out with s source of <interface-with-desired-IP>.

I've tried it - it works (source IP verified with tcpdump).

No go try it, and don't tell me it won't work, because I just confimed it does.

-Jon

P.S.  Why bother asking for help, if you are so sure of what will work and what will not?

ASKER CERTIFIED SOLUTION
Avatar of The--Captain
The--Captain
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Yes, it is a brilliant solution. Even fping do not have the capibility, but we can play around the route on the OS itself. I have tried on specifying both source gw interface and ip, but have not try on only specifying either of them.
I am not sure if I would call it a "brilliant" solution, but I am confident as to its feasibility.  Let me know how it goes (and yes, you are correct, if I properly perceive the eventual conclusion to your statements) - this trick can indeed be used on any network tool in a similar situation (in which the user needs to specify the src addr, but the tool does not support configuration of the src addr via a direct argument).  As long as the network tool in question does not circumvent the routing subsystem function calls, the tool should correctly choose the proper outbound address on which to bind, given the according associations within the routing table.

Cheers,
-Jon

Thanks!

-Jon