diff --git a/Shorewall-lite/shorewall-lite b/Shorewall-lite/shorewall-lite index d9aeb483e..f65aae6d8 100755 --- a/Shorewall-lite/shorewall-lite +++ b/Shorewall-lite/shorewall-lite @@ -376,7 +376,7 @@ usage() # $1 = exit status echo " show connections" echo " show filters" echo " show ip" - echo " show [ -m ] log []" + echo " show [ -m ] log []" echo " show [ -x ] mangle|nat|raw|routing" echo " show policies" echo " show tc [ device ]" diff --git a/Shorewall/releasenotes.txt b/Shorewall/releasenotes.txt index 79f157325..1f1b306c6 100644 --- a/Shorewall/releasenotes.txt +++ b/Shorewall/releasenotes.txt @@ -336,10 +336,10 @@ None. duplicate chains. So to set all possible optimizations, specify OPTIMIZE=15. -5) /sbin/shorewall and /sbin/shorewall-lite now support 'show log - ' where is an IP address. The command searches the - current LOGFILE for Netfilter messages containing the supplied - address. +5) The command-line tools now support 'show log ' where + is a regular expression to search for in the LOGFILE. The command + searches the current LOGFILE for Netfilter messages matching the + supplied regex. ---------------------------------------------------------------------------- V I. P R O B L E M S C O R R E C T E D A N D N E W F E A T U R E S diff --git a/Shorewall/shorewall b/Shorewall/shorewall index fb03f2295..c6d8b8229 100755 --- a/Shorewall/shorewall +++ b/Shorewall/shorewall @@ -1360,7 +1360,7 @@ usage() # $1 = exit status echo " show dynamic " echo " show filters" echo " show ip" - echo " show [ -m ] log []" + echo " show [ -m ] log []" echo " show macro " echo " show macros" echo " show [ -x ] mangle|nat|raw|routing" diff --git a/Shorewall6-lite/shorewall6-lite b/Shorewall6-lite/shorewall6-lite index 6c0737275..89a1d5811 100755 --- a/Shorewall6-lite/shorewall6-lite +++ b/Shorewall6-lite/shorewall6-lite @@ -364,7 +364,7 @@ usage() # $1 = exit status echo " restart [ -n ] [ -f ]" echo " restore [ -n ] [ ]" echo " save [ ]" - echo " show [ -x ] [ -m ] [-f] [ -t {filter|mangle} ] [ {chain [ [ ... ]capabilities|classifiers|config|connections|filters|ip|log|macros|mangle|nat|policies|raw|routing|tc|vardir|zones} ]" + echo " show [ -x ] [ -m ] [-f] [ -t {filter|mangle} ] [ {chain [ [ ... ]capabilities|classifiers|config|connections|filters|ip|log []|macros|mangle|nat|policies|raw|routing|tc|vardir|zones} ]" echo " start [ -f ] [ ]" echo " stop [ -f ]" echo " status" diff --git a/Shorewall6/lib.cli b/Shorewall6/lib.cli index 1ccd4a340..55d9d818b 100644 --- a/Shorewall6/lib.cli +++ b/Shorewall6/lib.cli @@ -140,6 +140,15 @@ packet_log() # $1 = number of messages fi } +search_log() # $1 = IP address to search for +{ + if [ -n "$g_showmacs" -o $VERBOSITY -gt 2 ]; then + $g_logread | grep 'IN=.* OUT=.*SRC=.*\..*DST=' | grep "$1" | tac | sed 's/ kernel://; s/\[.*\] //' | sed s/" $host $LOGFORMAT"/" "/ + else + $g_logread | grep 'IN=.* OUT=.*SRC=.*\..*DST=' | grep "$1" | tac | sed 's/ kernel://; s/MAC=.* SRC=/SRC=/; s/\[.*\] '// | sed s/" $host $LOGFORMAT"/" "/ + fi +} + # # Show traffic control information # @@ -447,12 +456,17 @@ show_command() { $IP6TABLES -t raw -L $g_ipt_options ;; log) - [ $# -gt 1 ] && usage 1 + [ $# -gt 2 ] && usage 1 echo "$g_product $SHOREWALL_VERSION Log ($LOGFILE) at $g_hostname - $(date)" echo show_reset host=$(echo $g_hostname | sed 's/\..*$//') - packet_log 20 + + if [ $# -eq 2 ]; then + search_log $2 + else + packet_log 20 + fi ;; tc) [ $# -gt 2 ] && usage 1 diff --git a/Shorewall6/shorewall6 b/Shorewall6/shorewall6 index 65ab1d6ee..1d61cc0d6 100755 --- a/Shorewall6/shorewall6 +++ b/Shorewall6/shorewall6 @@ -1282,7 +1282,7 @@ usage() # $1 = exit status echo " restart [ -n ] [ -f ] [ ]" echo " restore [ -n ] [ ]" echo " save [ ]" - echo " show [ -x ] [ -m ] [-f] [ -t {filter|mangle} ] [ {chain [ [ ... ]|actions|capabilities|classifiers|config|connections|filters|ip|log|macros|mangle|nat|policies|raw|routing|tc|vardir|zones} ]" + echo " show [ -x ] [ -m ] [-f] [ -t {filter|mangle} ] [ {chain [ [ ... ]|actions|capabilities|classifiers|config|connections|filters|ip|log []|macros|mangle|nat|policies|raw|routing|tc|vardir|zones} ]" echo " start [ -f ] [ -n ] [ ]" echo " stop [ -f ]" echo " status"