Added mount comparison and saving iptables rules to iptables-save format

master
Mateusz Chochół 8 years ago
parent 2e3fe3a793
commit 42f2001651
  1. 5
      statesnap.sh

@ -15,6 +15,8 @@ function makeSnap {
ps aux | awk '{ print $11 }' | sort | uniq | egrep -v '^\[' > $FOLDER/ps.out ps aux | awk '{ print $11 }' | sort | uniq | egrep -v '^\[' > $FOLDER/ps.out
netstat -lpn | egrep "(tcp.*LISTEN|udp)" | sort | uniq | awk '{split($NF,arr,"/"); print $1 " " $4 " " arr[2]}' > $FOLDER/netstat.out netstat -lpn | egrep "(tcp.*LISTEN|udp)" | sort | uniq | awk '{split($NF,arr,"/"); print $1 " " $4 " " arr[2]}' > $FOLDER/netstat.out
(/sbin/iptables -L -n; echo -e "\n#NAT\n"; /sbin/iptables -L -nt nat) > $FOLDER/iptables.out (/sbin/iptables -L -n; echo -e "\n#NAT\n"; /sbin/iptables -L -nt nat) > $FOLDER/iptables.out
/sbin/iptables-save > $FOLDER/iptables-save.out
mount > $FOLDER/mount.out
/sbin/ip route > $FOLDER/routing.out /sbin/ip route > $FOLDER/routing.out
msg "Written state snapshot to $FOLDER" msg "Written state snapshot to $FOLDER"
} }
@ -31,6 +33,9 @@ function compare {
echo -e "$GREEN\nFirewall rules diff$RST" echo -e "$GREEN\nFirewall rules diff$RST"
echo -e "$BLUE============================================================================$RST" echo -e "$BLUE============================================================================$RST"
(/sbin/iptables -L -n; echo -e "\n#NAT\n"; /sbin/iptables -L -nt nat) | diff - $FOLDER/iptables.out (/sbin/iptables -L -n; echo -e "\n#NAT\n"; /sbin/iptables -L -nt nat) | diff - $FOLDER/iptables.out
echo -e "$GREEN\nMounts diff$RST"
echo -e "$BLUE============================================================================$RST"
mount | diff - $FOLDER/mount.out
echo -e "$GREEN\nRouting table diff$RST" echo -e "$GREEN\nRouting table diff$RST"
echo -e "$BLUE============================================================================$RST" echo -e "$BLUE============================================================================$RST"
/sbin/ip route | diff - $FOLDER/routing.out /sbin/ip route | diff - $FOLDER/routing.out

Loading…
Cancel
Save