Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

MySQL Remote Access Hosts With Range

Discussion in 'Database Discussion' started by rinkleton, Jan 11, 2018.

Tags:
  1. rinkleton

    rinkleton Well-Known Member

    Joined:
    Jul 16, 2015
    Messages:
    93
    Likes Received:
    3
    Trophy Points:
    8
    Location:
    Cleveland
    cPanel Access Level:
    Root Administrator
    I'm trying to integrate with Google Data Studios and they provide a list of IPs they will hit your MySQL database with, however, they are ranges. For example: 64.18.0.0/20.

    MySQL connector - Data Studio (Beta) Help

    I've tried using the API to add "64.18.0.0/20" or "64.18.0.0/255.255.240.0" but neither work. Is there any way to do this? The error I get is "The IP address/netmask is not valid."
     
  2. Infopro

    Infopro cPanel Sr. Product Evangelist
    Staff Member

    Joined:
    May 20, 2003
    Messages:
    16,170
    Likes Received:
    370
    Trophy Points:
    583
    Location:
    Pennsylvania
    cPanel Access Level:
    Root Administrator
    Twitter:
    Seems to me those IP ranges are to be added to your firewall, CSF for example.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. rinkleton

    rinkleton Well-Known Member

    Joined:
    Jul 16, 2015
    Messages:
    93
    Likes Received:
    3
    Trophy Points:
    8
    Location:
    Cleveland
    cPanel Access Level:
    Root Administrator
    But that's in addition to setting up MySQL access hosts right? Just because I allow some IPs through the firewall doesn't necessarily mean MySQL will permit the connection is my understanding.
     
  4. Infopro

    Infopro cPanel Sr. Product Evangelist
    Staff Member

    Joined:
    May 20, 2003
    Messages:
    16,170
    Likes Received:
    370
    Trophy Points:
    583
    Location:
    Pennsylvania
    cPanel Access Level:
    Root Administrator
    Twitter:
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. rinkleton

    rinkleton Well-Known Member

    Joined:
    Jul 16, 2015
    Messages:
    93
    Likes Received:
    3
    Trophy Points:
    8
    Location:
    Cleveland
    cPanel Access Level:
    Root Administrator
    Let me just clarify that I'm asking if cpanel (API) can accept IP ranges in for MySQL access hosts, and if so, is there a limit on the ranges and what format does it need to be in? Is that something you can help with?

    What I am not looking for is help connecting Google Data Studios. I just mentioned it so it's understood why I'm asking.
     
  6. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    43,711
    Likes Received:
    1,794
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello @rinkleton,

    You can use the percent symbol as a wildcard. EX:

    Code:
    uapi --user=username Mysql add_host host=192.168.%.%
    Note that while it's not necessarily required for this UAPI function via the command line, it's good practice to URI encode values when using our API:

    Code:
    uapi --user=username Mysql add_host host=192.168.%25.%25
    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  7. rinkleton

    rinkleton Well-Known Member

    Joined:
    Jul 16, 2015
    Messages:
    93
    Likes Received:
    3
    Trophy Points:
    8
    Location:
    Cleveland
    cPanel Access Level:
    Root Administrator
    So 192.168.0.% would be equivalent to 192.168.0.0/24 and 192.168.%.% would be 192.168.0.0/16 right?

    So if I need a /20 I'd have to do 192.168.%.% which opens up more IPs than what I want.... but that probably should be fine because I'll also have to set firewall exceptions which should accept the ips in ranges rather than wildcards.

    I guess I'm curious if this is a mysql limitation or an API limitation.
     
  8. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    43,711
    Likes Received:
    1,794
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  9. rinkleton

    rinkleton Well-Known Member

    Joined:
    Jul 16, 2015
    Messages:
    93
    Likes Received:
    3
    Trophy Points:
    8
    Location:
    Cleveland
    cPanel Access Level:
    Root Administrator
    Yep, thanks. The docs there seem to indicate they can take any subnet mask, but I guess that's not true. They can only take ones which fully allow or deny an A, B, C, or D block. IE: /24 and /16 work but not /19. So that was part of my confusion.
     
  10. Dean Silky Ocean Studios

    Joined:
    Feb 8, 2018
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    UK
    cPanel Access Level:
    Reseller Owner
    Hi Rinkleton,
    Did you get this working. I'm trying to set up the same thing and not getting very far.
    Thx
     
  11. rinkleton

    rinkleton Well-Known Member

    Joined:
    Jul 16, 2015
    Messages:
    93
    Likes Received:
    3
    Trophy Points:
    8
    Location:
    Cleveland
    cPanel Access Level:
    Root Administrator
    I did. Here was my steps as far as I remember:
    1. In your firewall add the IPs google provides exactly in the format they give. Don't forget to restart your firewall after. Example for CSF: "tcp:in:d=3306:s=64.18.0.0/20" (You only have to do this once per server)
    2. Set mysql access hosts for each of the IPs google gives you, but you have to do it in the mysql wildcard format. It doesn't exactly match up with the ranges google gives, but your firewall shouldn't allow them through in the first place. Example:
      64.18.%.%. (Do for each cpanel account you need to grant access to)
    3. Create new mysql user and give them select only permissions on the DB. (Do for each DB you need to grant access to)
    This should let GDS connect to your DB.
     
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice