Lets learn "Structure of IPTables rules"
This tutorial is basically an extension of the previous tutorial available here where we talked about the basics of Linux IPTables inbuilt tables and chains. In this tutorial, we'll discuss the Linux IPTables rules, about how they are structured in the IPTables command.
Some points need to keep in mind regarding IPTables rules
- Rules are matched in serial order in every chain.
- Every rule contains criteria and a target. Criteria is basically the condition for the rule to match the IP packet.
- If criteria is matched, the control goes to the rule provided in the target or executes the special values available in the target.
- If criteria is not matched, control goes to the next rule in the chain.
Target Values
Now that we know what criteria and target are. Let's learn about special values you can specify for the TARGET. These special values are already known to the Linux IPTables program.
- ACCEPT - The packet will be accepted by the firewall.
- DROP - The packet will be dropped by the firewall.
- QUEUE - The packet will be transferred to the userspace by the firewall.
- RETURN - The firewall will stop executing the next rules in the current chain and control will go back to the calling chain.
- REJECT - iptables “rejects” the packet. It sends a “connection reset” packet in case of TCP, or a “destination host unreachable” packet in case of UDP or ICMP.
Example
Above example shows a sample rule in FILTER table's INPUT chain with CRITERIA that if packet is coming from eth0 interface with protocol tcp and destination port 22 then the TARGET would be accepted (i.e the packet would be accepted by firewall in such case ).
HOPE YOU LIKED THIS TUTORIAL. IF YOU HAVE ANY DOUBTS, DON't FORGET TO COMMENT BELOW. STAY TUNED FOR MORE TUTORIALS :)
Comments
Post a Comment