How does the Linuxiptables firewall open the MySQL connection port?

Source: Internet
Author: User
Modify the firewall configuration file: vi/etc/sysconfig/iptables add the following line:-ARH-Firewall-1-INPUT-mstate? StateNEW-mtcp-ptcp? If you want to open port 21 and other dport3306-jACCEPT, you only need to switch 3306 to port 21 to open. After configuration, restart iptableser

Modify the firewall configuration file:
Vi/etc/sysconfig/Iptables
Add the following line:
-A RH-Firewall-1-INPUT-m state? State NEW-m tcp-p tcp? Dport3306-j ACCEPT
If you want to activate ports such as 21, you only need to replace 3306 with the ports to be opened, such as 21.
After configuration, restart iptable
Service iptables restart
Then you can access Mysql from other machines.

Note:
-A RH-Firewall-1-INPUT-m state -- state NEW-m tcp-p tcp -- dport3306-j ACCEPT
-A RH-Firewall-1-INPUT-j REJECT -- reject-withicmp-host-prohibited

-A RH-Firewall-1-INPUT-j REJECT -- reject-with icmp-host-prohibited
It indicates that icmp access is denied. if other packets are returned, an error is returned indicating that access is disabled on the host.

The line for enabling port 3306 must be before icmp-host-prohibited.

 

 

Open port 80

Open flle/etc/sysconfig/iptables:
# Vi/etc/sysconfig/iptables
Append rule as follows:
-A RH-Firewall-1-INPUT-m state -- state NEW-m tcp-p tcp -- dport80-j ACCEPT
Save and close the file. Restart iptables:
#/Etc/init. d/iptables restart

Public port 110

Append rule as follows:
-A RH-Firewall-1-INPUT-m state -- state NEW-m tcp-p tcp -- dport110-j ACCEPT

Public port 143

Append rule as follows:
-A RH-Firewall-1-INPUT-m state -- state NEW-m tcp-p tcp -- dport143-j ACCEPT

Restart iptables service

Type the following command:
# Service iptables restart

Verify that port is open

Run following command:
Netstat-tulpn | less
Make sure iptables is allowing port 80/110/143 connections:
Iptables-L-n

Refer to iptables man page for more information about iptablesusage and syntax:
Man iptables

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.