Score:0

How to allow an ip address to access a specific port on the server without blocking other traffic

jp flag

First off, am using Firewalld and my configuration is as follows:

  • All traffic is allowed (nothin fancy).
  • Server has MySQL and Apache2 (Linux Debian)

I need to allow MySQL remote connections to a specific ip address (my ip) without shutting out http connections. The MySQL config file only allows one ip and thus I can't directly add my ip there cuz then Apache2 won't be able to connect over http that's why am looking for a firewall solution.

I have also tried creating a specific zone using firewalld (firewall-cmd) but the zone ended up blocking all http traffic since it had a source ip and thus ended up here.

Any help is greatly appreciate.

Score:0
us flag

Opening MySQL port anywhere outside is a security risk and I prefer to avoid it.

I would leave MySQL listening to localhost and instead use SSH port forwarding to access MySQL remotely:

  1. Run ssh -L 3306:localhost:3306 [email protected] on the remote machine
  2. On remote machine, use localhost as the MySQL server.

If you need to have the SSH connection on all the time, then you can use a tool autossh which keeps the SSH connection open and automatically reconnects if it is disconnected at some point.

Dennisrec avatar
jp flag
I get the idea but how would you apply that approach in PHP or Python.?
us flag
You need to run the SSH connection in the background, and in PHP / Python DB connector use localhost port 3306 as the server address.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.