David Coulson on 7 Jan 2013 10:04:25 -0800

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] Raising the dead: proc filesystem

Here is a really simple way:

# ip ro get via dev bond0  src 
    cache  mtu 1500 advmss 1460 hoplimit 64

Assuming is not directly attached or has a more specific route, the IP following 'src' will be the IP address of the interface through which you route to your default gw. awk/sed/cut your way to only the IP.

On Jan 7, 2013, at 12:56 PM, Sam Gleske wrote:

Reference to an original thread "proc filesystem":

Has anyone found a decent way to do this outside of parsing ifconfig output?  I've done it in a one liner here...

Yet I've found that most times I'm able to reliably turn to the /proc filesystem for stuff like this.  I'm just curious if anyone has found a decent way to do this since that thread was originally posted.

I wonder if parsing a combination of /proc/net/fib_trie and /proc/net/route would be useful in finding the IP address of the default route (which I would assume be the internet connected IP address).  I found fib_trie by grep -irl my IP address through /proc.  Here's some kernel documentation on fib_trie but there's nothing useful about using it for obtaining the IP address of the default route.


I look forward to discussing this.

Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug

Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug