Created
November 20, 2015 13:31
-
-
Save joepreludian/459d2b434538ea7202d1 to your computer and use it in GitHub Desktop.
Simple firewall script to start. Allows only 22 and 80 port.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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