CentOS system settings iptables

Source: Internet
Author: User
Edit/etc/sysconfig/iptables and run/sbin/serviceiptablesrestart. The rule will not be lost after the system restarts. You can also use the command line method to add rules (rules will be lost after the system is restarted). The following are common firewall rules: iptables-F # Delete an existing rule iptables-PINP edit/etc/sysconfig/ Iptables 
Then run/sbin/service iptables restart. after the system is restarted, the rules will not be lost.
You can also use the command line method to add rules (rules will be lost after the system is restarted). The following are common firewall rules:
Iptables-F # Delete an existing rule
Iptables-p input drop # configure the default deny rule.
The basic rule is to first reject all services and then add new rules as needed.
Iptables-a input-p tcp -- dport 80-j ACCEPT # Open the tcp protocol of the WEB service port
Iptables-a input-p tcp -- dport 110-j ACCEPT # Open the tcp protocol of the POP3 service port
Iptables-a input-p tcp -- dport 25-j ACCEPT # Open the tcp protocol of the SMTP service port
Iptables-a input-p tcp -- dport 21-j ACCEPT # Open the tcp protocol of the FTP service port
Iptables-a input-p tcp-s 202.106.12.130 -- dport 22-j ACCEPT # allow IP address 202.106.12.130 this host to connect to the local SSH service port
Iptables-a input-p tcp -- dport 53-j ACCEPT # allow inbound tcp packets on the DNS service port
Iptables-a input-p udp -- dport 53-j ACCEPT # allow inbound udp packets from the DNS service port
Iptables-a input-p icmp-type echo-request-I eth1-j DROP # prevent death ping. All icmp protocol requests from eth1 are discarded.
Iptables-a forward-p tcp -- syn-m limit -- limit 1/s-j ACCEPT # prevent SYN Flood (DOS attacks)
You can also add rules based on the server situation.
After the rules are set, you can use iptables-save>/etc/iptable. rules to export firewall rules. you can also use iptables-restore/etc/iptables. rules to import firewall rules.
Firewall rules can be activated only when the iptables service is running. To manually start the service, run the following command:
/Sbin/service iptables restart
To ensure that it is started during system boot, run the following command:
/Sbin/chkconfig -- level 345 iptables on
The ipchains service cannot run with the iptables service at the same time. To disable the ipchains service, run the following command:
/Sbin/chkconfig -- level 345 ipchains off

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.