Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to check whether a port is open in a remote Linux system

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article will explain in detail how to check whether a port in a remote Linux system is open, Xiaobian thinks it is quite practical, so share it for everyone to make a reference, I hope you can gain something after reading this article.

This is a very important topic, not only for Linux administrators, but also for all of us. I mean it's also useful for users working in the IT infrastructure industry to understand this topic. They need to check whether a port is open on the Linux server before proceeding further.

If the port is not opened, they will ask the Linux administrator to open it. If this port is already open, we need to discuss with the application team what to do next.

We'll show you 3 ways to check if a port is open.

This goal can be achieved using the following Linux commands:

nc

nmap

telnet

How to use nc (netcat) command to check if a port is open on a remote Linux system?

NC stands for NetCat. netcat is a simple Unix utility that uses TCP or UDP protocols to read and write data between network connections.

It is designed to be a trusted backend tool that can be used directly or simply invoked by other programs or scripts.

At the same time, it's also a feature-rich network debugging and exploration tool, as it can create almost any type of connection you need, and it also has several interesting features built in.

Netcat has three functional modes: connect mode, snoop mode and tunnel mode.

General syntax for nc (netcat) command:

$ nc [-options] [HostName or IP] [PortNumber]

In the following example, we will check whether port 22 is open on a remote Linux system.

If the port is open, you will get output similar to the following.

# nc -zvw3 192.168.1.8 22Connection to 192.168.1.8 22 port [tcp/ssh] succeeded!

Detailed command:

nc

z

v

w3

192.168.1.8

22

When it detects that the port is not open, you will get the following output:

# nc -zvw3 192.168.1.95 22nc: connect to 192.168.1.95 port 22 (tcp) failed: Connection refused

How do I use the nmap command to see if a port is open on a remote Linux system?

nmap ("Network Mapper") is an open source tool for network discovery and security auditing designed to quickly scan large networks, although it works equally well for individual hosts.

In a novel way, nmap uses bare IP packets to determine whether hosts in a network are reachable, what services they are providing (application name and version number), what operating system they are running on (version of the system), what packet filtering software or firewall they are using, and other additional features.

Although nmap is commonly used for security audits, many system and network administrators find it useful for routine tasks such as listing network assets, managing service upgrade schedules, and monitoring host or service health.

General syntax of nmap:

$ nmap [-options] [HostName or IP] [-p] [PortNumber]

If the port is open, you will get the following output:

# nmap 192.168.1.8 -p 22Starting Nmap 7.70 ( https://nmap.org ) at 2019-03-16 03:37 IST Nmap scan report for 192.168.1.8 Host is up (0.00031s latency).PORT STATE SERVICE22/tcp open ssh

Nmap done: 1 IP address (1 host up) scanned in 13.06 seconds

If the port is not open, you will get something like this:

# nmap 192.168.1.8 -p 80Starting Nmap 7.70 ( https://nmap.org ) at 2019-03-16 04:30 ISTNmap scan report for 192.168.1.8Host is up (0.00036s latency).PORT STATE SERVICE80/tcp closed httpNmap done: 1 IP address (1 host up) scanned in 13.07 seconds

How do I use telnet to see if a port is open on a remote Linux system?

The telnet command is used to interactively communicate with another host via the TELNET protocol.

General syntax of telnet command:

$ telnet [HostName or IP] [PortNumber]

If the probe succeeds, you will see output similar to the following:

$ telnet 192.168.1.9 22Trying 192.168.1.9... Connected to 192.168.1.9.Escape character is '^]'.SSH-2.0-OpenSSH_5.3^]Connection closed by foreign host.

If the probe fails, you will see output similar to the following:

$ telnet 192.168.1.9 80Trying 192.168.1.9... telnet: Unable to connect to remote host: Connection refused

Currently, we have only found the above 3 ways to check if a port is open on a remote Linux system. If you find another way to achieve the same goal, please let us know in the comment box below.

About "how to check whether a port in a remote Linux system is open" this article is shared here, I hope the above content can be of some help to everyone, so that you can learn more knowledge, if you think the article is good, please share it for more people to see.

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report