Sniffing & Spoofinghostsfilemanagementnetworkmappings

Hostsman

Cross-platform command line tool for handling hosts files. Adds, removes, or lists mappings in the hosts file.

Description

Hostsman is a cross-platform command line tool designed for managing entries in the hosts file, located at /etc/hosts on Linux systems. It provides simple operations to insert, remove, check, or list hostname-to-IP mappings, making it useful for network configuration, testing, or blocking unwanted domains by redirecting them to specific IPs.

Common use cases include adding custom DNS mappings for development environments, removing obsolete entries, verifying if a hostname is already mapped, or listing all current mappings. This tool is particularly handy in penetration testing or system administration where quick manipulation of the hosts file is needed without manual editing.

It relies on Python dependencies and installs via standard Kali package management, ensuring compatibility across platforms.

How It Works

Hostsman interacts directly with the system's hosts file at /etc/hosts. It parses command-line arguments to either read the file for listing or checking hostnames, append new HOSTNAME[:IP] mappings (defaulting to 127.0.0.1 if IP omitted), or remove specified hostnames by rewriting the file excluding those entries. Operations require root privileges for file modifications.

Installation

bash
sudo apt install hostsman

Flags

-h, --helpshow this help message and exit
-l, --listShow the content of hosts file
-c, --check HOSTNAME [HOSTNAME ...]Check if the host name existed in the host file
-i, --insert HOSTNAME[:IP] [HOSTNAME[:IP] ...]Insert HOSTNAME[:IP] mappings
-r, --remove HOSTNAME [HOSTNAME ...]Remove mapping for HOSTNAME from hosts file.

Examples

Show the help message and usage information
hostsman -h
List the entire content of the hosts file
hostsman -l
Check if example.com exists in the hosts file
hostsman -c example.com
Check if multiple hostnames exist in the hosts file
hostsman -c example.com test.com
Insert mapping for example.com (defaults to 127.0.0.1)
hostsman -i example.com
Insert multiple hostname:IP mappings
hostsman -i example.com:192.168.1.100 test.com:10.0.0.1
Remove the mapping for example.com from the hosts file
hostsman -r example.com
Remove mappings for multiple hostnames
hostsman -r example.com test.com unwanted.com
Updated 2026-04-16kali.org ↗