Juneau LUG |
|
|
|
The Juneau Linux Users Group |
||
|
This script parses log entries created by
an iptables firewall. You will be able
to
modify it for other formats though
by modifying
the awk entries. (This is all one line): May 14 21:07:01 firewall kernel: Dropwall:IN=eth1 OUT= MAC=09:19:29:39:49:59:69:79:89:99:09:19:29:39 SRC=61.189.236.10 DST=24.237.22.218 LEN=78 TOS=0x00 PREC=0x00 TTL=110 ID=50924 PROTO=UDP SPT=1026 DPT=137 LEN=58 By default, awk seperates fields in a line with whitespace. So we're interested in fields 9 (SRC=61.189.236.10), 18 (DPT=137) and occasionally 19, as from time to time an extra whitespace will sneak into the log entry. In these cases, the source port ends up at field 18, and the destination port ends up at 19. Your mileage may vary. NOTE: This is quick & dirty. Yes, I know that there are more efficient ways of doing this that don't require THREE separate text files. However I tend to brute force my way through stuff like this, and quit when I get the results I want. Efficiency is left as an exersize for the reader. -James
|
|