Our features site is undergoing a refresh! Be sure to explore the revamped site and discover our latest product roadmap launching here on Monday, March 18th.

cPanel and Remote MySQL Server should be able to use private IPs

Jeff Nolan shared this idea 10 years ago
Open Discussion

Typically the cPanel server is public-facing which means it's hostname resolves to a public IP address. There is a strong use case to want to connect a remote MySQL server using a private network interface. However, the MySQL server can only resolve the cPanel server's hostname to it's public IP address which means the DB user accounts created on the MySQL server are given grants to the wrong IP address.


The work-around is to grant privileges on the private IP address manually. But in a shared hosting environment where accounts can be provisioned automatically this would pose a problem. It would useful for cPanel to support remote connections to MySQL using private IPs.

Best Answer
photo

This functionality can be achieved without the need to manually add new grants each time a new account/MySQL user is provisioned.


The deployment would be to modify /etc/hosts on the MySQL Remote Server such that the resolution is forced for the MySQL Remote Server to resolve the cPanel & WHM server's hostname to the private IP desired. This would solve the issue such that the /etc/hosts file change is the only change necessary. No further modifications are required.


Example:


cPanel & WHM server with hostname 'server.hosting.com', public IP 123.123.123.123, and private ip 192.168.0.1

MySQL Remote Server with private ip 192.168.0.2


On the MySQL Remote Server, /etc/hosts would be modified to include:


192.168.0.1 server.hosting.com


This does not resolve the fact that the public IP will still receive a grant, but the hostname based grant will be applicable.


In other words, this is not a solution for this feature request -- but a potential temporary workaround in the interim.

Replies (2)

photo
1

This functionality can be achieved without the need to manually add new grants each time a new account/MySQL user is provisioned.


The deployment would be to modify /etc/hosts on the MySQL Remote Server such that the resolution is forced for the MySQL Remote Server to resolve the cPanel & WHM server's hostname to the private IP desired. This would solve the issue such that the /etc/hosts file change is the only change necessary. No further modifications are required.


Example:


cPanel & WHM server with hostname 'server.hosting.com', public IP 123.123.123.123, and private ip 192.168.0.1

MySQL Remote Server with private ip 192.168.0.2


On the MySQL Remote Server, /etc/hosts would be modified to include:


192.168.0.1 server.hosting.com


This does not resolve the fact that the public IP will still receive a grant, but the hostname based grant will be applicable.


In other words, this is not a solution for this feature request -- but a potential temporary workaround in the interim.

photo
1

Just query a host that returns your IP address:

$externalContent = file_get_contents('http://checkip.dyndns.com/');

preg_match('/Current IP Address: \

Leave a Comment
 
Attach a file