Practical setting of Linux Firewall iptables, linux Firewall iptables

Source: Internet
Author: User

Practical setting of Linux Firewall iptables, linux Firewall iptables

One important step to maintain a server is to manage the opening and closing of ports to prevent external malicious attacks from exploiting the ports occupied by these services.


First, you can view the iptables information:

Sudo iptables-L

Each rule is listed. The rule marked with ACCEPT indicates that the communication indicated by this rule can be successful, and the rule marked with DROP indicates that the communication indicated by this rule is blocked. Note that during system running, a rule will be matched from the beginning to the end. Therefore, the last rule is DROP, which indicates that the rule is finished, and no DROP is in the middle, otherwise, the subsequent ACCEPT does not work.


Add Rules:

# Iptables-a input-p tcp-I eth0 -- dport ssh-j ACCEPT

-A indicates append,-p tcp indicates tcp protocol,-I eth0 indicates Nic, -- dport ssh indicates port ssh (that is, 22), and-j ACCEPT indicates that this rule is ACCEPT. If we want to open port 9001, replace ssh with port 9001.


Delete rule:

# Iptables-d input 3

3 refers to the third rule, which is the table listed in iptables-L above. The first row is the first rule.


The last one is DROP, so we need to block communication:

# Iptables-a input-j DROP


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.