I am wondering what is the command/utility to have a real-time view of incoming IPs to my server, ideally along with the port and connected.
I am wondering what is the command/utility to have a real-time view of incoming IPs to my server, ideally along with the port and connected.
Use
pktstat -n
The pktstat source code is hosted on Debian's site, or you can get it from SourceArchive.com
For 'purdy' display, I'm partial to a tool called 'iptraf' that will do just what you mention, as well as per interface, and per port aggregates.
For core Linux tools, trusty netstat will do the trick...
Here is how to see all traffic coming to port 2222:
A
tcpdump
would show you that; if you just wanted a list of IPs, you could filter on SYN packets and only output the source IP address. Something like:Would get you the list of IPs, in realtime. You could also
tee
that to a file, and periodically do asort -u
on it to get a list of unique IP addresses that have sent connections your way.You can use
last
to get an idea where your connections are coming from:The results, now in chronological order look like this:
If you want more details, and your sysadmin no longer allows
netstat
, usess
:Once you get the output of one of the commands mentioned in other answers, you can use "watch" tool to have "real-time". For example, "watch -n 5 ps" will do the command "ps" each 5 seconds ("-n" argument). Replace "ps" with the command of interest, and you will get "monitoring". Or, just "tee" on file, as in another suggestion.