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!