In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains "linux how to check which ports are open". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "linux how to check which ports are open".
Linux view open port method: 1, use rpm to install nmap tool, execute "nmap 127.0.0.1" command to view the open port of this machine; 2, execute "netstat-anp" command to view open port.
The operating environment of this tutorial: linux5.9.8 system, Dell G3 computer.
Linux to see which ports are open
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 the rpm installation shown 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 setting. # 1:nmap # [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 37017186Preparing... # [100%] 1:nmap-frontend # [100%] [root@DB-Server Server] #
With regard to the use of nmap, you can write long capitals, which will not be expanded here. As shown below, nmap 127.0.0.1 looks at the ports open on this machine and scans all ports. Of course, you can also scan other server ports.
[root@DB-Server Server] # nmap 127.0.0.1 Starting Nmap 4.11 (http://www.insecure.org/nmap/) at 2016-06-22 15:46 CSTInteresting ports on localhost.localdomain (127.0.0.1): Not shown: 1674 closed portsPORT STATE SERVICE22/tcp open ssh25/tcp open smtp111/tcp open rpcbind631/tcp open ipp1011/tcp open unknown3306/tcp open mysql Nmap finished: 1 IP address (1 host up) scanned in 0.089 secondsYou have new mail in / Var/spool/mail/root [root@DB-Server Server] #
2:netstat tool detects open ports
You can use "netstat-anp" to see which ports are open.
(note: adding the parameter'- n 'will convert the application to port display, that is, addresses in numeric format, such as: nfs- > 2049, ftp- > 21, so you can open two terminals, one by one corresponding to the port number of the program)
Expansion: check if the port is open
Lsof tool detects open ports
[root@DB-Server Server] # service mysql startStarting MySQL. [OK] [root@DB-Server Server] # lsof-i:3306COMMAND PID USER FD TYPE DEVICE SIZE NODE NAMEmysqld 7860 mysql 15u IPv6 44714 TCP *: mysql (LISTEN) [root@DB-Server Server] # service mysql stopShutting down MySQL.. [OK] [root@DB-Server Server] # lsof-iOK 3306 [root@DB-Server Server] #
[root@DB-Server Server] # lsof-I TCP | fgrep LISTENcupsd 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)
Use telnet to check if the port is open
Even if the server port is in the listening state, the firewall iptables blocks the port, so it is impossible to detect whether the port is open by this method.
The netcat tool detects whether the port is open
[root@DB-Server ~] # nc-vv 192.168.42.128 1521Connection 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 published 0 [root@DB-Server ~] # nc-vv 192.168.42.128 1433nc: connect to 192.168.42.128 port 1433 (tcp) failed: No route to host Thank you for reading, this is the content of "how to check which ports are open by linux", after the study of this article I believe that you have a deeper understanding of the question of how to view which ports are open in linux, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.