Networking Forums

Networking Forums > Computer Networking > Linux Networking > Making route output wider!

Reply
Thread Tools Display Modes

Making route output wider!

 
 
Cameron Kerr
Guest
Posts: n/a

 
      05-19-2004, 01:44 PM
Snoopy <(E-Mail Removed)> wrote:
> Ok, this is the dumbest question I've ever had to ask, but...
>
> I have an ADSL modem giving my Linux box a DHCP address, including (as
> always) an IP address and a gateway. I can view the IP address fine
> using ifconfig, but when trying to view the gateway using route, I get:
>
> Kernel IP routing table
> Destination Gateway Genmask Flags Metric Ref Use
> Iface
> ...
> ...
> ...
> default host-212-158-20 0.0.0.0 UG 0 0 0 eth0
>
> How the heck do I make the 'Gateway' field big enough to show me the
> complete value?!


You don't. Try using -n to give numeric output. If you really want to
get the complete host address, you could either look at /proc/net/route
yourself (suggest Perl), or rewrite the output of route -n, piping the
output through 'column -t' to reformat it as a table.

Here's something I just whipped up. I called it 'reroute' (reformatted,
that is).

#!/bin/sh
#
# Reformat and resolve route(8) output.
# Note that this won't use data from /etc/{hosts,networks}

( echo "Destination Gateway Netmask Flags Metric IFace"
/sbin/route -n | sed -e '1d' -e '2d' |
while read destn gwn mask flags metric ref use iface
do
#resolve dest
dest=`dig +short -x $destn`
if [ -z "$dest" ]; then
dest="$destn"
fi

#resolve gateway if it's not 0.0.0.0
if [ "$gwn" != "0.0.0.0" ]; then
gw=`dig +short -x $gwn`
#gw=${gw:-$gwn}
if [ -z "$gw" ]; then
gw="$gwn"
fi
else
gw="*"
fi

echo "$dest $gw $mask $flags $metric $iface"
done ) | column -t

--
Cameron Kerr
(E-Mail Removed) : http://nzgeeks.org/cameron/
Empowered by Perl!
 
Reply With Quote
 
 
 
 
Snoopy
Guest
Posts: n/a

 
      05-19-2004, 03:48 PM
Ok, this is the dumbest question I've ever had to ask, but...

I have an ADSL modem giving my Linux box a DHCP address, including (as
always) an IP address and a gateway. I can view the IP address fine
using ifconfig, but when trying to view the gateway using route, I get:

Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use
Iface
....
....
....
default host-212-158-20 0.0.0.0 UG 0 0 0 eth0

How the heck do I make the 'Gateway' field big enough to show me the
complete value?!

Any help appreciated,

A.

 
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Just Ahead: A Wider Wireless World Nomen Nescio Wireless Internet 1 12-20-2007 07:45 PM
VPN client adds wrong route to local route table snowdog_2112 Windows Networking 7 11-01-2005 02:05 PM
Making Route Delete Persistent Windows Networking 8 02-17-2005 02:23 PM
route and static route to a gateway Sting Linux Networking 2 02-21-2004 03:35 AM
RedHat 9.0 - Making 'route' changes permanent Chris Linux Networking 5 12-09-2003 01:45 PM



1 2 3 4 5 6 7 8 9 10 11