[TriLUG] [OT] Time Warner Cable - new modem problems

Daniel Sterling sterling.daniel at gmail.com
Thu Jun 7 23:38:37 EDT 2012


On Thu, Jun 7, 2012 at 11:07 PM, William Chandler <wcchandler at gmail.com> wrote:
> HOP=`traceroute 8.8.8.8 -N 1 -n -m 1 2>&1 | sed 1d | cut -d ' ' -f 4`

Hmm, traceroute can be rather finicky; I'd go with grabbing the route
directly from the networking stack. Assuming eth0 is your WAN
interface:

You can use ip(8):

$ /sbin/ip route show dev eth0 | grep default | perl -p -e 's/default
via (\S+).*$/$1/'

Or even grab the route directly from /proc/net/route:

$ cat /proc/net/route | grep -P '^eth0\s+00000000' | perl -p -e
'/^(?:\S+\s+){2}(\S+)/;$_=join(".", reverse unpack "C*", pack "H*",
$1)."\n"'

-- Dan



More information about the TriLUG mailing list