Linux system View set iptables rules __linux

Source: Internet
Author: User
Tags iptables

Sometimes we just took over the iptables rules that the server used to do. We may not know, need to look at the iptables rules how to write since the understanding of the machine, I will introduce to view the Iptables rule instance.

Iptables is a powerful Linux firewall that uses a very high frequency. This article describes how to view the Iptables rule settings.

1, Iptables-l

View the iptables rule for the filter table, including all the chains. The filter table contains three rule chains for input, OUTPUT, and forward.
Note:-L is a shorthand for--list, which is to list the rules.

2, Iptables-l [-t table name]

View only the rules in a table.
Description: There are three table names: Filter,nat,mangle, and if you do not specify a table name, the list of rules for the filter table (equivalent to the first command) is viewed by default.

Example: Iptables-l-t filter

3, Iptables-l [-t table name] [chain name]

Here is a chain name, which is the name of the chain of rules.
Description: Iptables has input, OUTPUT, FORWARD, prerouting, postrouting five rules chain.
Example: Iptables-l INPUT
Note: The chain name must be uppercase. On Linux systems, the case of commands is sensitive.

4. Iptables-n-L

Description: Displays the rule in digital form. If there is no-n, there may be anywhere in the rule, with-N, which becomes 0.0.0.0/0

5, Iptables-nv-l

Description: You can also use "Iptables-l-nv" to view, this list looks more detailed, more friendly to the technical staff, hehe.

If you want to remove the iptables rule we can do the following

Delete with the-d parameter

Delete the previously added rule (iptables-a input-s 192.168.1.5-j DROP):

[Root@test ~]# iptables-d input-s 192.168.1.5-j drop sometimes the rule to delete is too long to write a large number of delete, both waste time and easy to write mistakes, then we can use the –line-number to find out the rule of the line numbers, Then delete the rule by line number.

[Root@test ~]# Iptables-nv--line-number
Iptables v1.4.7:no Command specified
Try ' iptables-h ' or ' iptables--help ' for the more information.
[Root@test ~]# iptables-nl--line-number
Chain INPUT (Policy ACCEPT)
Num Target prot opt source destination
1 DROP All--192.168.1.1 0.0.0.0/0
2 DROP All--192.168.1.2 0.0.0.0/0
3 DROP All--192.168.1.3 0.0.0.0/0

Delete second row rule

[Root@test ~]# iptables-d INPUT 2

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.