Linux operating system tests whether the remote port is up to or if the native port is open method __linux

Source: Internet
Author: User
Tags redis

In this guide, we will show you how to use the simple Netcat (NC) command to determine if the port on the remote host is accessible/open.

Netcat (or NC) is a powerful and Easy-to-use program that can be used in Linux for anything related to TCP, UDP, or UNIX domain sockets.

# yum Install NC                  [in Centos/rhel]
# DNF Install NC                  [in Fedora 22+]
$ sudo apt-get install     [in In Debian/ubuntu]

We can use it to open a TCP connection, listen on arbitrary TCP and UDP ports, send UDP packets, and port scans in IPV4 and IPV6.

With Netcat, you can check for a single or multiple open port range, as shown below. The following command will help us see if Port 22 is open on the host 192.168.22.43:

Nc-zv 192.168.22.43
Connection to 192.168.22.43 Port [Tcp/ssh] succeeded!
The results that are not open are:

Nc-zv 192.168.22.43 6380
nc:connect to 192.168.22.43 Port 6380 (TCP) Failed:connection refused

In the above commands, these flags are:

-Z-----------Setting up the NC simply scans the listening daemon and does not actually send any data to them.

-v-----------Enable verbose mode


The following command checks to see if ports 80, 22, and 21 are turned on on the remote host 192.168.56.10:

Nc-zv 192.168.56.10 80 22 21

You can also specify the range of port scans:

$ nc-zv 192.168.56.10 20-80
If you need to check whether a port on this machine is open, simply replace the IP address with the local IP, and the port is changed to the port you want to test.


To see if the native port is occupied

Netstat-ap | grep 6380
TCP        0      0 localhost:6380          *:*                     LISTEN      1280/redis-server 1
tcp        0      0 localhost:16380         *:*                     LISTEN      1280/redis-server 1



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.