0

I am trying to send one message from one computer in my home LAN to another in the same LAN using netcat. This is the code I am running in bash: In PC1

nc -l -p 31337

In PC2 (Private IP Address 192.168.1.10)

nc 192.168.1.10 31337

The problem is that when I send a message in one terminal, nothing seems to appear on the other PC and vice versa. Doing the same thing on the same PC, but with two terminal windows open, everything works fine. However there is no point in sending one message from one terminal to another in the same computer. What I want is to send from one PC in my home LAN to another.

PS I am working on Ubuntu 16.04.4 on both PCs

  • 1
    are you running a firewall on either system? What do you get when you run nc -vvv ...? – Patrick Apr 28 '18 at 4:25
0

The way you test this is:

1) Open a second window both on PC1 and PC2, start tcpdump or wireshark on the LAN interface, e.g. tcpdump -ni eth0.

2) Do a ping from PC1 to PC2, and from PC2 to PC1. See if you get ping replies, verify you can see the packets in the dump.

If you can't see the ping replies, something in your network setup is broken. Find it and fix it.

3) Now use nc, again observe the packets. Depending on the outcome, you now have an idea where the problem is.

  • Ok these are the results of what I changed. – Jack D. Apr 28 '18 at 8:01
  • First of all I connected both PCs into another LAN network. This time netcat worked but only if the listener was the 2nd PC and the sender the 1st PC (and indeed I could ping PC2 from PC1 but not the opossite). Then I opened wireshark on PC1 and tryed pinging it from PC2, with the results being "Destination Host Unreachable" and on wireshark I see a lot of ARP requests "Who has 192.168.1.10(PC1 IP)?Tell 192.168.1.4 (PC2 IP)" – Jack D. Apr 28 '18 at 8:12
  • Please edit question with new information; don't put it in the comments (comments may be deleted by the system at some stage). This looks like something in your LAN configuration is screwed up (firewall on the router?), so you must investigate your routers/your setup. – dirkt Apr 28 '18 at 10:09
0

The problem was that my Windows Firewall was blocking inbound requests to port 31337 (the code in the PC was running on Linux Subsystem for Windows). So you have to go to Control Panel -> System and Security -> Windows Defender Firewall and choose Advanced Settings. There make a new inbound rule to allow requests to port 31337.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.