Perform traceroute with specific outgoing IP
21,520
I imagine your subnets are assigned to (virtual) interfaces and that you want the trace to go through one of these.
The traceroute
has an option for this. Check out the man page - you just do this to force the trace to proceed through a specific interface:
traceroute -i <interface> <host>
If this doesn't work, out can add a specific route to the host you want to trace via the gateway you want. Do:
route add -host <host> gw <gw>
Then do the traceroute - and don't forget to delete the route (if you don't need it anymore):
route del -host <host> gw <gw>
Hope it helps.
Related videos on Youtube
Author by
maddo7
Updated on September 18, 2022Comments
-
maddo7 almost 2 years
My server has multiple /24 subnets added via network-script files
ifcfg-eth0-range0
Now one /24 subnet has connection issues and I need to perform a traceroute to see what's wrong.
How can I have my server using one of those IPs as outgoing IP address when doing a traceroute?
-
maddo7 over 8 years
traceroute -i eth0:749 google.com
givessetsockopt SO_BINDTODEVICE: No such device
but I can see this interface from/sbin/ifconfig
, any idea what's wrong? -
MrMajestyk over 8 yearsHave to admit I have used this on Cisco and it may be that Linux aliased interfaces do not support binding or something. See my coming edit for another suggestion.
-
maddo7 over 8 yearsWhen I do
route add -host google.com gw x.x.x.2
traceroute times out and wget saysfailed: No route to host.
-
MrMajestyk over 8 yearsWell that would then suggest that there is no (configured) way to reach google.com via x.x.x.2 - but: how about adding some details to your question: What does the interface list on the server look like? How are the clients on the non-working subnet configured? What is their default GW for instance? What does traceroute <some host> look like from the server? From the client?
-
maddo7 over 8 yearsActually the question here is related to serverfault.com/questions/741246/… the hosting company told me to do a traceroute both sides to see where the problem was. Meanwhile they looked at it and confirmed the problem has to be server related. The strange thing is the subnet stopped working overnight without any server changes being made during that time. So now I'm struggling to find out why the IPs aren't working and only get a timeout.