From charlesreid1

Revision as of 05:54, 22 August 2016 by Admin (talk | contribs)

iptables is a firewall program.

Simple example

here is a simple iptables example that allows ssh, http, and https, and not much else. It is a good starting point.

# Flush
iptables -F

# allow SSH/HTTP/HTTPS
iptables -A INPUT  -p tcp --dport 22 -j ACCEPT
iptables -A OUTPUT -p tcp --dport 22 -j ACCEPT
iptables -A INPUT  -p tcp --dport 80 -j ACCEPT
iptables -A OUTPUT -p tcp --dport 80 -j ACCEPT
iptables -A INPUT  -p tcp --dport 443 -j ACCEPT
iptables -A OUTPUT -p tcp --dport 443 -j ACCEPT

# Set default policies for INPUT, FORWARD and OUTPUT chains
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT ACCEPT

# Set access for localhost
iptables -A INPUT -i lo -j ACCEPT

# Accept packets belonging to established and related connections
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

OpenVPN iptables scripts

For more examples of iptables scripts, you can visit the OpenVPN/Static Key page. More specifically:

Flags