NightKhaos

Neutron Security Group Logging

Aug 31st, 2015
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.88 KB | None | 0 0
  1. #!/bin/bash
  2. # This script looks in iptables to see if Neutron security groups have been initalised and then adds
  3. # the following rule if it does not already exist:
  4. # -I neutron-openvswi-sg-fallback -m limit --limit 6/min -j LOG --log-prefix "Neutron-Dropped: " -m comment --comment "Log rule for unmatched traffic"
  5. CHAINNAME=neutron-openvswi-sg-fallback
  6. RULE='-m limit --limit 6/min -j LOG --log-prefix "Neutron-Dropped: " -m comment --comment "Log rule for unmatched traffic"'
  7.  
  8. # Find out where iptables is
  9. if IPTABLES=$(which iptables)
  10. then
  11.     # Confirm the neutron-openvswi-sg-fallback chain exits
  12.     if $IPTABLES -S | grep -q "\-N $CHAINNAME"
  13.     then
  14.         # See if the LOG entry exists in that chain
  15.         if ! $IPTABLES -S | grep "\-A $CHAINNAME" | grep -q LOG
  16.         then
  17.             # Create the rule
  18.             eval $IPTABLES -I $CHAINNAME $RULE
  19.         fi
  20.     fi
  21. fi
Advertisement
Add Comment
Please, Sign In to add comment