Netcat cannot work as server on OpenWrt

I have a machine server1 installed ubuntu and machine server2 installed openwrt.
on the server2, I use it as server to listen port 248.And type the command as fallows.

netcat -l -p 248

on the server1, used as client,and I typed command

netcat 248

And it cannot work, these has no connection.
The ip addr of sever1 is and the server2 is
they can ping or ssh to another,and the firewall is disable.
The netcat in openwrt is 0.7.1,not a busy-box's nc.
could you help me,please.

I might not be able to help much but a quick test worked for me. I started a listener on my r4s router using the full netcat and sent data to it with nc from my eap225, piping the output from echo to nc. The data shows on my terminal screen on the r4s.:

root@R4S-wrt:~# netcat -l -p 2000
root@EAP225-wrt:~# echo "Hello" |nc 2000

The receiving netcat terminated with the end of input as expected.

A second test of just the netcat and nc commands let me type lines of text in both directions.

I'm running OpenWrt 22.03.3 on both.

Did you send data to the netcat pipe in your command or use another technique to connect your input data?

If your setup still is not working, try using tcpdump to see what shows up on the interface of the sender and receiver.

Good luck!

Thanks for your reply.
I use the same way (netcat -l -p xxx) as you on my router running OpenWrt, but when I send some data from the ubuntu , it failed.
The information shows on the ubuntu is "netcat : connect : Connectiion refused".
I try a way that set the openwrt as a client with "netcat addr port", and use the ubuntu to receive data, it successed.Both of them can send data to each other.
The problem just is the openwrt's netcat only can be a client to send data to the server which is listening.

If either OS is running as a virtual machine rather than on its own hardware, check the network and security settings of the virtualization software and the host os.

On OpenWrt, check that a listener is running with netstat -ln in a second ssh terminal session.

root@R4S-wrt:~# netstat -ln |grep 248
tcp        0      0   *               LISTEN      

(use the same port number in the grep command that you use in the netcat command.
The zeros in the address field indicates that it is listening on all local ip addresses.

If that shows listening on your configured port then I suspect that the firewall might not actually be disabled in OpenWrt or there may be outbound firewall rules on Ubuntu. The Connection refused message indicates that an icmp message was sent back rather than the packet being lost or dropped by a firewall.

With the addresses that you showed, it looks like it is not likely that there is another system in between that could be blocking but if there is, obviously check security settings on it.

tcpdump -ni any port 248 in a second ssh session on OpenWrt during a test might help prove where the rejection is occurring but you may need to install tcpdump if you have storage space.

Did you try other port numbers? Maybe there is something special with port 248 on your setup. netcat -l -p 248 did work on my OpenWrt router though.