Signup/Sign In
Ask Question
Not satisfied by the Answer? Still looking for a better solution?

Run a shell script upon connection to port 445

My machine currently has port 445 open to the internet. I'm looking to see how frequent scans of this port are and I plan to achieve that by running a shell script when someone connects to this port. How could I do this with IPtables? I'm using Debian 10.

1 Answer

The solution to your problem is very old, but doesn't involve iptables. It's called the inetd super-server. Its configuration - /etc/inetd.conf - lets you define the port and protocol to listen for - the "service", defined in /etc/services - and the program to execute in case of a connection - which could be your logging script.

The service would be
microsoft-ds    445/tcp                         # Microsoft Naked CIFS

Login / Signup to Answer the Question.