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?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.
Sign up to join this communityI 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?
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