Home > Article > Operation and Maintenance > How to solve the problem of blocked port in Linux
How to solve the problem of blocked port in Linux
Linux system will have network firewall settings. If the firewall is turned off, then as long as If a service is enabled on a certain port on Linux, then Telnet can be connected to this port. The prerequisite for Telnet to be able to connect to a certain port is that the service is enabled on this port, and the firewall allows access to this port.
Let’s talk about how to solve the problem of blocked ports.
Set the required port to be able to pass through the firewall:
The method to set a certain port to be able to pass through the firewall is as follows:
vi /etc/sysconfig/iptables
Enter the editing page, Add the following configuration in the specified location
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT
This sentence should be placed after -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
Modify After saving and exiting, restart the network card service
service iptables restart
View the port opening information
service iptables status
Generally, if the server can see the opening information, it will be successfully opened. .
Determine whether a certain port has a service
netstat -anp |grep "Port number to be viewed", such as netstat -anp |grep "9001"
If 9001 is set in /etc/sysconfig/iptables to pass the firewall, and the service is started again, then other computers in the network segment can telnet to the 9001 port of the machine. You can also telnet localhost 9001 on this machine to check whether 9001 can be telneted.
If it is a purchased server, you also need to set port release in the security group.
Recommended: linux operation and maintenance tutorial
The above is the detailed content of How to solve the problem of blocked port in Linux. For more information, please follow other related articles on the PHP Chinese website!