From charlesreid1

No edit summary
No edit summary
Line 1: Line 1:
iptables is a firewall program.
iptables is a firewall program.


For an exmple of iptables scripts, you can visit the [[OpenVPN/Static Key]] page. More specifically:
==Simple example==
 
here is a simple iptables example that allows ssh, http, and https, and not much else. It is a good starting point.
 
<pre>
# 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
</pre>
 
==OpenVPN iptables scripts==
 
For more examples of iptables scripts, you can visit the [[OpenVPN/Static Key]] page. More specifically:
* https://charlesreid1.com/wiki/OpenVPN/Static_Key#Server_Firewall_Script
* https://charlesreid1.com/wiki/OpenVPN/Static_Key#Server_Firewall_Script
* https://charlesreid1.com/wiki/OpenVPN/Static_Key#Client_Firewall_Script
* https://charlesreid1.com/wiki/OpenVPN/Static_Key#Client_Firewall_Script


 
==Flags==
=Flags=


{{LinuxNetworkingFlag}}
{{LinuxNetworkingFlag}}

Revision as of 05:54, 22 August 2016

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