Results 1 to 2 of 2

Thread: Block all subdomains of a website

  1. #1
    Join Date
    Mar 2013

    Question Block all subdomains of a website

    I need to block access to some websites from all browsers on my ubuntu 12.04 machine.
    For example I need to block and all its subdomains (,,

    I tried to edit the file /etc/hosts and added

    This blocks the main page ( but it does not block the subdomains (I can still access

    How do I easily block a domain (such as and all its subdomains (,, ..........)?

  2. #2
    Join Date
    Nov 2008
    Metro Boston
    Kubuntu 14.04 Trusty Tahr

    Re: Block all subdomains of a website

    Short answer is that there is no simple solution to block *

    You can extend the method you describe by adding every hostname you might need to block to /etc/hosts. Otherwise you'd have to install something like Squid as a caching proxy and write "access control" rules to block the domain. In squid you can do this:

    acl idnes dstdomain
    http_access deny idnes
    which defines an "access control list" for the domain, then adds a rule to block access to any URL that points to that domain. You'd then have to configure the browsers to use the proxy or set up Squid for "transparent" proxying and add an iptables rule.

    Another, simpler solution is to use a browser add-on like AdBlockPlus for Firefox and add a rule to block anything from This is easy to thwart, though, since the user can simply disable or delete the rule.
    Last edited by SeijiSensei; March 21st, 2013 at 11:30 AM.
    If you ask for help, please have the courtesy to check for responses and thank the people who helped you.

    Blog · Linode System Administration Guides · Android Apps for Ubuntu Users

Tags for this Thread


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts