I've got an rsync daemon running on an android phone. I just want to netcat the rsync port on the phone (configured on 1873), to verify the daemon is up and listening to the port, but strangely the netcat attempt is rejected.
Rsync is working fine, it's syncing files between the phone and Ubuntu box, so there is no firewall or any other network issue blocking traffic.
Rsync daemon is listening on the port:
cepheus:/ $ netstat -ltnp 2> /dev/null | grep 1873
tcp 0 0 127.0.0.1:1873 0.0.0.0:* LISTEN 2992/rsync
So why is the connection refused?
$ nc -zv 192.168.1.100 1873
nc: connect to 192.168.1.100 port 1873 (tcp) failed: Connection refused
The below is just for additional background, I hope it doesn't muddy the waters. My expectation is that if a tcp port is in "listening" mode, netcat -zv should succeed given no firewall/network issues.
The rsync daemon is started via adb like so:
adb -s 192.168.1.100:5555 shell -t '/data/local/tmp/rsync --daemon --no-detach --config=/data/local/tmp/rsyncd.conf --log-file=/proc/self/fd/2'
And the local port 6010 on my ubuntu box is port forwarded to 1873 on the phone.
$ adb forward --list
192.168.1.100:5555 tcp:6010 tcp:1873
The check on the adb port works fine for instance.
$ nc -zv 192.168.1.100 5555
Connection to 192.168.1.100 5555 port [tcp/*] succeeded!
~
Update
$ nc -zv localhost 6010
nc: connect to localhost port 6010 (tcp) failed: Connection refused
Connection to localhost 6010 port [tcp/*] succeeded!
The connection attempt does actually succeed as verified in the daemon logs when setting the destination ip to localhost. The problem is that nc outputs exactly the same two lines when the daemon is down, and port closed.
Whilst Tom's answer does work, I'd rather not have the daemon listening on 0.0.0.0
.
I've tried setting the source port to local rsync port, but it just results in a bind error when using 127.0.0.1 or Connection refused when setting it to internal ip address of the Ubuntu box:
$ nc -zv 192.168.1.100 1873 -s 127.0.0.1 -p 6010
nc: bind failed: Address already in use