SHARE
TWEET
Untitled
a guest
Apr 23rd, 2015
4
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- #!/bin/sh
- ETH0=$(ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}')
- # Flushing all rules
- iptables -F
- iptables -X
- # Setting default filter policy
- iptables -P INPUT DROP
- iptables -P OUTPUT ACCEPT
- iptables -P FORWARD DROP
- # Allow unlimited traffic on loopback
- iptables -A INPUT -i lo -j ACCEPT
- iptables -A OUTPUT -o lo -j ACCEPT
- iptables -A OUTPUT -o eth0 -j ACCEPT
- # Allow incoming ssh only
- iptables -A INPUT -p tcp -s 0/0 -d ${ETH0} --sport 513:65535 --dport 22 -m state --state NEW,ESTABLISHED -j ACCEPT
- iptables -A OUTPUT -p tcp -s ${ETH0} -d 0/0 --sport 22 --dport 513:65535 -m state --state ESTABLISHED -j ACCEPT
- #Allow DNS for outgoing connection
- iptables -A INPUT -p tcp -s 0/0 -d ${ETH0} -m state --state ESTABLISHED,RELATED -j ACCEPT
- iptables -A INPUT -p tcp -s 0/0 -d ${ETH0} --sport 513:65535 --dport 22 -j ACCEPT
- # make sure nothing comes or goes out of this box
- iptables -A INPUT -j DROP
RAW Paste Data
