In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article "Linux system how to check whether the port is open" in addition to the program members most people do not understand, today Xiaobian in order to let everyone better understand "Linux system how to check whether the port is open", to give you a summary of the following content, with certain reference value, detailed steps clear, details properly handled, I hope everyone through this article to gain something, let's take a look at the specific content.
1: nmap tool detects open ports nmap is a tool for network scanning and host detection. The installation of nmap is very simple, as shown in rpm installation below.
[root@DB-Server Server]# rpm -ivh nmap-4.11-1.1.x86_64.rpm warning: nmap-4.11-1.1.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 37017186 Preparing... ########################################### [100%] 1:nmap ########################################### [100%] [root@DB-Server Server]# rpm -ivh nmap-frontend-4.11-1.1.x86_64.rpm warning: nmap-frontend-4.11-1.1.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 37017186 Preparing... ########################################### [100%] 1:nmap-frontend ########################################### As shown below, nmap 127.0.0.1 looks at the open ports of this machine and scans all ports. Other server ports can also be scanned.
[root@DB-Server Server]# nmap 127.0.0.1 Starting Nmap 4.11 ( http://www.insecure.org/nmap/ ) at 2016-06-22 15:46 CST Interesting ports on localhost.localdomain (127.0.0.1): Not shown: 1674 closed ports PORT STATE SERVICE 22/tcp open ssh 25/tcp open smtp 111/tcp open rpcbind 631/tcp open ipp 1011/tcp open unknown 3306/tcp open mysql Nmap finished: 1 IP address (1 host up) scanned in 0.089 seconds You have new mail in /var/spool/mail/root [root@DB-Server Server]#
2: netstat tool detects open ports [root@DB-Server]# netstat -anlp| grep :3306 tcp 0 0 :::3306 :::* LISTEN 7358/mysqld [root@DB-Server Server]# netstat -anlp | grep :22 tcp 0 0 :::22 :::* LISTEN 4020/sshd tcp 0 52 ::ffff:192.168.42.128:22 ::ffff:192.168.42.1:43561 ESTABLISHED 6198/2 [root@DB-Server Server]#
As shown above, this tool feels less concise than nmap. Of course, it is not as powerful as nmap.
3: lsof tool detects open ports [root@DB-Server]# service mysql start MySQL... [ OK ] [root@DB-Server Server]# lsof -i:3306 COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME mysqld 7860 mysql 15u IPv6 44714 TCP *:mysql (LISTEN) [root@DB-Server Server]# service mysql stop Shutting down MySQL.. [ OK ] [root@DB-Server Server]# lsof -i:3306 [root@DB-Server Server]#
[root@DB-Server Server]# lsof -i TCP| fgrep LISTEN cupsd 3153 root 4u IPv4 9115 TCP localhost.localdomain:ipp (LISTEN) portmap 3761 rpc 4u IPv4 10284 TCP *:sunrpc (LISTEN) rpc.statd 3797 rpcuser 7u IPv4 10489 TCP *:1011 (LISTEN) sshd 4020 root 3u IPv6 12791 TCP *:ssh (LISTEN) sendmail 4042 root 4u IPv4 12876 TCP localhost.localdomain:smtp (LISTEN)4: Use telnet to detect whether the server port is open. Even if it is in the listening state, the firewall iptables block the port, so it is impossible to detect whether the port is open by this method.
5: The netcat tool detects whether the port is open. [root@DB-Server ~]# nc -vv 192.168.42.128 1521 Connection to 192.168.42.128 1521 port [tcp/ncube-lm] succeeded! [root@DB-Server ~]# nc -z 192.168.42.128 1521; echo $? Connection to 192.168.42.128 1521 port [tcp/ncube-lm] succeeded! 0 [root@DB-Server ~]# nc -vv 192.168.42.128 1433 nc: connect to 192.168.42.128 port 1433 (tcp) failed: No route to host Close port and Open port
Closed port and open port should be two different concepts, each port has a corresponding service, so to close the port, as long as the corresponding service can be closed. Like the following example, MySQL service is enabled, port 3306 is in listening state, after MySQL service is disabled, port 3306 is naturally closed.
[root@DB-Server Server]# service mysql start Starting MySQL...... [ OK ] [root@DB-Server Server]# lsof -i:3306 COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME mysqld 7860 mysql 15u IPv6 44714 TCP *:mysql (LISTEN) [root@DB-Server Server]# service mysql stop Shutting down MySQL.. [ OK ] [root@ DB-Server]# lsof -i:3306 [root@DB-Server]#What is Linux is a free-to-use and freely distributed UNIX-like operating system. Linux is a POSIX-based multiuser, multitasking, multithreaded and multiCPU operating system that can run major Unix tools, applications and network protocols.
Thank you for reading, I hope you have a certain understanding of the key issue of "how to check whether the port is open in Linux system". The specific use situation still needs to be used by everyone to understand it. Try it quickly. If you want to read more articles related to knowledge points, please pay attention to the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.