I'm a newbie in network programming in C/C++ and I'm working on raw sockets to program a simple ping or traceroute application as they are written in common network programming books.

Programs like traceroute, manipulate packet headers like TTL so that they can retrieve router IP addresses.

I know that routers are designed to find best routes by finding nearest routers in a simple manner.
I was wondering if it's possible to find a way to manipulate packet headers in a way that packets force a router to choose a specific route instead of their default route, I mean to manipulate packets the way traceroute does and create a manual route to destination.

In first step, is it even possible? if not and there's any similar way to achieve this goal, what is it?


In practice, clients can't affect the router's forwarding decision. Initially, source routing (in RFC 791) was designed to implement this but it's grown out of use and has very little support today.

Strictly speaking, there is no way to accomplish what you're asking. With some more details to the exact intention there might be ways to get what you want (router discovery? network scan? vulnerability scan?).

| improve this answer | |
  • imagine a route containing 10 routers in the middle, the 5th router is blocking specific connection, like any TCP/UDP connection over HTTP(S) ports, while each router has access to more than one router in front of them, I though there might be a way to bypass the 5th route, like forcing 4th router to choose another router in its next step than the 5th. – Brian SP2 Jun 15 '18 at 20:40
  • 1
    That's pretty much what source routing was about - it's obsolete. – Zac67 Jun 15 '18 at 21:17

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