Delete iptables rules-how to delete an existing iptables rule
Source: Internet
Author: User
Syntax: iptables-Dchainrulenum [options] Where: chain indicates the chain, that is, the attribute rulenum such as INPUTFORWARD indicates the rule number. Start from 1. You can use iptables-LINPUT -- line-numbers to list... syntax: iptables-D chain rulenum [options] Where: chain indicates the chain, that is, the attribute rulenum such as input forward is the number of the rule. Start from 1. You can use iptables-l input -- line-numbers to list the rule numbers of the specified chain. Therefore, for example, if you want to delete an INPUT chain rule, iptables-d input 3 means to delete 3rd rules. There is also A second method. The second method is-A command ing, but replace-A with-D. This is useful when the rules in your chain are complex and you do not want to calculate their numbers. That is to say, how do you use iptables-.... if A rule is defined in A statement,-D is used to replace-A directly when this rule is deleted. The rest will remain unchanged without any numbers. ==================================== Let's talk about the preceding -- line-numbers option, the following command: iptables-l input -- line-numbers lists all rules of the INPUT chain num target prot opt source destination 1 REJECT tcp -- anywhere tcp dpt: microsoft-ds reject-with icmp-port-unreachable 2 REJECT tcp -- anywhere tcp dpt: 135 reject-with icmp-port-unreachable 3 REJECT tcp -- anywhere tcp dpt: netbios-ssn reject-with icmp-port-unreachable 4 REJECT udp -- anywhere udp dpt: microsoft-ds reject-with icmp-port-unreachable 5 REJECT udp -- anywhere udp dpt: 135 reject-with icmp-port-unreachable ...... delete the specified row 4th rule: iptables-d input 4 [root @ tp ~] # Iptables-F clear the rules of all rule chains in the filter of the preset table [root @ tp ~] # Iptables-X clear the rules in the user-defined chain in the filter of the preset table
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.