
Iptables -A OUTPUT -o eth0 -p tcp -sport 443 -m state -state ESTABLISHED -j ACCEPT Allowing only SSH to a Network Iptables -A INPUT -i eth0 -p tcp -dport 443 -m state -state NEW,ESTABLISHED -j ACCEPT Iptables -A OUTPUT -o eth0 -p tcp -sport 80 -m state -state ESTABLISHED -j ACCEPT The below rules will allow all the incoming traffic of HTTP & HTTPS (80 & 443) iptables -A INPUT -i eth0 -p tcp -dport 80 -m state -state NEW,ESTABLISHED -j ACCEPT Allowing HTTP & HTTPS Incoming Connections If we trust the internal users, we can use the DROP for incoming rules, and the default outgoing will be ACCEPT.

# iptables -P INPUT DROPįor every firewall rule, we need to define two rules, i.e., one for In-coming and another for Out-going. The default policy is ACCEPT, change the policy to DROP for all the INPUT, FORWARD, OUTPUT. Use the IPtables flush command, below are some examples – #iptables -flush

Deleting the IPtables or Existing Rulesīefore you start building new IPtables set of rules, you should clean up all the default rules, and existing rules.

This article will help you to create IPtables rules that you can directly use for your daily or routine needs, These examples will act as basic templates for you to work on iptables with these rules which suit your specific requirement.
