2 # quick look at current connections and related information
3 # Copyright (C) 1998, 1999 Henry Spencer.
5 # This program is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by the
7 # Free Software Foundation; either version 2 of the License, or (at your
8 # option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 # This program is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 # RCSID $Id: look,v 1.26 2001/06/01 16:44:11 henry Exp $
17 info=/var/run/ipsec.info
21 --help) echo "Usage: ipsec look" ; exit 0 ;;
22 --version) echo "$me $IPSEC_VERSION" ; exit 0 ;;
25 # clear out variables that have strange effects on sort etc.
26 unset LANG LANGUAGE LC_ALL LC_MESSAGES
28 # Pick up IPsec configuration etc.
29 eval `ipsec _confread --varprefix IPSEC --type config setup`
30 if test " $IPSEC_confreadstatus" != " "
32 echo "$IPSEC_confreadstatus -- aborting" |
33 logger -s -p daemon.error -t ipsec_look
41 # label it just to be sure
42 echo "`hostname` `date`"
44 # combine spigrp and eroute
45 cat /proc/net/ipsec_spigrp /proc/net/ipsec_eroute |
47 function pad(subnet) {
50 return sprintf("%03s%03s%03s%03s%03s", d[1], d[2],
54 printf "%s:%-18s -> %-18s => %s\n",
56 $1, $3, (($5 in tun) ? tun[$5] : $5)
60 printf "%s:%-18s -> %-18s => %s (%s)\n",
62 $2, $4, (($6 in tun) ? tun[$6] : $6), $1
66 ' | sort | sed 's/^[^:]*://'
68 # tncfg (mostly as a divider line)
69 egrep -v 'NULL[ \t]+mtu=0\(0\)[ \t]+->[ \t]+0' /proc/net/ipsec_tncfg |
70 paste -d % | sed 's/%/ /g' | sed 's/ -> /->/g'
73 sort /proc/net/ipsec_spi
75 # relevant routing information, including header line (which is good
76 # enough as a separator, no need for another bar)
78 if test " $defaultroutephys" != " "
80 pat="$pat|$defaultroutephys\$|$defaultroutevirt\$"
82 for i in `echo "$IPSECinterfaces" | tr '=' ' '`
87 netstat -nr | egrep "$pat" | sed '/^Dest/s/^/ /' | sort | sed '/^ Dest/s/ //'