Live data from Hacker News

Using a Hosts File To Make The Internet Not Suck As Much

someonewhocares.org

91–100 of 104 posts

Re: Using a Hosts File To Make The Internet Not Suck As Much

#92
post #6

Earlier quoted context omitted.

Will browsers immediately fail the connection, or will it try to make the connection and wait for a timeout? I generally use 0.42.42.42 because Class-A addresses can't start with 0, so they fail immediately.

IIRC, addresses 0/8 addresses are for multicast, so depending on your and your upstream's router configuration, that potentially sends those requests to a weird set of hosts on your class-A.

Multicast is 224.0.0.0/4 (224-239). 0/8 should only be used as a source address for "local network" traffic and never a destination.

Re: Using a Hosts File To Make The Internet Not Suck As Much

#93
post #78

Can most of this be accomplished more easily by using OpenDNS?

If you use the hosts file, your browser doesn't need to wait to make the DNS request to OpenDNS, since it already has the loopback/null route in hosts.

But you have an entire community addressing real time changes (like adding sites that get infected with malware or being used in phishing attacks) and dealing with false positives.

Re: Using a Hosts File To Make The Internet Not Suck As Much

#94
post #24

Earlier quoted context omitted.

If every entry routes to 127.0.0.1, what's the worst that could happen?

One can also null route them as well via 0.0.0.0. Hosts tend to die instantly that way versus timing out with 127.0.0.1

Here is the 0.0.0.0 version: http://someonewhocares.org/hosts/zero/

Re: Using a Hosts File To Make The Internet Not Suck As Much

#95
post #93

Earlier quoted context omitted.

If you use the hosts file, your browser doesn't need to wait to make the DNS request to OpenDNS, since it already has the loopback/null route in hosts.

But you have an entire community addressing real time changes (like adding sites that get infected with malware or being used in phishing attacks) and dealing with false positives.

Also, OpenDNS entries should be cached after the first lookup.

Re: Using a Hosts File To Make The Internet Not Suck As Much

#97
post #24

Earlier quoted context omitted.

If every entry routes to 127.0.0.1, what's the worst that could happen?

One can also null route them as well via 0.0.0.0. Hosts tend to die instantly that way versus timing out with 127.0.0.1

Years ago I maintained a popular ad blocking hosts file. I got a lot of complaints when I switched from 127.0.0.1 to 0.0.0.0. Some TCPIP stacks just didn't like it. Others had little webservers running on 127.0.0.1 that quickly served up 404's for speed or black jpegs to make things pretty. Someone out there maintained a little httpd for windows that did just that. If it saw a GET for blahblah.jpg it would serve up a black graphic of some random size. It sure beat the default FF or IE error message.

Honestly, there's no need for this stuff in the age of browser based ad blocking. I gave up on it when I saw how easy it was to write rules and wildcards in ad block plus. Interest in it fell. I'm surprised to see one still maintained.

Re: Using a Hosts File To Make The Internet Not Suck As Much

#98

Could someone post the same approach, but using bind (DNS), handling all those entries in one zone? Is it possible?

Yes, it's actually pretty easy.

First, create a zone file that all of the domains will share. I put mine in /var/named/master/dummy:

    $TTL    1d
    @               IN      SOA     ns1.localdomain.       hostmaster.ns1.localdomain. (
                            2012100601 ; serial
                            8h ; refresh
                            2h ; retry
                            7d ; expire
                            1h ; default_ttl
                            )
    ;
    ; Name servers
    ;
    @               IN      NS      ns1.localdomain.
    @               IN      NS      ns2.localdomain.
    ;
    ; Host addresses
    ; Leave commented to return NXDOMAIN
    ; Uncomment to resolve to IP address
    ;@               IN      A      127.0.0.1
I prefer not resolve these hosts at all (NXDOMAIN), because it seems to be faster and I don't want client machines to probe themselves, but you can uncomment the A record and use whatever IP address you want (e.g. for sinkhole monitoring). Remember to increment the serial number with every edit (which will be rare or never, once you've set it to your liking).

Next, create a simple file with each domain you want to block on one line. I put mine in /var/named/dummy:

    ads.example.com
    tracker.example.com
    example.org
Now create a conf file in the format bind expects, pointing every domain to the zone file (for convenience, put this in /var/named/Makefile in a 'dummy' target):

    sed 's/.*/zone "&" { type master; file "master\/dummy"; };/'  dummy.conf
Which will result in /var/named/dummy.conf containing:

    zone "ads.example.com" { type master; file "master/dummy"; };
    zone "tracker.example.com" { type master; file "master/dummy"; };
    zone "example.org" { type master; file "master/dummy"; };
Finally, add to your named.conf:

    include "/var/named/dummy.conf";
Restart bind and you're now authoritative for those zones on your network!

Re: Using a Hosts File To Make The Internet Not Suck As Much

#99

Is there an IP block lists for Servers ? I see a lot of traffic from ip addresses that seem to probe my measly AWS EC2 instance and I wish there was a list I could feed to my NGINX or IPtables so they would just drop those packets .

Why would you want to block search engines and other crawlers?

I love the search engines ; its the other type of automated crawlers -- its kind of each to spot them by the urls access logs. Once a flaw/vulnerability is publicized, you can see script kiddies' attempting to use that on your site

Re: Using a Hosts File To Make The Internet Not Suck As Much

#100

Could someone post the same approach, but using bind (DNS), handling all those entries in one zone? Is it possible?

Yes, it's actually pretty easy. First, create a zone file that all of the domains will share. I put mine in /var/named/master/dummy: $TTL 1d @ IN SOA ns1.localdomain. hostmaster.ns1.localdomain. ( 2012100601 ; serial 8h ; refresh 2h ; retry 7d ; expire 1h ; default_ttl ) ; ; Name servers ; @ IN NS ns1.localdomain. @ IN NS ns2.localdomain. ; ; Host addresses ; Leave commented to return NXDOMAIN ; Uncomment to resolve…

Bind is really confusing.

One of these days I'm gonna roll my own DNS server in Python with a sane configuration syntax.

Post reply on HN