routel -- makes "ip route" listings readable

Stephen R. van den Berg (
Sun, 18 Apr 1999 16:19:29 +0200

Content-Type: text/plain; charset=us-ascii

Perhaps I'm just dense and a tool like this already exists; but just
in case it doesn't, or anyone else finds this useful, here's a small
contribution to the iproute package (see attachment).

           Stephen R. van den Berg (AKA BuGless).

Climate is what you expect. Weather is what you get.

--VS++wcV0S1rZb1Fb Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=routel

#!/bin/sh #$Id$

# # Script created by: Stephen R. van den Berg <>, 1999/04/18 # Donated to the public domain. # # This script transforms the output of "ip" into more readable text. # "ip" is the Linux-advanced-routing configuration tool part of the # iproute package. #

test "X-h" = "X$1" && echo "Usage: $0 [tablenr [raw ip args...]]" && exit 64

test -z "$*" && set 0

ip route list table "$@" | while read network rest do set xx $rest shift proto="" via="" dev="" scope="" src="" table="" case $network in broadcast|local|unreachable) via=$network network=$1 shift ;; esac while test $# != 0 do key=$1 val=$2 eval "$key=$val" shift 2 done echo "$network $via $src $proto $scope $dev $table" done | awk -F ' ' ' BEGIN { format="%15s%-3s %15s %15s %8s %8s%7s %s\n"; printf(format,"target","","gateway","source","proto","scope","dev","tbl"); } { network=$1; mask=""; if(match(network,"/")) { mask=" "substr(network,RSTART+1); network=substr(network,0,RSTART); } via=$2; src=$3; proto=$4; scope=$5; dev=$6; table=$7; printf(format,network,mask,via,src,proto,scope,dev,table); } '

--VS++wcV0S1rZb1Fb-- - To unsubscribe from this list: send the line "unsubscribe linux-net" in the body of a message to