We are upgrading an old database server but want to make sure we update code on all other servers connecting to it. I'm thinking of mirroring the network port and logging what IP addresses connect to the server. I thought of turning on logging on the server itself, but I don't want to affect its performance since it is still in production.
Are there any recommendations on software I could use to log the IP addresses? It can be Windows, Linux, FreeBSD, VM, LiveCD, or something else. As long as it works on an x86-compatible box, I should be able to get it running.
What OS is the database server itself running? If it's Linux, you could add a logging rule to the local firewall configuration with minimal impact on the server. Something along the lines of:
You can add
-m limit --limit 4/s
to limit this rule to logging only 4 times/second (etc.), which if the connection rate is high will prevent it from hogging all the IO. This will log lines to syslog that look like:The information you want is the
SRC=
field.If you set up a separate Linux (or FreeBSD) system to receive traffic from a mirror port, you can use
tcpdump
to record the ip addresses. Something like:This will match all packets to port yourdbport that have the SYN flag set (e.g., they are a new connection attempt). After running this for a file, you can extract IP addresses like this:
Which will produce lines like this:
Where the fields are:
Which means you can get just the source ip address like this:
The
sort -u
gives you a unique list of addresses.