Skip to content

Instantly share code, notes, and snippets.

@caspian311
Last active August 29, 2015 14:04
Show Gist options
  • Select an option

  • Save caspian311/0046b609dca1cc7e75f8 to your computer and use it in GitHub Desktop.

Select an option

Save caspian311/0046b609dca1cc7e75f8 to your computer and use it in GitHub Desktop.
firewall settings that only allows ssh and web access
#!/bin/sh
# Flushing all rules
iptables -F
iptables -X
# Setting default filter policy
iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -P FORWARD DROP
# Allow unlimited traffic on loopback
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT
# Allow incoming ssh only
iptables -A INPUT -m state --state NEW -p tcp --dport 22 -j ACCEPT
# Allow web traffic
iptables -A INPUT -m state --state NEW -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -m state --state NEW -p tcp --dport 443 -j ACCEPT
# make sure nothing comes or goes out of this box
iptables -A INPUT -j DROP
iptables -A OUTPUT -j DROP
@caspian311
Copy link
Copy Markdown
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment