### Enable and Start nscd Daemon on FreeBSD Source: https://github.com/stevenblack/hosts/blob/master/alternates/fakenews-only/readme.md These commands enable and start the name service cache daemon (nscd) on FreeBSD. Enabling it ensures it starts on boot, and starting it provides immediate functionality. This is often a prerequisite for proper DNS caching. ```sh sudo sysrc nscd_enable="YES" sudo service nscd start ``` -------------------------------- ### Example of blocking domains in hosts file (Text) Source: https://github.com/stevenblack/hosts/blob/master/alternates/fakenews-only/readme.md This example demonstrates how to block specific domains by adding entries to a hosts file. Each entry maps a domain to the IP address 0.0.0.0, effectively nullifying requests to those domains. This method is preferred over 127.0.0.1 for performance and compatibility reasons. ```text # 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... ``` -------------------------------- ### Run updateHostsFile.py with Extensions and Backup Source: https://github.com/stevenblack/hosts/blob/master/alternates/fakenews-porn-only/readme.md This example shows how to include specific host file extensions and create a backup of the original hosts file. The '--extensions' flag specifies which additional host files to merge, and '--backup' creates a copy before overwriting. ```sh python3 updateHostsFile.py --extensions porn social --backup ``` -------------------------------- ### Install Dependencies for Hosts File Generation Source: https://github.com/stevenblack/hosts/blob/master/alternates/fakenews-only/readme.md This command installs the necessary Python dependencies for the 'updateHostsFile.py' script using pip3. The '--user' flag is recommended to install packages at the user level, avoiding potential conflicts with system-wide packages. ```bash pip3 install --user -r requirements.txt ``` -------------------------------- ### Run updateHostsFile.py to Skip Static Hosts and Compress Output Source: https://github.com/stevenblack/hosts/blob/master/alternates/fakenews-porn-only/readme.md This example demonstrates generating a hosts file while skipping the standard static hosts section and applying compression. '--skipstatichosts' is useful for specific network configurations, and '--compress' reduces file size by removing comments and empty lines. ```sh python3 updateHostsFile.py --skipstatichosts --compress ``` -------------------------------- ### Install Bind9 DNS Server on Debian/Raspbian/Ubuntu Source: https://github.com/stevenblack/hosts/wiki/Bind-DNS-Server Installs the Bind9 DNS server package, which is required to serve DNS queries and block hosts. ```bash sudo apt install bind9 ``` -------------------------------- ### Run updateHostsFile.py with Minimise Output and Whitelist Source: https://github.com/stevenblack/hosts/blob/master/alternates/fakenews-porn-only/readme.md This example shows how to generate a hosts file in a minimized format, where each domain is on a separate line, and apply a whitelist to exclude certain entries. '--minimise' is useful for URL blockers, and '--whitelist' filters the output. ```sh python3 updateHostsFile.py --minimise --whitelist my_whitelist.txt ``` -------------------------------- ### Prepare and Execute Zonefile Generation Script Source: https://github.com/stevenblack/hosts/wiki/Bind-DNS-Server Downloads the `generate-zonefile.sh` script, makes it executable, and then runs it to create the actual zonefile used by Bind9. Users need to uncomment a URL within the script to specify the hosts list source. ```bash wget [URL_TO_GENERATE-ZONEFILE.SH] chmod +x generate-zonefile.sh ./generate-zonefile.sh ``` -------------------------------- ### Start DNS Clean Service on Linux Mint Source: https://github.com/stevenblack/hosts/blob/master/alternates/fakenews-only/readme.md This command starts the DNS clean service on Linux Mint to refresh DNS entries. It requires root privileges and should be executed in a terminal. ```sh sudo /etc/init.d/dns-clean start ``` -------------------------------- ### NixOS Configuration for hosts file (Nix) Source: https://github.com/stevenblack/hosts/blob/master/alternates/fakenews-only/readme.md This Nix configuration snippet shows how to include the StevenBlack hosts file in a NixOS system. It uses `builtins.fetchurl` to download the hosts file from a specified URL and adds its content to `networking.extraHosts`. Note that `fetchurl` is impure; for reproducible builds, `fetchFromGitHub` with a specific commit is recommended. ```nix { networking.extraHosts = let hostsPath = https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts; hostsFile = builtins.fetchurl hostsPath; in builtins.readFile "${hostsFile}"; } ``` -------------------------------- ### Example of Blocking Domains with hosts File Source: https://github.com/stevenblack/hosts/blob/master/alternates/fakenews-porn-social/readme.md This example demonstrates how to block specific subdomains of `doubleclick.net` by mapping them to `0.0.0.0`. This entry in the hosts file directs traffic intended for these domains to a non-existent address, effectively blocking them. ```text # 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 ``` -------------------------------- ### Run updateHostsFile.py with Blacklist and Custom IP Source: https://github.com/stevenblack/hosts/blob/master/alternates/fakenews-porn-only/readme.md This example demonstrates adding a blacklist file to the generated hosts file and specifying a custom IP address. '--blacklist' appends entries from a specified file, and '--ip' sets the target IP for all hosts. ```sh python3 updateHostsFile.py --blacklist my_blacklist.txt --ip 127.0.0.1 ``` -------------------------------- ### Run updateHostsFile.py with Auto Update and Replace Source: https://github.com/stevenblack/hosts/blob/master/alternates/fakenews-porn-only/readme.md This example demonstrates running the update script with the '--auto' and '--replace' flags. '--auto' enables automatic updates of host data sources without prompting, and '--replace' ensures that the generated hosts file overwrites the existing one. ```sh python3 updateHostsFile.py --auto --replace ```