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!

block server access/connection to remote url

Discussion in 'General Discussion' started by MaxFein, Apr 2, 2018.

  1. MaxFein

    MaxFein Member

    Joined:
    Jul 29, 2015
    Messages:
    20
    Likes Received:
    2
    Trophy Points:
    3
    Location:
    Portland, Oregon
    cPanel Access Level:
    Root Administrator
    Hi, I'd like to block any access from my server to a specific url and am wondering the/a best way to go about this?

    I have root access to my fully-managed VPS.

    My host said that they add the url to be blocked by iptables.

    However, looking online about using iptables this way shows that it can work but is perhaps not the best way... one person on serverfault put it this way:
    " It's possible, but it's like trying to weld a Phillips bit on the side of a hammer so you can use it to drive screws."
    ...which is funny, hope you got a laugh too ;)

    So, host says they can use the IP address currently associated with the URL so that iptables is better able to block outgoing connection for the time being... my concern is that the IP may change in future, which is why I want to just block the URL.

    To be specific, I want to block connection to a specific URL (or is it URI?) that looks like this:

    Code:
    https://example.com/wp-admin/admin-ajax.php
    (http:// equivalent also)

    If its not practical to be so specific, I am fine blocking access to the domain name entirely.

    Wondering if there is a way to do this by messing with DNS - eg. make it so that the server is not able (one way or another) to effectively resolve the name to an IP or some such... this is something like I would hack together on my PC via my hosts file... don't know enough about how to approach this with my server... :)

    Any guidance appreciated, thanks very much.
     
    #1 MaxFein, Apr 2, 2018
    Last edited: Apr 2, 2018
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    44,344
    Likes Received:
    1,852
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello,

    You could modify the /etc/hosts file on your server, though keep in mind it's unsupported. It's one of the methods discussed on the following URL:

    How to deny all the communications between our server and particular domain and its subdomains?

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
    MaxFein likes this.
  3. MaxFein

    MaxFein Member

    Joined:
    Jul 29, 2015
    Messages:
    20
    Likes Received:
    2
    Trophy Points:
    3
    Location:
    Portland, Oregon
    cPanel Access Level:
    Root Administrator
    Thanks. While most of that thread is about blocking incoming by domain/URL and the challenges in *trying* to do that, I assume you are pointing toward the last answer on the thread:

    So yeah, that all makes good sense, and the question seems to be:

    How to add a wildcard DNS record (*.example.com A 127.0.0.1) to the local DNS server on my server?

    I'll google and check docs, etc... if you can save me some time re. what to edit and where, well, that'd be great :)

    Cheers, Max
     
  4. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    44,344
    Likes Received:
    1,852
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello,

    You'd create a DNS zone for "example.com" using "WHM >> Add a DNS Zone" and then add the wildcard entry using "WHM >> Edit DNS Zone". However, I believe editing the /etc/hosts file on the server is the better approach as far as workarounds because outgoing connections may not always use the local server for DNS resolution.

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
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