Solve the problem that CentOS firewall cannot be started

Source: Internet
Author: User
CentOS firewall cannot be started, and the firewall service must be enabled for all online servers. this is the most direct and effective method for linux system security protection. 1. if serviceiptablesstartserviceiptablesrestart fails to start/restart the firewall. 2. the best way is to modify the configuration file vi/etc/sysco.

CentOS firewall cannot be started, and the firewall service must be enabled for all online servers. this is the most direct and effective method for linux system security protection.

1. if

Service iptables start

Service iptables restart

When the firewall cannot be started/restarted.

 

2. the best way is to modify the configuration file.

Vi/etc/sysconfig/iptables

 

[Plain]View plaincopy
  1. # Firewall configuration written by system-config-firewall
  2. # Manual customization of this file is not recommended.
  3. * Filter
  4. : Input accept [0: 0]
  5. : Forward accept [0: 0]
  6. : Output accept [0: 0]
  7. -A input-m state -- state ESTABLISHED, RELATED-j ACCEPT
  8. -A input-p icmp-j ACCEPT
  9. -A input-I lo-j ACCEPT
  10. -A input-m state -- state NEW-m tcp-p tcp -- dport 22-j ACCEPT
  11. -A input-j REJECT -- reject-with icmp-host-prohibited
  12. -A forward-j REJECT -- reject-with icmp-host-prohibited
  13. COMMIT

 

 

Then start the firewall.

Service iptables start

View firewall services

Service iptables status

 

3. if you need to enable the exception port, add the following configuration:

Vi/etc/sysconfig/iptables

 

[Plain]View plaincopy
  1. # Firewall configuration written by system-config-firewall
  2. # Manual customization of this file is not recommended.
  3. * Filter
  4. : Input accept [0: 0]
  5. : Forward accept [0: 0]
  6. : Output accept [0: 0]
  7. -A input-m state -- state ESTABLISHED, RELATED-j ACCEPT
  8. -A input-p icmp-j ACCEPT
  9. -A input-I lo-j ACCEPT
  10. -A input-m state -- state NEW-m tcp-p tcp -- dport 22-j ACCEPT
  11. -A input-m state -- state NEW-m tcp-p tcp -- dport 3306-j ACCEPT
  12. -A input-j REJECT -- reject-with icmp-host-prohibited
  13. -A forward-j REJECT -- reject-with icmp-host-prohibited
  14. COMMIT

 

As shown in the preceding figure, Port 3306 is added.

 

If you need to disable the firewall to start automatically

View status

 

Chkconfig -- list iptables disable automatic chkconfig iptables off

View status

Chkconfig -- list iptables
Related Article

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.