Hosts Script — Unified Hostlist Generator

15 Jun 2021 • 2 min read

Hosts Script is a Bash-based utility that generates a unique, sorted, and consolidated hosts blocklist from multiple sources.

Hosts Script is a Bash-based utility that generates a unique, sorted, and consolidated hosts blocklist from multiple sources.

It supports combining:

  • Existing hosts-formatted lists
  • Plain domain/IP lists

The output can be directly used as a system hosts file or as an input for DNS-based blocking solutions.

How It Works

  • Fetches multiple hostlist sources defined by the user
  • Normalizes domains into a hosts-style format
  • Removes duplicates
  • Sorts entries for consistency
  • Redirects all blocked domains to a configurable local address (default: 0.0.0.0)

The script helps maintain a clean, minimal, and deterministic blocklist from multiple upstream sources.

Features

  • Merge multiple hostlist sources
  • Deduplicate and sort entries
  • Generate hosts-formatted blocklists
  • Configurable redirect IP
  • Simple plain-text configuration
  • Lightweight and dependency-free (Bash only)

Configuration

ParameterDescription
LOCAL_HOSTLocal IP to redirect blocked domains (default: 0.0.0.0)
OUTPUT_HOSTOutput file name (default: hosts.txt)
source.listHosts-formatted sources
source.domainPlain domain/IP sources

Source File Format

source.list Hosts-formatted entries only:

TEXT
0.0.0.0 www.example.com
0.0.0.0 www.evil.com

source.domain Domain or IP only:

TEXT
www.example.com
www.evil.com
If a source file contains only one entry, add an extra empty line at the end (known script limitation).

Usage

  1. Clone the Repository
    BASH
    git clone https://github.com/patkarmandar/Hosts
    cd Hosts
  2. Add Source Lists
    • Add hosts-formatted sources or links to source.list
    • Add plain domains/IPs or links to source.domain
    • One entry per line
  3. Run the Script
    BASH
    bash generate.sh
  4. Output
    • The generated hosts blocklist will be available as: hosts.txt
  5. You can append or replace it in:
    • /etc/hosts (Linux/macOS)
    • System DNS or Pi-hole
    • Custom DNS filtering tools

Curated Hosts Lists

CategoryDescription
PornPorn sites + ads
TrackersMIUI & Microsoft trackers
FacebookFacebook domains
GoogleGoogle domains
InstagramInstagram domains
LinkedInLinkedIn domains
TwitterTwitter/X domains
WhatsAppWhatsApp domains

Credits & Sources

This project aggregates and processes data from the following sources:

  • Steven Black Hosts
  • Pornaway
  • Fanboy Hosts
  • Energized.pro
  • LukeSmithxyz Hosts
All credit goes to the original maintainers of these lists.

Use Cases

  • System-level ad blocking
  • Privacy hardening
  • DNS sinkhole input (Pi-hole, AdGuard)
  • Social media blocking
  • Tracker & telemetry reduction

Start searching

Enter keywords to search articles.