can I pick anyone's brains?

Christopher Barry christopher.barry at
Wed Jan 26 16:24:35 UTC 2011

On Wed, 2011-01-26 at 17:15 +0100, Harald Becker wrote:
> Hallo David!
> Here we are again ... :-)
> > If I have an IP address... or something, is there a simple
> > command I can issue from a script which will examine all the routing
> > tables for me and return
> >
> > "eth0"  "local"
> > or 
> > "eth1"  "gateway"
> > or
> > "tun0"  "gateway" 
> >
> > or something similar?
> Can you please tell a bit more, what you want to achieve? The routing is
> normally done by the kernel, so not required to be done in user space
> programs or shell scripts.
> There is one command, that allows to dump the routing table, that is the
> command "route". With an awk script it would be possible to filter the
> table output and select an appropriate routing entry. That way an awk
> script could be used to build a command with your requirements ... else
> I don't know any standard command for your purpose.
> --
> Harald

I like 'ip r'. parse it however you like.

outputs like below:
# ip r dev wlan0  proto kernel  scope link  src
metric 2 dev vmnet8  proto kernel  scope link  src dev eth1  proto kernel  scope link  src dev eth0  proto kernel  scope link  src dev virbr0  proto kernel  scope link  src dev wlan0  scope link  metric 1000 
default via dev wlan0  proto static

More information about the busybox mailing list