ip route get lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- bpranoto · 2020-04-29 08:06 My computer has several network interfaces. In order to check which interface makes a connection to the other computer, in Linux I can call the command ip route get address, like this: Code: [Select]$ ip route get 192.168.177.3 and the response is: Code: [Select]192.168.177.3 dev tap0 src 192.168.177.200 uid 1000     cache How can I get such information in my code without calling the shell comand? Does indy have such function? Thanks. ---------------------------------------------------------------------- MarkMLl · 2020-04-29 08:55 By implication You're running Linux: you really should be giving us more detailed information. I can't speak specifically for Indy, but you can find what you want in /proc/net/route noting (a) that it's "host-endian" and (b) that you'll need to ensure that your parsing is unsigned. MarkMLl ---------------------------------------------------------------------- avra · 2020-04-29 09:51 You can study source of some linux traceroute in C like this one: http://traceroute.sourceforge.net/ then extract relevant part and translate it to pascal. ...or try to adapt Indy examples mentioned here: https://stackoverflow.com/questions/21589004/how-to-get-ip-which-is- using-for-internet-connection-in-delphi https://stackoverflow.com/questions/4178398/how-i-can-trace-an-ip- using-delphi https://duckduckgo.com/?q="TIdTraceRoute"+indy ...or take a look at this Synapse trace route example: https://forum.lazarus.freepascal.org/index.php?topic=48594.0 ---------------------------------------------------------------------- bpranoto · 2020-05-02 16:15 Thanks for all the hints. After some experiments, with Indy, I can get what I look for simply with TIdIcmpClient.ping() . The interface which makes the  connection is in the ToIpAddress field of the ping's reply.  However, it requires root permission to do the  ping. ---------------------------------------------------------------------- Leledumbo · 2020-05-02 19:51 Quote from: bpranoto on May 02, 2020, 06:15:39 pmHowever, it requires root permission to do the  ping. Not really, it just needs setuid like what the ping binary has. Actual permission is to create a raw socket, which is a privileged action. ---------------------------------------------------------------------- MarkMLl · 2020-05-02 19:54 Quote from: Leledumbo on May 02, 2020, 09:51:44 pmQuote from: bpranoto on May 02, 2020, 06:15:39 pmHowever, it requires root permission to do the  ping. Not really, it just needs setuid like what the ping binary has. Actual permission is to create a raw socket, which is a privileged action. Or the appropriate POSIX capability set (and released as soon as the relevant operation is completed). And it's entirely likely that the target system doesn't respond to a ping... all of which should explain why I suggested looking at what's in the /proc tree. MarkMLl