1

I have opened a service:

nc -l -p 1234 -e service.sh

If someone connects to this service.

nc xxx.xxx.xxx.xxx 1234

Can this connection be found in any Linux log file?

  • if some answer helps you, kindly accept it by clicking the check mark. That'll contribute some reputation to both of you – phuclv Feb 15 at 17:18
1

No, network connections are not logged by Linux by default. You can view current connections with a variety of tools, e.g. sudo lsof -P -n -i, but the system does not keep a history of network connections--that's up to the application. Web servers, ssh, mail servers, etc. all do this in their own ways, but nc is designed more for testing than production and does not have logging. If you want to log nc connections, you could use iptables or network sniffing tools or add logging to service.sh.

As an additional assurance that the connection is not being logged by the system, use a unique port number, e.g. nc -l -p 58404 -e service.sh, make a connection to this from another computer, and then search through all of your system logs for that port number:

sudo find /var/log -type f -exec zcat -f {} + |grep 58404
sudo journalctl |grep 58404

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.