Skip to content

Instantly share code, notes, and snippets.

@andygock
Created August 7, 2019 14:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andygock/fa2d260662f74641e9b15c5519d2a7f9 to your computer and use it in GitHub Desktop.
Save andygock/fa2d260662f74641e9b15c5519d2a7f9 to your computer and use it in GitHub Desktop.
Basic iptables starter script that only allow incoming SSH and ping
#!/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