Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Can Wildcards be used in the HOSTS file?

1,126 views
Skip to first unread message

bret_...@none.com

unread,
Feb 20, 2017, 12:43:48 AM2/20/17
to
Can Wildcards be used in the HOSTS file?

For example
Instead of putting in all five of these:

www.spam.com
www.spam.com/spammer1
www.spam.com/spammer2
www.spam.com/spammer3
www.spam.com/spammer4

Can someone just put:

www.spam.com/*.*


R.Wieser

unread,
Feb 20, 2017, 3:58:50 AM2/20/17
to
Bret,

The HOSTS file only accepts/works with/filters on *domain names* (the name
of the server). From your examples only the first entry is therefore
valid, the others are not.

Furthermore, if you put that first entry into your HOSTS file (followed by a
127.0.0.1 (or alike) ofcourse) than you catch *everything* attempt to access
that server, no matter what the path to the resource is.

And yes, that means that if you by accident do like "spammer10" than you
would be out of luck, as its an all-or-nothing kind of filtering.

Regards,
Rudy Wieser


-- Origional message:
<bret_...@none.com> schreef in berichtnieuws
t30lactnpkk9nhl09...@4ax.com...

micky

unread,
Feb 20, 2017, 6:28:09 AM2/20/17
to
In microsoft.public.windowsxp.general, on Mon, 20 Feb 2017 09:58:40
+0100, "R.Wieser" <add...@not.available> wrote:

>Bret,
>
>The HOSTS file only accepts/works with/filters on *domain names* (the name
>of the server). From your examples only the first entry is therefore
>valid, the others are not.
>
>Furthermore, if you put that first entry into your HOSTS file (followed by a
>127.0.0.1 (or alike) ofcourse) than you catch *everything* attempt to access
>that server, no matter what the path to the resource is.
>
>And yes, that means that if you by accident do like "spammer10" than you

I've found that spamme10 sends the best spam.

Martim Ribeiro

unread,
Feb 20, 2017, 10:03:08 AM2/20/17
to
On Sun, 19 Feb 2017 23:43:10 -0600, in microsoft.public.windowsxp.general
bret_...@none.com wrote:

> Can Wildcards be used in the HOSTS file?

You have the answer.

Another way of answering it from the side is to use the MVP HOSTS file.
http://winhelp2002.mvps.org/hosts.htm

Here is the file.
http://winhelp2002.mvps.org/hosts.txt

Yet another way to do what you want to do is to use Acrylic.
http://superuser.com/questions/135595/using-wildcards-in-names-in-windows-hosts-file

Here is Acrylic.
http://mayakron.altervista.org/wikibase/show.php?id=AcrylicHome

There's also DNSAgent apparently.
https://github.com/stackia/DNSAgent

VanguardLH

unread,
Feb 20, 2017, 4:19:06 PM2/20/17
to
No. Hostnames (optionally with domains) must be listed. Most users
employ the hosts file to define hosts and include the domain although
the domain is only needed if the host is elsewhere (other domain). You
will need 3rd party software that provides URL filtering and which
permits wildcard masking.

In your example, and provided you completed the definition (you forgot
the IP address to which the host reference will get redirected),
www.spam.com/*.* is meaningless. You would filter on www.spam.com, not
on some [sub]path under that domain and definitely not by using a mask
akin to a filespec. It is a *hosts* file. You would add:

127.0.0.0 www.spam.com

in your hosts file. However, that only helps to block DNS requests so
is only useful in a web-centric client that might connect to that
source. The hosts file is not applicable to e-mailed spam since you
were not the receiving e-mail server that accepted the message. The
hosts file will not help to eliminate e-mailed spam whether you use a
local e-mail client or your e-mail provider's webmail client. You were
not the endpoint in the transmission. The e-mail server was.

For most users, the hosts file only has value in blocking unwanted
content in a web client, like a web browser. However, you must specify
hostnames, not domain names. www.spam.com will work but spam.com will
not. That is why pre-compiled hosts files, like the MVPS one, have
around 52 entries just for doubleclick.com, one for each host the domain
uses to issue their content. Entering doubleclick.com in your hosts
file will not block web content originating from rd1.doubleclick.com.
If you want to block on domains (instead of hosts which is what the
hosts file does) then you need to add something that provides URL
filtering.

I use Avast free and it has a URL filter. Alas, Avast has swayed on
that feature: in some versions it is there, in other versions it is
missing. So I cannot rely on it being available in every future version
of Avast. Guess they don't consider URL filtering as anti-security or
anti-privacy protection. I also use OpenDNS (with Google DNS as a
backup) instead of my ISP's DNS server. I have an account at OpenDNS
(you can still get a free one but, I believe, you now have to do a trial
of their service, decided not to use them, and they convert you to a
free account as a reward for trying their service, so getting a free
account there now is a bit obtuse). In my OpenDNS free account, I can
define up to 50 URL filters. I can specify a domain, a particular host
at the domain, and even wildcard either the host or domain portion of
the URL filter. This is domain URL filtering. You don't specify some
[sub]path under there. Using OpenDNS with an account means you have to
keep it updated with whatever is your current IP address. That allows
them to know which account, if any, to apply its settings when you
connect to them to issue your DNS lookups. If you have a static IP
address assigned to you by your ISP (usually at extra cost since it may
require getting a business-tier account) then you can configure your
OpenDNS account with that IP address. If you get a dynamically assigned
IP address from your ISP then you need to use a DNS updater client which
reports a change of your IP address into your OpenDNS account. The
updater will also update at 28-day intervals since free accounts will
expire if not updated in a month. Another benefit of using OpenDNS is
that you can assign a hostname to your own computer without having to
register a domain (although you can bring one to OpenDNS if you want to
use that) or have to get someone to home your domain in their
nameserver. Instead of having to remember your IP address (which can
change if dynamic), you can remember its name. OpenDNS also provided
DDNS (Dynamic DNS) services. As I recall, the limit is 2 hostnames per
free account (used to be 5 but they reduced their services for free
accounts). OpenDNS is not the only DNS filtering or DDNS provider.
No-IP is another. There are more.

I know users that configure their DDNS setting in their router to use
OpenDNS or another DDNS provider. The problem there is that the router
only updates the account when its WAN-side IP address changes, and that
could be a lot longer than a month's expiration on free account (even
for dynamic IP address since non-dialup users often keep their IP
address assignment for months). Router-based DDNS support works with
static IP addresses. If you have a dynamic IP address assignment,
you'll want a DNS updater client running on one of your intranet hosts
to update your free account before it expires from being idle too long.
Issuing DNS lookups to your account does not count as accessing your
account. You must login using a local client (DNS updater) or use their
web site. Loggin in is what measures how long your account has been
idle.

Note that DNS filtering in the hosts file, URL filtering, or DNS
filtering only works when you issue DNS lookups, like a reference to
www.spam.com. None of this works if the reference is to an IP address
because that means DNS was never involved. DNS is to lookup a host to
find its IP address. If you start with an IP address, you don't have to
look it up. www.spam.com = 34.198.59.158 and 52.54.255.92. If a
reference uses those IP addresses, none of the above methods will filter
out that source. You retrieving e-mail does not involve DNS (other than
for your local e-mail client to connect to your e-mail provider's server
to get your e-mail). The content of the e-mail is sent to you within a
DATA command in a session between your e-mail client and the server.
There is no DNS lookup involved in the transfer of the e-mail's content.
So putting www.spam.com in a hosts file, URL filter, or using a DDNS
account will not stop you from getting their spam. They will, however,
eliminate that e-mail spam that you do receive from connecting out to
their images or ads via hyperlinks inside their spam message. You still
get the spam but it cannot connect out to retrieve their additional
content. So you end up getting neutered spam.

Shadow

unread,
Feb 21, 2017, 11:19:26 AM2/21/17
to
On Sun, 19 Feb 2017 23:43:10 -0600, bret_...@none.com wrote:

>Can Wildcards be used in the HOSTS file?
>
>For example
>Instead of putting in all five of these:
>
>www.spam.com

127.0.0.1 www.spam.com

would block access to

>www.spam.com/spammer1
>www.spam.com/spammer2
>www.spam.com/spammer3
>www.spam.com/spammer4

and
>www.spam.com/*.*

But not

www.hi_there_I_have_cheap_viagra.spam.com

HTH
[]'s
--
Don't be evil - Google 2004
We have a new policy - Google 2012

J. P. Gilliver (John)

unread,
Feb 24, 2017, 2:27:36 AM2/24/17
to
In message <gqpoacdbdigqkdgg6...@4ax.com>, Shadow
<S...@dow.br> writes:
>On Sun, 19 Feb 2017 23:43:10 -0600, bret_...@none.com wrote:
>
>>Can Wildcards be used in the HOSTS file?
>>
>>For example
>>Instead of putting in all five of these:
>>
>>www.spam.com
>
>127.0.0.1 www.spam.com
>
>would block access to
>
>>www.spam.com/spammer1
>>www.spam.com/spammer2
>>www.spam.com/spammer3
>>www.spam.com/spammer4
>
>and
>>www.spam.com/*.*
>
> But not
>
>www.hi_there_I_have_cheap_viagra.spam.com
>
> HTH
> []'s
I think bret_pedro might have been asking, could you have

127.0.0.0 *.spam.com

or even

127.0.0.0 *spam.com

?
--
J. P. Gilliver. UMRA: 1960/<1985 MB++G()AL-IS-Ch++(p)Ar@T+H+Sh0!:`)DNAf

The first banjo solo I played was actually just a series of mistakes. In fact
it was all the mistakes I knew at the time. - Tim Dowling, RT2015/6/20-26

Shadow

unread,
Feb 24, 2017, 4:52:42 PM2/24/17
to
No. You would need a firewall for that, or proxy software.
Hosts file blocks "hosts", and *.spam.com is not a host.
0 new messages