I have two linux machines connected via ethernet. I tried to test sending packets from one to the other using netcat. On the listening machine I used the following command:
nc -l 10000
nc -4u <ip address of listening machine's ethernet port> 10000
Turns out the problem was with the netcat listener. By default, the
-l command listens for TCP packets. I was sending UDP packets (the
-u command). The "
connection refused" message stemmed from the fact that the netcat sender did not have anything listening to it on the other machine. Not sure why this is the case, but from my experiments netcat will give you a "
connection refused" message if you don't have a netcat listener that receives the packets from your netcat sender.
Anyways, the command on the receiving machine that worked was:
nc -4ul 10000