Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- ###### SETUP ######
- # VARS #
- fw="iptables"
- # Cleaning #
- $fw -F
- $fw -X
- $fw -t nat -F
- $fw -t nat -X
- $fw -t mangle -F
- $fw -t mangle -X
- # Default Policy #
- $fw -P INPUT DROP
- $fw -P FORWARD DROP
- $fw -P OUTPUT DROP
- # Loopback interface #
- $fw -A INPUT -i lo -j ACCEPT
- $fw -A OUTPUT -o lo -j ACCEPT
- ###### CONFIG ######
- # Sessions #
- $fw -A INPUT -p all -m state --state ESTABLISHED,RELATED -j ACCEPT
- $fw -A OUTPUT -p all -m state --state ESTABLISHED,RELATED -j ACCEPT
- # SERVICES #
- # All outgoing connections #
- #$fw -A OUTPUT -p all -j ACCEPT
- # SSH #
- $fw -A INPUT -p tcp --dport 22 -j ACCEPT
- ####### LOG #######
- # All undefined packets to new chain "undef_" #
- $fw -N undef_in
- $fw -N undef_out
- $fw -N undef_fw
- $fw -A INPUT -j undef_in
- $fw -A OUTPUT -j undef_out
- $fw -A FORWARD -j undef_fw
- # Log all packages in chains undef_ #
- $fw -A undef_in -j LOG --log-level 7 --log-prefix "Iptables: drop input: "
- $fw -A undef_in -j DROP
- $fw -A undef_out -j LOG --log-level 7 --log-prefix "Iptables: drop output: "
- $fw -A undef_out -j DROP
- $fw -A undef_fw -j LOG --log-level 7 --log-prefix "Iptables: drop forward: "
- $fw -A undef_fw -j DROP
- ###### Save all rules ######
- /sbin/service iptables save
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement