Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Linux CentOS 6 - IPTables

I would like to know what command line(s) I need to enter to determine what my MySQL port is, or rather what config file I could check. I know it's typically 3306 but I'm not 100% sure this is the case. It would just be nice to know how to check for future reference.

In addition, would it be possible to restrict that port to only accept my server's IP address? Or I guess what I'm asking is if I can set up IPTables to only allow my server to talk to my MySQL database and deny all other incoming IPs, etc.

When performing iptables -L I see this :

ACCEPT tcp -- anywhere anywhere tcp dpt:mysql

which I'm assuming isn't ideal. Forgive me if I'm too vague.

Edit: also forgive me if I'm asking too many questions.

share|improve this question

migrated from Dec 22 '11 at 17:21

This question came from our site for pro webmasters.

up vote 0 down vote accepted

Without checking config files, "netstat -pltn" is your friend. It Will tell you the process name and number of running tcp servers.

As for restrictions with iptables, after accepting valid connections you should drop the unwanted ones.

If you are connecting from the same machine, it's better to configure MySQL to bind to localhost.

share|improve this answer
The answer to… is quite good for this question. – itorres Dec 22 '11 at 17:31

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.