Created
May 4, 2014 18:18
-
-
Save jasonmccallister/b6868356639701776fd3 to your computer and use it in GitHub Desktop.
Bash file to quickly install CentOS firewall rules
This file contains 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
# flush all rules | |
iptables -F | |
# block null packets | |
iptables -A INPUT -p tcp --tcp-flags ALL NONE -j DROP | |
# block syn-flood attacks | |
iptables -A INPUT -p tcp ! --syn -m state --state NEW -j DROP | |
# block XMAS packets | |
iptables -A INPUT -p tcp --tcp-flags ALL ALL -j DROP | |
# allow localhost | |
iptables -A INPUT -i lo -j ACCEPT | |
# allow 80 and 443 for webserver | |
iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT | |
iptables -A INPUT -p tcp -m tcp --dport 443 -j ACCEPT | |
# allow SMTP on 465 | |
iptables -A INPUT -p tcp -m tcp --dport 465 -j ACCEPT | |
# allow SSH access | |
iptables -A INPUT -p tcp -m tcp --dport 22 -j ACCEPT | |
# allow outgoing connections block everything else | |
iptables -I INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT | |
iptables -P OUTPUT ACCEPT | |
iptables -P INPUT DROP | |
# save rules | |
iptables -L -n | |
iptables-save > /etc/sysconfig/iptables | |
# restart iptables | |
service iptables restart |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment