Created
July 27, 2018 22:24
-
-
Save josuebasurto/d14020c3ef1c9b047afc01384f4b626a to your computer and use it in GitHub Desktop.
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 22 -m state --state NEW -s 0.0.0.0/0 -j ACCEPT | |
$IPT -A INPUT -p tcp --dport 5000:5999 -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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment