
Once installed, you'll find that your surfing experience improves, your breath becomes more lovely, and the world transforms into a gentle place full of unicorns and love.
Remove 'ipv6' from / URL for an IPv4 only versionįlush the DNS cache to activate the new hosts file:. Some lists use 127.0.0.1 (localhost) which exists, and will probably not respond, adding delay.
0.0.0.0 is NXDOMAIN (non-existent domain) - this will sinkhole requests. Or, write the hosts file directly with curl, for example: Install by swapping the active and inactive files (remember, the active file is always hosts): You can use a custom hosts file as a simple ad-blocker while surfing.Īs "an easy and effective way to protect you from many types of spyware, reduce bandwidth, prevent pop-up traps, prevent user tracking, and block most advertising you would otherwise be subjected to on the Internet."ĭownload their custom hosts file, rename and copy it to /etc/hosts.love To restore, Copy the above, open Terminal, and type: sudo pbpaste > /etc/hosts How to make the internet not suck (as much): # localhost is used to configure the loopback interface If you need restore the hosts file, here's the original: Use dig, or nslookup with a URL to see if it's resolved. You can now test your new mapping with ping, or by entering the URL in a browser window! Sudo dscacheutil -flushcache sudo killall -HUP mDNSResponder Press enter on the filename prompt to leave it unchanged, and Ctrl-x to exit the editor.ĥ Flush the DNS cache Enter the following command (Big Sur) to flush the DNS cache and activate the changes: We can also use the hosts file to block access to websites! Make an entry like: 127.0.0.1 to locally block facebook (for example), or enter: 157.166.226.25 to direct facebook requests to cnn.com.Ĥ Save the hosts file When done editing the hosts file, press Ctrl-o to save the file.
Navigate using the arrow keys, leave space between fields, and make sure there is an empty blank line after the last entry. 127.0.0.1 localhost).Īppend your new mappings underneath the existing ones. is located at /etc/hosts, which is a symbolic link to /private/etc/hosts Editing the hosts fileĮditing the hosts file in Mac OS X is a pretty easy task, especially if you are familiar with the terminal.ġ Open the Terminal.app Press ⌘-space and start typing terminal, or navigate to: Applications ➤ Utilities ➤ TerminalĢ Open the hosts file Enter the following command in Terminal to open hosts in a text-editor:Įnter your (admin) user password when prompted.ģ Edit the hosts file The hosts file contains some comments (lines starting with the # symbol), as well as some default hostname mappings (one per line), entered as IP address followed by one or more hostnames (e.g.is checked before the active network connection's DNS servers.is a text file that maps hostnames to IP addresses.doesn't have an extension, its just called hosts.