skip to Main Content

I am using Debian 10 as a MySQL server and I have opened my firewall on port 3306 TCP to allow some others to connect to databases on the MySQL server. At the moment port 3306 is open to all but I want to only open this for fixed IP’s. Now how can I see the IP’s that are connected to my MySQL on port 3306?
I made a testscript and ran if from somewhere else, it connects ok and retrieves all MySQL data but netstat or nmap is not showing that connection at all.

2

Answers


  1. Chosen as BEST ANSWER

    I found a solution by using tcpdump and filter on port 3306. This works fine.


  2. This is a solution for netstat.

    netstat -tn 2>/dev/null | grep :3306 | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -nr | head
    

    It shows the ip’s connected as well as the number of connections by that same ip.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search