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

Is there a Tcping port connection detection tool similar to that in Windows system in Linux?

2025-04-11 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article mainly explains "is there any Tcping port connection detection tool in Linux similar to that in Windows system", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "is there any Tcping port connection detection tool similar to that in Windows system in Linux?"

1. Introduction to nc command

NetCat, known as the "Swiss Army knife" among web tools, has versions of Windows and Linux. Because of its short and practical functions, it is designed as a simple and reliable network tool that can transmit read and write data through TCP or UDP protocols. At the same time, it is also a network application Debug analyzer because it can create different types of network connections as needed.

Introduction to netcat

Take the minimum installation version of CentOS7.5 as an example. By default, the system does not integrate the nc toolset, so you need to install it manually:

[root@zcwyou ~] # yum install-y nmap-ncat

two。 Test whether the TCP80 port of 192.168.1.1 can connect properly

[root@zcwyou] # nc-v-w 1 192.168.1.1-z 80

Ncat: Version 7.50

Ncat: Connected to 192.168.1.1:80.

Connected indicates that the connection was successful.

Linux uses the netcat command to detect whether the TCP80 port can connect properly.

Try to connect to port 81

[root@zcwyou] # nc-v-w 1 192.168.1.1-z 81

Ncat: Version 7.50

Ncat: Connection refused.

Connection refused. The connection is rejected, indicating that port 81 is not open or the intermediate firewall does not allow port 81.

3. Transfer files using nc

Most of the time, we are trying to transfer files through the network or other tools. There are many ways, such as FTP,SCP,SMB, etc., but when you only need to transfer files temporarily or at once, it's really worth wasting time installing and configuring software to your machine. Suppose you want to send a file zcwyou.txt from A to B. Either An or B can be used as a server or a client. Below, let A be the server and B the client.

Server side configuration

[root@zcwyou ~] # nc-l 1567

< zcwyou.txt Client [root@zcwyou ~]# nc -n 172.31.100.7 1567 >

Zcwyou.txt

Principle: the server inputs zcwyou.txt into nc, which is sent by nc, and the client receives the message through nc and saves it to zcwyou.txt.

4. Clone a hard disk or partition

Perform a similar listening action on server2, that is, redirect the received data to dd:

[root@zcwyou ~] # nc-l-p 1234 | dd of=/dev/sda

The data after dd is redirected to nc on server1, that is, the data is sent.

[root@zcwyou ~] # dd if=/dev/sda | nc 192.168.200.27 1234

Note: cloning of hard drives or partitions should not be done on systems that are already mount.

5. Specify source port

Assuming that your firewall filters all ports except port 25, you need to use the-p option to specify the source port.

Open listening on the server side:

[root@zcwyou ~] # nc-l 1567

Client sends data, destination port 1567, source port 25

[root@zcwyou] # nc 172.31.100.7 1567-p 25

Root permission is required to use a port less than 1024.

This command will open port 25 on the client side for communication, otherwise a random port will be used.

6. Specify source address

Use the-s option to specify the source ip address.

The server turns on listening and redirects zcwyou.txt to nc.

[root@zcwyou] # nc-u-l 1567

< zcwyou.txt 客户端 [root@zcwyou ~]# nc -u 192.168.100.1 1567 -s 192.168.88.20 >

File.txt

When the server has more than one IP, specify 192.168.88.20 as the source IP.

7. Directory transfer

It's easy to send a file, but if we want to send multiple files, or an entire directory, it's just as simple as using the compression tool tar to send the package after compression.

If you want to transfer a directory over the network from A to B.

On the Server side, package the abc directory and redirect to nc.

[root@zcwyou ~] # tar-cvf-abc | nc-l 1567

On the Client side, the data is received through nc and unpacked by tar.

[root@zcwyou ~] # nc-n 172.31.100.7 1567 | tar-xvf-

If you want to save bandwidth, we can use bzip2 or other tools to compress the package.

The Server side compresses the directory abc through bzip2 and redirects it to nc, listening on port 1567.

[root@zcwyou ~] # tar-cvf-abc | bzip2-z | nc-l 1567

The Client end passes the received data to bzip2 and tar for processing.

[root@zcwyou ~] # nc-n 172.16.26.88 1567 | bzip2-d | tar-xvf-

8. Encrypt the data you send over the network

If you are worried about the security of sending data over the network, you can use tools such as mcrypt to encrypt your data before sending it.

On the server side, use mcrypt tools to encrypt data.

[root@zcwyou ~] # nc localhost 1567 | mcrypt-flush-bare-F-Q-d-m ecb > zcwyou.txt

The client uses the mcrypt tool to decrypt the data.

Mcrypt-flush-bare-F-Q-m ecb < zcwyou.txt | nc-l 1567

The above two commands prompt for a password to ensure that both sides use the same password.

Here we are using mcrypt for encryption, using any other encryption tool.

9. Transport stream video

It's not the best way to generate streaming video, but if we don't have a specific tool on the server and use netcat, we can still hope to do it.

The server reads a video file and redirects it to the netcat client.

[root@zcwyou ~] # cat video.avi | nc-l 1567

The client reads the content through nc and hands it to the mplayer player.

[root@zcwyou ~] # nc 172.31.100.7 1567 | mplayer-vo x11-cache 3000-

10. Use the UDP protocol

By default, only the TCP port is connected when nc creates a connection. However, we can use the-u option to connect to the UDP port.

[root@zcwyou] # ncat-l-u 8888

The udp 8888 port is open, then use netstat to verify that the port is open.

[root@zcwyou ~] # netstat-tunlp | grep 1234

Udp 0 0 0.0.0.0 1234 0.0.0.015 * 17341/nc

Udp6 0 0: 1234: * 17341/nc

Test the UDP port of a server, such as checking whether Ali DNS server 223.5.5.5 is available locally

[root@zcwyou] # nc-v-u 223.5.5.5 53

Ncat: Version 7.50

Ncat: Connected to 223.5.5.5:53.

The display of Connected indicates a successful connection to the remote DNS port and the DNS is working properly.

Linux uses the UDP port of the netcat test server

11. Other uses

Use the-t option to simulate the Telnet client:

HTTP client is used to download files

Connect to the mail server and check messages using the SMTP protocol

Capture the screen using ffmpeg and share it through streaming, and so on. There are other more uses.

At this point, I believe you have a deeper understanding of "whether there is a Tcping port connection detection tool in Linux similar to that in Windows system". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

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