Solve Problems Related to the failure of Connecting ports in CentOS
Recently, when setting up a CentOS service, port 22 is always unavailable and port 22 of Windows Telnet cannot be accessed. In CentOS, netstat-lnpt checks that port 22 is not monitored, therefore, the online Search solution can be used, but none of them can solve the problem.
Now we will solve it step by step.
I. Add port 22 to iptables
1. To open ports 8080, enter the following command.
/Sbin/iptables-I INPUT-p tcp-dport 80-j ACCEPT
/Sbin/iptables-I INPUT-p tcp-dport 22-j ACCEPT
/Sbin/iptables-I INPUT-p tcp-dport 8080-j ACCEPT
2. Modify the file
Vim/etc/rc. d/init. d/iptables
Add the preceding text
3. Save:
/Etc/rc. d/init. d/iptables save
4. view the opened Port:
/Etc/init. d/iptables status
5. Restart
5.1/etc/init. d/iptables restart (temporarily valid)
5.2 chkconfig iptables off/on (permanently valid)
The preceding steps show how to add a port.
Try Telnet now. First, check whether listening is enabled on the CentOS local netstat-lnpt port. If listening is enabled, try it.
If it is not successful, perform the following steps:
Ii. Restart Port
Run the command:/etc/init. d/sshd restart
Many links are based on ssh connections, so you need to restart them through sshd.
Then, run netstat-lnpt to check the port listening status.
Telnet successful!
The above is my experience and hope to solve your problem. Thank you!
Tips: The ntsysv command has a surprise.