CentOS7: Configuring the most basic web environment-iptables

Source: Internet
Author: User

CentOS7: Configuring the most basic web environment-iptables

A centos 7 virtual machine is installed because you want to try Sphinx.

The previous steps are simple. You can download a new image officially. I use a 64-bit image.

After the installation, ifconfig can see the IP address. VMware chooses bridging to connect the host to the virtual machine.

After the root user enters the system, he attempts to connect to ftp using the host!

An error occurred while trying http. So I started to check the httpd configuration and found no suspicious information. Finally, I found the firewall, Which is iptables.

Iptables-a output-p tcp -- sport 80-j ACCEPT

After execution, the web is normal.

Connection to Mysql (in fact, MariaDB, CentOS uses MariaDB to replace Mysql, but fortunately, everything is the same), failed.

Log on to mysql-u root-p locally.

Iptables-a output-p tcp -- sport 3306-j ACCEPT

Connect to Mysql remotely again. (Grant all privileges on *. * TO 'root' @ '%' identified by '20140901' with grant option; is omitted here ;)

As a result, iptables was started.

Iptable stop

The problem persists after restart

Iptables-a output-p tcp -- sport 80-j ACCEPT

Iptables-a output-p tcp -- sport 3306-j ACCEPT

Service iptables save

The problem persists after restart

Chkconfig-level 35 iptables off

After restart, the problem persists.

Systemctl disable iptables. service

The problem persists after restart

After startup

Service iptables status, you can see that the iptables service is indeed closed, but the rule still takes effect, depressing.

You can find the iptables configuration file under/etc/sysconfig/and add

-A input-p tcp-m tcp -- dport 80-j ACCEPT
-A input-p tcp-m tcp -- dport 3306-j ACCEPT

After restart, the problem persists.

Finally, I had a compromise. Now, I need to restart and execute two lines of commands at a time!

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.