Last active
February 28, 2020 16:52
-
-
Save AysadKozanoglu/c051098855a85d55a0085cfc30f1c554 to your computer and use it in GitHub Desktop.
iptable script enable http https ssh 222001 postfix&dovecot imp
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 | |
IPT="/sbin/iptables" | |
# Flush old rules, old custom tables | |
$IPT --flush | |
$IPT --delete-chain | |
# Set default policies for all three default chains | |
$IPT -P INPUT DROP | |
$IPT -P FORWARD DROP | |
$IPT -P OUTPUT ACCEPT | |
# Enable free use of loopback interfaces | |
$IPT -A INPUT -i lo -j ACCEPT | |
$IPT -A OUTPUT -o lo -j ACCEPT | |
# All TCP sessions should begin with SYN | |
$IPT -A INPUT -p tcp ! --syn -m state --state NEW -s 0.0.0.0/0 -j DROP | |
# Accept inbound TCP packets | |
$IPT -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT | |
$IPT -A INPUT -p tcp --dport 22001 -m state --state NEW -s 0.0.0.0/0 -j ACCEPT | |
$IPT -A INPUT -p tcp --dport 80 -m state --state NEW -s 0.0.0.0/0 -j ACCEPT | |
$IPT -A INPUT -p tcp --dport 443 -m state --state NEW -s 0.0.0.0/0 -j ACCEPT | |
#postfix dovecot ports | |
$IPT -A INPUT -p tcp --dport 143 -m state --state NEW -s 0.0.0.0/0 -j ACCEPT | |
$IPT -A INPUT -p tcp --dport 993 -m state --state NEW -s 0.0.0.0/0 -j ACCEPT | |
$IPT -A INPUT -p tcp --dport 995 -m state --state NEW -s 0.0.0.0/0 -j ACCEPT | |
$IPT -A INPUT -p tcp --dport 465 -m state --state NEW -s 0.0.0.0/0 -j ACCEPT | |
$IPT -A INPUT -p tcp --dport 25 -m state --state NEW -s 0.0.0.0/0 -j ACCEPT | |
# Accept inbound ICMP messages | |
$IPT -A INPUT -p ICMP --icmp-type 8 -s 0.0.0.0/0 -j ACCEPT | |
$IPT -A INPUT -p icmp -m icmp --icmp-type 8 -m limit --limit 1/second -j ACCEPT | |
#LOGGING |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment