Skip to main content

MySQL Remote Access Hosts With Range

Comments

10 comments

  • Infopro
    Seems to me those IP ranges are to be added to your firewall, CSF for example.
    0
  • rinkleton
    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.
    0
  • Infopro
    I'm unable to assist you with this other than digging up this thread for you on google: Unable to connect DataStudio to MySQL data on host... - Page 2 - The Google Advertiser Community - 644779 Looks like a good place to start. HTH!
    0
  • rinkleton
    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.
    0
  • cPanelMichael
    Hello @rinkleton, You can use the percent symbol as a wildcard. EX: 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: uapi --user=username Mysql add_host host=192.168.%25.%25
    Thank you.
    0
  • rinkleton
    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.
    0
  • cPanelMichael
    Hello, This is a MySQL limitation. The following MySQL document explains the full set of host options you can use (you need to scroll down a bit): MySQL :: MySQL 5.6 Reference Manual :: 6.2.3 Specifying Account Names Let us know if this helps. Thank you.
    0
  • rinkleton
    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.
    0
  • Dean Silky Ocean Studios
    Hi Rinkleton, Did you get this working. I'm trying to set up the same thing and not getting very far. Thx
    0
  • rinkleton
    Hi Rinkleton, Did you get this working. I'm trying to set up the same thing and not getting very far. Thx

    I did. Here was my steps as far as I remember:
    • 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)
    • 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)
    • 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.
    0

Please sign in to leave a comment.