Disconnected Netcat Connection

I have two Linux machines connected via Ethernet. I tried to verify that packets were being sent from one to the other using netcat. On the listening machine, I used the following command:

nc -l 10000 

On the sending machine, I used:

 nc -4u <ip address of listening machine ethernet port> 10000 

When I tried to send something, I would get the following message: "nc: Write error: no host path"

When searching for a problem, I found suggestions for temporarily disabling the firewall. I did this with the commands:

 /etc/init.d/iptables save /etc/init.d/iptables stop 

However, now when I try to send from one machine to another, I get the following message: "nc: Write error: connection rejected"

Any ideas what is going on?

+4
source share
1 answer

Turns out the problem is with the netcat listener. By default, the -l listens for TCP packets. I sent UDP packets ( -u command). The “ connection refused ” message came from the fact that the sender netcat was not listening on another computer. Not sure why this is, but from my experiments, netcat will give you a " connection refused " message if you don't have a netcat listener that receives packets from your netcat sender.

In any case, the command on the host machine that worked was:

 nc -4ul 10000 
+5
source

Source: https://habr.com/ru/post/1493242/


All Articles