Are there wild cards for a hosts file?

Discussion in 'other software & services' started by Mortal Raptor, Oct 30, 2014.

  1. Mortal Raptor

    Mortal Raptor Banned

    Joined:
    Oct 6, 2014
    Posts:
    1,013
    I entered 0.0.0.0 softonic.com but for example this site:

    http://safe-n-sec.en.softonic.com/

    Just loads fine, isn't there a way to block everything that ends with softonic.com as they seem to change the URL for every download
     
  2. Raza0007

    Raza0007 Registered Member

    Joined:
    Mar 30, 2009
    Posts:
    1,425
    Location:
    USA
    A Hosts file works with domain names only. So, if you want to block a website you need to enter its complete name. Wildcards are not allowed in a hosts file. If you need to use a wildcard then you need to install a DNS server on your PC, like dnsmasq.
     
  3. Mortal Raptor

    Mortal Raptor Banned

    Joined:
    Oct 6, 2014
    Posts:
    1,013
    oh what a shame, so I have to enter each URL separately :(
     
  4. tlu

    tlu Guest

    No, as wildcards or placeholders are invalid in the hosts file. It blocks only and exactly what's added to it. That's the major reason why all those publicly available hosts files like MVPS are that huge as all sub-domains for, e.g., doubleclick.net and the likes have to be seperate entries.

    @Raza0007: dnsmasq doesn't accept wildcards, either. However, adding an entry like

    Code:
    address=/softonic.com/0.0.0.0
    applies to all related sub-domains. That's why blocking of ads/trackers/malware with dnsmasq is clearly superior compared to a hosts file.
     
  5. Raza0007

    Raza0007 Registered Member

    Joined:
    Mar 30, 2009
    Posts:
    1,425
    Location:
    USA
    I have actually never used wildcard entries with dnsmasq personally, but before posting here I checked this Wikipedia entry and the comparison table lists the DNS servers that support wildcards and dnsmasq is listed as supporting wildcards.
     
  6. tlu

    tlu Guest

    Ah, okay, so I may be wrong. However, I still think that they should be unnecessary for what we're discussing here because simpy adding a domain like in the example above also covers all sub-domains. Thus, it is sufficient to add one entry like

    Code:
    address=/doubleclick.net/0.0.0.0
    where you need hundreds of entries in the hosts file. And adding specific sub-domains like

    Code:
    address=/ads.example.comt/0.0.0.0
    is still supported, of course.
     
  7. KeyPer4Life

    KeyPer4Life Registered Member

    Joined:
    Dec 18, 2013
    Posts:
    974
    If all your interested in doing is blocking certain domains then you could try using a PAC file. When you click on
    any domain that ends with in your example ( softonic.com) it will notify you that its blocked/refusing connections.
     
  8. Mortal Raptor

    Mortal Raptor Banned

    Joined:
    Oct 6, 2014
    Posts:
    1,013
    how to do that bro?
     
  9. KeyPer4Life

    KeyPer4Life Registered Member

    Joined:
    Dec 18, 2013
    Posts:
    974
    Depending on browser used you would have to configure the .pac file to use the connection
    settings of the browser.

    In Firefox and Mozilla forks - Automatic proxy configuration URL:
    Enter the file path into the blank field of APC (location where you put pac file)

    You can try a syntax like this: file:///C:/PacFIle/<name of pac file>.pac (doesn't have to be this location)
    Name you pac file - e.g., wipe-ads.pac or muncher.pac or any name you want to use with the .pac extension.

    So in this example I would type into the blank field of Automatic proxy configuration URL: file:///C:/PacFIle/wipe-ads.pac

    You could use an already pre-configured pac file or create your own. Also a pac file doesn't need JavaScript
    enabled to work.

    It may sound complicated but it's really not that hard to setup.

    http://sherylcanter.com/articles/oreilly_20040330_HostsPac.php
     
    Last edited: Nov 4, 2014
  10. siljaline

    siljaline Former Poster

    Joined:
    Jun 29, 2003
    Posts:
    6,619
Loading...