Enable and disable the IPtables firewall and ports 3306, 80, and in Centos.

Source: Internet
Author: User
Tags centos iptables

1. Enable and disable IPtables

1. Takes effect after restart

Enable: chkconfig iptables on

Close: chkconfig iptables off or chkconfig-level 35 iptables off

2. It takes effect immediately and becomes invalid after restart

Enable: service iptables start


Disable: service iptables stop


Temporarily disable the firewall:/etc/init. d/iptables stop


Restart iptables:/etc/init. d/iptables restart

2. View the firewall's iptables status:

/Etc/init. d/iptables status


3. Open ports 3306, 80, and in the IPtables firewall


/Sbin/iptables-I INPUT-p tcp-dport 80-j ACCEPT


/Sbin/iptables-I INPUT-p tcp-dport 22-j ACCEPT


/Sbin/iptables-I INPUT-p tcp-dport 3306-j ACCEPT

Then save:


/Etc/rc. d/init. d/iptables save

Well, the switch operation on the firewall in iptalbes is actually a very simple command with the same/sbin/iptables-I INPUT-p tcp-dport followed by a port, the other is simple acceptance. You can set it as needed.

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.