Muko
A command-line utility to manage hosts file entries and quickly toggle between development and production DNS settings.
Name Origin
The name muko comes from 向こう側 (mukō-gawa), meaning "the other side" in Japanese. This concept is famously featured in the Silent Hill video game series, where characters shift between the normal world and a dark, otherworldly dimension. Similarly, this tool lets you seamlessly switch between the "other side" of your development environment and the production reality.
Motivation
As a developer, I often need to test applications locally by redirecting production domains to my local development environment. However, constantly editing the hosts file and commenting/uncommenting lines is tedious and error-prone. Muko solves this by providing a simple way to toggle domains between DEV mode (using custom IPs) and PROD mode (using real DNS) with a single command.
Features
- Add domain entries to your hosts file with custom IPs
- Quickly switch domains between DEV and PROD modes
- View all managed domains in a formatted table
- See both dev IPs and resolved production IPs side-by-side
- Automatic DNS resolution to compare dev vs prod IPs
- Tag-based management to avoid interfering with other hosts file entries
Installation
Install directly from the GitHub repository:
Note: This tool modifies /etc/hosts, so you'll need appropriate permissions (typically sudo) when running commands that modify the hosts file.
Usage
View All Managed Domains
Simply run muko without any arguments to see all domains managed by muko:
This displays a table showing:
- Mode: DEV (active) or PROD (commented out)
- Domain: The domain name
- Alias: Optional alias (only shown if different from domain)
- Dev IP: The custom IP address used in DEV mode
- Prod IP: The actual resolved IP from DNS (shown only in PROD mode)
Add a Domain
Add a new domain entry to your hosts file:
# Add with default IP (127.0.0.1)
# Add with custom IP
# Add with alias
After adding a domain, it's automatically set to DEV mode (active).
Switch to DEV Mode
Uncomment a domain entry to use the custom dev IP:
# Using domain name
# Using alias
In DEV mode, the domain will resolve to your custom IP address (e.g., 127.0.0.1).
Switch to PROD Mode
Comment out a domain entry to use the real production IP:
# Using domain name
# Using alias
In PROD mode, the domain entry is commented out, so DNS resolution falls back to the real production IP address.
How It Works
Muko manages hosts file entries by adding a special tag #muko: to each line it creates. This allows the tool to:
- Identify which entries it manages (avoiding conflicts with other tools or manual entries)
- Store additional metadata like aliases
- Parse and modify only its own entries
Example hosts file entry managed by muko:
127.0.0.1 example.com #muko: myapp
When switched to PROD mode, this becomes:
#127.0.0.1 example.com #muko: myapp
Examples
Typical Workflow
# View current state
# Add a production domain for local development
# Work on local development
# (api.example.com now points to 127.0.0.1)
# Need to test against production?
# Back to development
Managing Multiple Domains
# Add multiple services
# View all at once
# Switch all to prod when needed
Requirements
- Rust (for installation)
- Write access to
/etc/hosts(typically requiressudo)