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