Add Iptables Chain

Iptables is used to set up, maintain, and inspect the tables of IP packet filter rules in the Linux kernel.

Add Chain Example (from command line):

Create a new chain in iptables:

# iptables -N chainname

Insert the chain into the input chain at the head of the list:

# iptables -I INPUT 1 -j chainname

Flush all the rules in the chain:

# iptables -F chainname

Some Iptables Commands in Detail:

-I, --insert chain [rulenum] rule-specification
Insert one or more rules in the selected chain as the given rule number. So, if the rule number is 1, the rule or rules are inserted at the head of the chain. This is also the default if no rule number is specified.

-L, --list [chain]
List all rules in the selected chain. If no chain is selected, all chains are listed.

-F, --flush [chain]
Flush the selected chain (all the chains in the table if none is given). This is equivalent to deleting all the rules one by one.

-N, --new-chain chain
Create a new user-defined chain by the given name.  There must be no target of that name already.

Leave a Reply

Your email address will not be published.