from wikipedia
The computer file hosts is an operating system file that maps hostnames to IP addresses. It is a plain text file. Originally a file named HOSTS.TXT was manually maintained and made available via file sharing by Stanford Research Institute for the ARPANET membership, containing the hostnames and address of hosts as contributed for inclusion by member organizations. The Domain Name System, first described in 1983 and implemented in 1984,1 automated the publication process and provided instantaneous and dynamic hostname resolution in the rapidly growing network. In modern operating systems, the hosts file remains an alternative name resolution mechanism, configurable often as part of facilities such as the Name Service Switch as either the primary method or as a fallback method.
purpose
The hosts file is one of several system facilities that assists in addressing network nodes in a computer network. It is a common part of an operating system's Internet Protocol (IP) implementation, and serves the function of translating human-friendly hostnames into numeric protocol addresses, called IP addresses, that identify and locate a host in an IP network.
What is a hosts file?
A hosts file, named hosts
(with no file extension), is a plain-text file
used by all operating systems to map hostnames to IP addresses.
In most operating systems, the hosts
file is preferential to DNS
.
Therefore if a domain name is resolved by the hosts
file, the request never
leaves your computer.
Having a smart hosts
file goes a long way towards blocking malware, adware,
and other irritants.
For example, to nullify requests to some doubleclick.net servers, adding these lines to your hosts file will do it:
# block doubleClick's servers
0.0.0.0 ad.ae.doubleclick.net
0.0.0.0 ad.ar.doubleclick.net
0.0.0.0 ad.at.doubleclick.net
0.0.0.0 ad.au.doubleclick.net
0.0.0.0 ad.be.doubleclick.net
# etc...
Translation
Using a customized and curated /etc/hosts file you override your ISPs name resolving system. This will help you to minimize and even avoid your computer to connect on the background to malicious sites and/or directly blocking access to them.
What's malicious? Any website you put in this file. From fakenews sites, porn, gambling, ... or google, facebook et al. main tracking services. You can set different host for your personal use, your kids mobile devices, work stations, etc.
Setting up your system
As stated, hosts file is used on every computer system from PC to mobile devices. Anything that has internet access needs to resolve names. Here you can know where is this file located on your system and if it's editable (root access).
One of the advantages for having customized hosts file is you can update it at regular intervals to add/delete new domains at your will and needs.
The basic procedure is to open your /etc/hosts file on a text editor and copy/paste the raw file version provided by StevenBlack GitHub repo.
Days or weeks later you may want to update this file to the latest version.
my config
I've set up a .bashrc alias I run every two months.
Open .bashrc and paste your version of this code:
alias hosts='sudo wget -O /etc/hosts https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts && cat ~/Documents/hosts_custom >> /etc/hosts'
- alias hosts: is just a name, choose any you want
- sudo: you need root access to write _/etc/hosts
- wget -O: use wget to download and write
- /etc/hosts: where hosts are stored on your system
- https url: raw url from github, choose regular version or specific variant.
from && is optional:
- cat local_file: route to a local file where you put your personal blocked domains (ex. www.facebook.com)
If you need/want execution at regular time intervals you can set a cron job, I run this alias at will every other week.
banner Photo by Thomas Jensen on Unsplash
Comments
October 30, 2022 15:10
Deepmaterial is reactive hot melt pressure sensitive adhesive manufacturer and supplier, manufacturing one component epoxy underfill adhesives, hot melt adhesives glue, uv curing adhesives,high refractive index optical adhesive, magnet bonding adhesives, best top waterproof structural adhesive glue for plastic to metal and glass, electronic adhesives glue for electric motor and micro motors in home appliance. Industrial Hot Melt Electronic Component Epoxy Adhesive
November 1, 2022 17:56
I can suggest essentially not too bad and even dependable tips, accordingly see it: 카지노사이트
November 2, 2022 18:33
I can suggest essentially not too bad and even dependable tips, accordingly see it: 플레이포커머니상
November 8, 2022 08:32
I can suggest essentially not too bad and even dependable tips, accordingly see it: how to sell merchant services
November 13, 2022 10:17
Mycatttery is the best place of munchkin cat for sale. We are a home kennel dedicated to providing you with high quality Munchkin kittens. munchkin kittens for sale
November 15, 2022 10:20
Welcome to Chris and Bella’s Cattery, we dedicate our lives to the breeding of munchkin cat for sale and Scottish fold munchkin cat for sale for any family who is caring and loving who needs to add our adorable fur babies to their lives. Our kittens and cats are well behave and well trained to fit into any family with kids, birds, dogs and other pets. Getting a munchkin cat, kitten or Scottish fold munchkin from our cattery will mean getting a loving, caring and passionate friend or partner for the rest of your lives. munchkin kittens for sale
November 15, 2022 19:43
Extremely decent blog and articles. I am realy extremely glad to visit your blog. Presently I am discovered which I really need. I check your blog regular and attempt to take in something from your blog. Much obliged to you and sitting tight for your new post. 먹튀검증