• 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.
  • Posts

    • Display Driver Uninstaller (DDU) 18.1.1.5 by Razvan Serea Display Driver Uninstaller (DDU) is a utility for completely removing AMD/NVIDIA/INTEL graphics drivers and related packages from your system, attempting to eliminate all leftovers (including registry entries, folders and files, driver store). Though AMD/NVIDIA/INTEL drivers can usually be removed via the Windows Control Panel, this uninstaller tool was created for situations where standard uninstall fails, or when you need to fully remove NVIDIA or ATI graphics card drivers. After using this driver cleaner, your system will behave as though it’s the first time you’re installing a new driver—similar to a fresh Windows installation. As with all such tools, we recommend creating a restore point beforehand, allowing you to undo changes if issues arise. If you're having trouble installing an older or newer driver, try it—there are reports that it resolves such problems. Recommended usage: The tool can be used in Normal mode but for absolute stability when using DDU, Safemode is always the best. Make a backup or a system restore (but it should normally be pretty safe). It is best to exclude the DDU folder completely from any security software to avoid issues. You do NOT need to uninstall the driver prior using DDU. Requirements: .NET Framework 4.8 Compatible with Windows 7, 8, 8.1, 10, and 11 (32-bit or 64-bit) Note: Using on Insider Preview builds is at your own risk. Display Driver Uninstaller (DDU) 18.1.1.5 changelog: Intel: Added NPU presence detection before removing shared DLL files (these were previously left to prevent potential NPU-related issues). Intel: Added optional NPU removal Improved "Extension" driver removal process. Updated several translations. Download: Display Driver Uninstaller 18.1.1.5 | 1.7 MB (Freeware) Download: DDU Portable | 1.2 MB Links: Display Driver Uninstaller Home Page | Screenshot | Forum Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • I just ordered a new MSI X870 board, hasn't even arrived yet. I checked the downloads page, and it has the firmware released on 6/11/2025 including the updated AGESA code.
    • There used to be an independent video game store in West Edmonton Mall around 20 years ago, I'm not sure when it went out of business, but they were selling console & PC games for $70±, I think it was so they could cover their rent!
    • That adverting your referring to can basically be turned off with a few Windows settings. The only advertising I've seen in the last couple of years on Windows 11 is Outlook ads because I don't have a Microsoft 365 subscription. That said, it took me only a couple days to get used to ignoring those ads. I would prefer they weren't there but it's not a big deal.
    • Petty nerd sums up many peoples dislike for things. i.e. Windows 11
  • Recent Achievements

    • Explorer
      Legend20 went up a rank
      Explorer
    • One Month Later
      jezzzy earned a badge
      One Month Later
    • First Post
      CSpera earned a badge
      First Post
    • One Month Later
      MIR JOHNNY BLAZE earned a badge
      One Month Later
    • Apprentice
      Wireless wookie went up a rank
      Apprentice
  • Popular Contributors

    1. 1
      +primortal
      634
    2. 2
      ATLien_0
      276
    3. 3
      +FloatingFatMan
      180
    4. 4
      Michael Scrip
      151
    5. 5
      Steven P.
      116
  • Tell a friend

    Love Neowin? Tell a friend!