Skip to content

Instantly share code, notes, and snippets.

@joepreludian
Created November 20, 2015 13:31
Show Gist options
  • Save joepreludian/459d2b434538ea7202d1 to your computer and use it in GitHub Desktop.
Save joepreludian/459d2b434538ea7202d1 to your computer and use it in GitHub Desktop.
Simple firewall script to start. Allows only 22 and 80 port.
# Exclui as regras ativas
iptables -t nat -F
iptables -t mangle -F
iptables -t filter -F
### Exclui cadeias customizadas
iptables -X
### Zera os contadores das cadeias
iptables -t nat -Z
iptables -t mangle -Z
iptables -t filter -Z
### Define a política padrão do firewall
iptables -P INPUT DROP
iptables -P OUTPUT ACCEPT
iptables -P FORWARD DROP
### Regras INPUT
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -p icmp --icmp-type 0 -j ACCEPT
iptables -A INPUT -p icmp --icmp-type 8 -j ACCEPT
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
### Regras OUTPUT
iptables -A OUTPUT -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
echo "Firewall Loaded!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment