Created
November 24, 2013 17:55
-
-
Save jtomaszewski/7630081 to your computer and use it in GitHub Desktop.
A basic, example iptables file you can use to configure your VPS.
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
#!/bin/sh | |
iptables -F | |
iptables -X | |
iptables -P INPUT DROP | |
iptables -P FORWARD DROP | |
iptables -P OUTPUT ACCEPT | |
iptables -A INPUT -i lo -j ACCEPT | |
iptables -A FORWARD -o lo -j ACCEPT | |
iptables -A INPUT -j ACCEPT -m state --state ESTABLISHED,RELATED | |
iptables -A FORWARD -j ACCEPT -m state --state ESTABLISHED,RELATED | |
# ping | |
iptables -A INPUT -p icmp --icmp-type 8 -j ACCEPT | |
# ssh | |
iptables -A INPUT -s 0/0 -p tcp --dport 22 -j ACCEPT | |
iptables -A INPUT -s 0/0 -p udp --dport 22 -j ACCEPT | |
# http | |
iptables -A INPUT -s 0/0 -p tcp --dport 80 -j ACCEPT | |
iptables -A INPUT -s 0/0 -p udp --dport 80 -j ACCEPT | |
# https | |
iptables -A INPUT -s 0/0 -p tcp --dport 443 -j ACCEPT | |
iptables -A INPUT -s 0/0 -p udp --dport 443 -j ACCEPT | |
# mysql | |
iptables -A INPUT -s 0/0 -p tcp --dport 3306 -j ACCEPT | |
iptables -A INPUT -s 0/0 -p udp --dport 3306 -j ACCEPT | |
# webmin | |
iptables -A INPUT -p tcp -m tcp --dport 10000 -j ACCEPT | |
# imap, imaps, smtp | |
iptables -A INPUT -s 0/0 -p tcp --dport 143 -j ACCEPT # imap | |
iptables -A INPUT -s 0/0 -p udp --dport 143 -j ACCEPT # imap | |
iptables -A INPUT -s 0/0 -p tcp --dport 993 -j ACCEPT # imaps | |
iptables -A INPUT -s 0/0 -p udp --dport 993 -j ACCEPT # imaps | |
iptables -A INPUT -s 0/0 -p tcp --dport 25 -j ACCEPT # smtp | |
iptables -A INPUT -s 0/0 -p udp --dport 25 -j ACCEPT # smtp | |
iptables -A INPUT -s 0/0 -p tcp --dport 587 -j ACCEPT # smtp | |
iptables -A INPUT -s 0/0 -p udp --dport 587 -j ACCEPT # smtp | |
iptables -A INPUT -s 0/0 -p tcp --dport 110 -j ACCEPT # pop3 | |
iptables -A INPUT -s 0/0 -p udp --dport 110 -j ACCEPT # pop3 | |
iptables -A INPUT -s 0/0 -p tcp --dport 995 -j ACCEPT # pop3s | |
iptables -A INPUT -s 0/0 -p udp --dport 995 -j ACCEPT # pop3s | |
# 25. Log dropped packets to | |
iptables -N LOGGING | |
iptables -A INPUT -j LOGGING | |
iptables -A LOGGING -m limit --limit 2/min -j LOG --log-prefix "IPTables Packet Dropped: " --log-level 7 | |
iptables -A LOGGING -j DROP | |
# and save it to the config file | |
iptables-save > /etc/iptables.up.rules |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment