IPTABLES - limit access to port 3306 to local ip block

I have a couple of machines on a lan I want those machines to be able to access port 3306 (mysql) on one of the machines, but I do not want outside to be able to see that port open
Len45Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

http:// thevpn.guruCommented:
iptables -A INPUT -p tcp --dport 3306 --source Ip.of.machine.A -j ACCEPT
add this rule as many times as needed and only the machines with this source IP will be able to access it. You need to provide more info if you want the exact rule.

I.e. are the client machines on the internet..does your server have a public IP,
0
hernst42Commented:
You can also add nets to the source like:

// allow following ip/hosts to connect:
// connections from the local machine
iptables -A INPUT -p tcp --dport 3306 --source 127.0.0.0/8 -j ACCEPT
//connections from the local lan
iptables -A INPUT -p tcp --dport 3306 --source 192.168.0.0/24 -j ACCEPT

// reject all other connections
iptables -A INPUT -p tcp --dport 3306 -j REJECT
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Len45Author Commented:
Thank you both

All machines are connected to Internet via NAT -- and are on a 192 LAN, so I like hernst42 answer since I can add all current and possible servers with two lines of code.  I will spllit points
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux Networking

From novice to tech pro — start learning today.