Skip to content

Instantly share code, notes, and snippets.

@alexey-detr
Last active August 29, 2015 14:03
Show Gist options
  • Save alexey-detr/f122f1b70c84a123085e to your computer and use it in GitHub Desktop.
Save alexey-detr/f122f1b70c84a123085e to your computer and use it in GitHub Desktop.
Allow any traffic for loopback. Allow 22, 80 ports. Deny others. Install iptables-persistent to load rules when server boot. I'm using it for default web server configuration.
#!/bin/sh
sudo iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
sudo iptables -A INPUT -p tcp --dport ssh -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 80 -j ACCEPT
sudo iptables -A INPUT -j DROP
sudo iptables -I INPUT 1 -i lo -j ACCEPT
sudo apt-get install iptables-persistent
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment