Created
August 7, 2019 14:46
-
-
Save andygock/fa2d260662f74641e9b15c5519d2a7f9 to your computer and use it in GitHub Desktop.
Basic iptables starter script that only allow incoming SSH and ping
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/bash | |
# | |
# basic iptables starter script that only allow incoming SSH and ping | |
# | |
# default actions | |
iptables -P INPUT DROP | |
iptables -P FORWARD DROP | |
iptables -P OUTPUT ACCEPT | |
# allow ping request | |
iptables -A INPUT -p icmp --icmp-type 8 -j ACCEPT | |
# allow SSH | |
iptables -A INPUT -p tcp -m tcp --dport 22 -j ACCEPT | |
# allow all established | |
iptables -A INPUT -p tcp -m state --state ESTABLISHED,RELATED -j ACCEPT | |
# allow all localhost | |
iptables -A INPUT -i lo -j ACCEPT | |
iptables -A OUTPUT -o lo -j ACCEPT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment