

The following example shows how to apply a restrictive policy with Iptables by dropping all incoming traffic except for the allowed. In this case, every connection is refused unless you define a rule to accept it.Īpplying a restrictive policy with Iptables: On the contrary, restrictive policies refuse all connections except for these you specifically accept. In this case, every connection is allowed unless you define a rule to refuse it specifically. You can apply Iptables with a permissive policy by accepting all incoming connections except for these you specifically drop or reject. Iptables permissive and restrictive policies: When you deal with Iptables, you need first to define the three policies for each chain after that, you can add exceptions and specifications. When using REJECT, an ICMP packet returns destination-unreachable to the source host. TCP packets will return an ACK/RST, which is the same response that an open port with no service on it will respond with.


When using DROP, UDP packets are dropped, and the behavior will be the same as connecting to a port with no service. The policy ACCEPT allows connections the policy REJECT refuses connections returning an error the policy DROP refuses connections without producing errors. There are 3 types of policies: ACCEPT, REJECT and DROP. The output also shows there are no defined rules, and all defined policies are accepted. Where INPUT refers to policies regarding incoming traffic, OUTPUT refers to policies applied to outgoing traffic, and FORWARD refers to routing policies. The output above shows 3 rows: Chain INPUT, Chain FORWARD, and Chain OUTPUT. The following list shows what chains include each table: Each table contains built-in (rule) chains. For example, there is a table for routing tasks and another table for filtering tasks each table contains rule chains.Īvailable tables are filter, nat, raw, security, and mangle. TABLE: Tables are iptables features for each purpose. TARGET: When using iptables, a target is an action you want Iptables to apply when a packet matches a rule.ĬHAIN: A chain is a list of rules available built-in chains are: INPUT, OUTPUT, FORWARD, PREROUTING, and POSTROUTING. Note: sudo command was added for readers who need to copy-paste the rules mentioned in this iptables tutorial. With Iptables, users can accept, refuse, or onward connections it is incredibly versatile and widely used despite being replaced by nftables.Īfter reading this tutorial, you will understand Iptables policies and define Iptables rules to protect your home network. Iptables is a command-line firewall that filters packets according to the defined rules.
