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!