What-Zit-Tooya/Ad-Block

Ip in hosts formatted files

Closed this issue · 5 comments

Sorry to tell you, but dump hosts files do not understand and can even break systems by having IP = IP in a hosts file

0.0.0.0 23.49.60.137
0.0.0.0 23.49.60.152

RPZ (Response Policy Zones) can handle this as:

32.137.60.49.23.rpz-ip CNAME . ; some comment
32.152.60.49.23.rpz-ip CNAME . ; some comment

Thanks for telling me. Fixed 1792d5f

I think i'll remove IPs from my hosts type adblock, as one IP can serve more server. Need sometime to do it.
This can be a problem if that IP also serve normal site.

@What-Zit-Tooya IP range blocklist should be used ONLY in firewall type apps.
Hosts file format should provide domains only, not IP servers, one server can be used by other services - not only risky.

@What-Zit-Tooya IP range blocklist should be used ONLY in firewall type apps.
Hosts file format should provide domains only, not IP servers, one server can be used by other services - not only risky.

Yeah..true,,
I'll remove IPs later.
Thanks for explanation. :)

@What-Zit-Tooya IP range blocklist should be used ONLY in firewall type apps.
Hosts file format should provide domains only, not IP servers, one server can be used by other services - not only risky.

Just to make it clear about the hosts files and IP-addresses syntax. as a proper OS would simply skip lines containing invalid syntax's such as the ip = ip situation.

A hosts file can not block another IP-address as it is solely a old school phone book (from the 60's)

The format of a hosts file is

VALID syntax
IP<spacer (usual 1 tabulator)>hostname.domain.tld<space>hostname
INvalid syntax
IP<spacer (usual 1 tabulator)>IP

man hosts

DESCRIPTION
This manual page describes the format of the /etc/hosts file. This file is a simple text file that associates IP addresses with hostnames, one line per IP
address. For each host a single line should be present with the following information:

          IP_address canonical_hostname [aliases...]

   Fields of the entry are separated by any number of blanks and/or tab characters.  Text from a "#" character until the end of the line is a  comment,  and  is
   ignored.   Host  names  may contain only alphanumeric characters, minus signs ("-"), and periods (".").  They must begin with an alphabetic character and end
   with an alphanumeric character.  Optional aliases provide for name changes, alternate spellings, shorter hostnames, or generic hostnames (for example, local‐
   host).

   The  Berkeley  Internet Name Domain (BIND) Server implements the Internet name server for UNIX systems.  It augments or replaces the /etc/hosts file or host‐
   name lookup, and frees a host from relying on /etc/hosts being up to date and complete.

   In modern systems, even though the host table has been superseded by DNS, it is still widely used for:

   bootstrapping
          Most systems have a small host table containing the name and address information for important hosts on the local network.  This is useful when DNS is
          not running, for example during system bootup.

   NIS    Sites  that use NIS use the host table as input to the NIS host database.  Even though NIS can be used with DNS, most NIS sites still use the host ta‐
          ble with an entry for all local hosts as a backup.

   isolated nodes
          Very small sites that are isolated from the network use the host table instead of DNS.  If the local information rarely changes, and  the  network  is
          not connected to the Internet, DNS offers little advantage.

EXAMPLE

       # The following lines are desirable for IPv4 capable hosts
       127.0.0.1       localhost

       # 127.0.1.1 is often used for the FQDN of the machine
       127.0.1.1       thishost.mydomain.org  thishost
       192.168.1.10    foo.mydomain.org       foo
       192.168.1.13    bar.mydomain.org       bar
       146.82.138.7    master.debian.org      master
       209.237.226.90  www.opensource.org

       # The following lines are desirable for IPv6 capable hosts
       ::1             localhost ip6-localhost ip6-loopback
       ff02::1         ip6-allnodes
       ff02::2         ip6-allrouters

@What-Zit-Tooya IP range blocklist should be used ONLY in firewall type apps.
Hosts file format should provide domains only, not IP servers, one server can be used by other services - not only risky.

Just to make it clear about the hosts files and IP-addresses syntax. as a proper OS would simply skip lines containing invalid syntax's such as the ip = ip situation.

A hosts file can not block another IP-address as it is solely a hold school phone book (from the 60's)

The format of a hosts file is

VALID syntax
IP<spacer (usual 1 tabulator)>hostname.domain.tld<space>hostname
INvalid syntax
IP<spacer (usual 1 tabulator)>IP

man hosts

DESCRIPTION
This manual page describes the format of the /etc/hosts file. This file is a simple text file that associates IP addresses with hostnames, one line per IP
address. For each host a single line should be present with the following information:

          IP_address canonical_hostname [aliases...]

   Fields of the entry are separated by any number of blanks and/or tab characters.  Text from a "#" character until the end of the line is a  comment,  and  is
   ignored.   Host  names  may contain only alphanumeric characters, minus signs ("-"), and periods (".").  They must begin with an alphabetic character and end
   with an alphanumeric character.  Optional aliases provide for name changes, alternate spellings, shorter hostnames, or generic hostnames (for example, local‐
   host).

   The  Berkeley  Internet Name Domain (BIND) Server implements the Internet name server for UNIX systems.  It augments or replaces the /etc/hosts file or host‐
   name lookup, and frees a host from relying on /etc/hosts being up to date and complete.

   In modern systems, even though the host table has been superseded by DNS, it is still widely used for:

   bootstrapping
          Most systems have a small host table containing the name and address information for important hosts on the local network.  This is useful when DNS is
          not running, for example during system bootup.

   NIS    Sites  that use NIS use the host table as input to the NIS host database.  Even though NIS can be used with DNS, most NIS sites still use the host ta‐
          ble with an entry for all local hosts as a backup.

   isolated nodes
          Very small sites that are isolated from the network use the host table instead of DNS.  If the local information rarely changes, and  the  network  is
          not connected to the Internet, DNS offers little advantage.

EXAMPLE

       # The following lines are desirable for IPv4 capable hosts
       127.0.0.1       localhost

       # 127.0.1.1 is often used for the FQDN of the machine
       127.0.1.1       thishost.mydomain.org  thishost
       192.168.1.10    foo.mydomain.org       foo
       192.168.1.13    bar.mydomain.org       bar
       146.82.138.7    master.debian.org      master
       209.237.226.90  www.opensource.org

       # The following lines are desirable for IPv6 capable hosts
       ::1             localhost ip6-localhost ip6-loopback
       ff02::1         ip6-allnodes
       ff02::2         ip6-allrouters

Thank you for attention and explanation,, im very sorry about this. Didnot know about this rule. For future use, i'll remember this rule. :)