• 0

[C/C#/C++] Force Windows XP to ping via specific interface?


Question

I don't care about the programming language, but C# or C/C++ would be preferable. Sadly, the platform must be Windows XP.

The goal is to ping out of a specific network interface on a multihomed machine, bypassing the routing table in the process.

In Linux/UNIX, this is trivial: simply ping out the interface with the existing ping utility. Windows XP does not provide this functionality.

I attempted to implement the UNIX behavior of ping using raw sockets to send custom made ICMP packets. I set the DontRoute socket option, bound the socket to a local endpoint, and sent the ICMP packet to the remote end point. In my tests, the source and destination addresses are correct, but the wrong interface is used to transmit the packet.

I've tried other avenues such as Cygwin. I could do it with a virtual machine running Linux. I also read somewhere that this is impossible in Windows XP, but possible on Vista/7. I'd be willing to consider manipulating the routing tables and/or interface metrics, if someone can prove that it works.

Words alone cannot express how deeply I hate Windows, so you can imagine how appreciative I'll be for any help.

4 answers to this question

Recommended Posts

  • 0

I imagine you've already found this. It was a top link in google: http://www.experts-exchange.com/Networking...Q_24035725.html

I can't prove it works, but it seems simple enough to try. Or as someone else says in the comments, if the interfaces are on different IPs you can use the -S switch to specify a source address.

Also somehere here managed to remove a default route to make it use a specific interface so the above should work :)

  • 0

Thanks for the reply. Sadly there is no -S option to specify the source address in XP.

I did see the post about changing the routing tables, unfortunately I'll be dealing with multiple routes so that could get hairy. Looks like I'll be going to the virtual machine route. Thanks again for the help.

  • 0

I may be misunderstanding this, but could you not use the switch, -k hostlist?

-k
HostList
: Specifies that the Echo Request messages use the Strict Source Route option in the IP header with the set of intermediate destinations specified in HostList. With strict source routing, the next intermediate destination must be directly reachable (it must be a neighbor on an interface of the router). The maximum number of addresses or names in the host list is 9. The host list is a series of IP addresses (in dotted decimal notation) separated by spaces.

Source

Am I reading that correctly? If you know the source path, you should be able to set the hops?

Or you could use -j hostlist, if you don't know all the hops:

-j
HostList
: Specifies that the Echo Request messages use the Loose Source Route option in the IP header with the set of intermediate destinations specified in HostList. With loose source routing, successive intermediate destinations can be separated by one or multiple routers. The maximum number of addresses or names in the host list is 9. The host list is a series of IP addresses (in dotted decimal notation) separated by spaces.

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.