From c2f41ae5b92f79091d1ba6be1cdfcd773110d1bf Mon Sep 17 00:00:00 2001 From: Tim Young Date: Sat, 13 Apr 2019 10:18:02 -0500 Subject: [PATCH] tracert: respond from requested IP address If a device does a traceroute to the opposite side of a router, the traceroute request will continue on to the next gateway until it dies from not being able to return on the same NIC. Instead, respond to traceroute requests from the "pinged" ip address (so that the originator stops requesting more tracert packets) instead of the closest address to the originator. Scenario: Level 3 It is dead, Jim 1.) from PC1, traceroute to the far side of router2 (192.168.3.2). Notice that the tracert continues on two times to router0 before dying. --- EduNetworkBuilder/NetworkDevice.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/EduNetworkBuilder/NetworkDevice.cs b/EduNetworkBuilder/NetworkDevice.cs index c8852c3..fe30f6d 100644 --- a/EduNetworkBuilder/NetworkDevice.cs +++ b/EduNetworkBuilder/NetworkDevice.cs @@ -3290,7 +3290,12 @@ namespace EduNetworkBuilder //Console.WriteLine(" Tracert bounce: " + tPacket.OrigTTL + " " + hostname + " " + tPacket.payloadData); //Finish setting up the new packet - sending it back - nPacket.sourceIP = new NB_IPAddress(NB.ZeroIPString); + // respond from requested address, not outgoing address: important for routers. + if (HasIPAddress(tPacket.destIP)) + nPacket.sourceIP = tPacket.destIP; + else + nPacket.sourceIP = new NB_IPAddress(NB.ZeroIPString); + nPacket.TsourceIP = new NB_IPAddress(NB.ZeroIPString); myNet.addPacket(nPacket); //Console.WriteLine(" Tracert bounce pkt:" + nPacket.OrigTTL + nPacket.payloadData);