Linux iptables: Rule Composition

Source: Internet
Author: User

Linux iptables: Rule Composition

Linux iptables: Rule principles and basics describes the four-table and five-chain links of iptables, which are the mount points through which packets at different network layers will pass, which table can be used to define rules for each mount point.

This article describes the composition of an iptables rule.

Linux iptables: Rule Composition

--------------------------------------------------------------------------------

This is the basic composition of iptables rules and the command format for iptables to define rules:

The first column is the iptables command;

The second column specifies the table where the rule is located. nat and filter tables are commonly used;

The third column is the command. Common commands are as follows:

-A adds A new rule (append) to the end of the specified chain.

-D delete: Specifies a rule in the chain, which can be deleted according to the rule sequence number and content.

-I insert a new rule in the specified chain. By default

-R: modify or replace a rule in a specified chain, which can be replaced by the rule sequence number and content.

-L list all the rules in the specified chain for viewing

-F flush rule

-P: Set the Default policy for the specified chain)

-N displays the output in the numeric format (numeric)


The fourth column is the mount point to which the rule applies;

The Fifth Column is options. Common options are as follows:

-P indicates the protocol.

-S source address

-D Destination Address

-- Sport source port number

-- Dport destination port number

-- Dports destination port number list

-M supplement

The sixth column is rules. Common rules are as follows:

ACCEPT allows data packets to pass through

DROP directly discards data packets without any response information

The REJECT rejects data packets and sends a response to the data sender if necessary.

SNAT rewrite the data packet source address

DNAT rewrite the destination address of the Data Packet

LOG Record Data Packets


The commands and parameters used in iptables rule definition are described as follows.

-------------------------------------- Split line --------------------------------------

Disable the default firewall in CentOS 7.0 and enable the iptables firewall.

Iptables examples

Linux Firewall iptables

Basic use of iptables backup, recovery, and firewall scripts

Detailed description of firewall iptables usage rules in Linux

-------------------------------------- Split line --------------------------------------

This article permanently updates the link address:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.