Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save pcdinh/354746 to your computer and use it in GitHub Desktop.
Save pcdinh/354746 to your computer and use it in GitHub Desktop.
#!/bin/bash
echo "Flushing iptables..."
iptables -F
echo "SSH Allowed"
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
echo "allow from localhost"
iptables -A INPUT -i lo -j ACCEPT
echo "allow from 192.168.1.1-100"
iptables -I INPUT 3 -i eth0 -m iprange --src-range 192.168.1.1-192.168.1.100 -j ACCEPT
echo "allow all pings"
iptables -I INPUT 5 -p icmp -j ACCEPT
# Set default policies for INPUT, FORWARD and OUTPUT chains
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT ACCEPT
# Accept packets belonging to established and related connections
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment