A macOS menu bar utility for managing entries in the /etc/hosts file with quick access from the top toolbar.
Clean, intuitive interface showing host entries with toggle controls and status indicators.
- 🔝 Menu bar integration - Always accessible from the top toolbar
- 📋 Safe section management - Only manages entries in marked sections, never touches system hosts
- 🔄 Quick toggle - Enable/disable hosts with one click
- ➕ Add new entries - Built-in form for adding new host mappings
- 🔒 Secure operation - Requests admin privileges when saving changes
- 🛡️ System protection - Cannot remove or modify hosts outside its managed section
- 🖥️ Native macOS interface - Built with SwiftUI for perfect integration
The app manages a dedicated section in your /etc/hosts file marked with:
####### HostSwitchStart
# Your managed entries go here
####### HostSwitchEnd
Key benefits:
- Safe: Only modifies the designated section, leaving system entries untouched
- Clean: Preserves existing hosts file structure and comments
- Isolated: Your managed entries are clearly separated from system/manual entries
-
Build the app:
./build_hostswitch.sh
-
Run the app:
open HostSwitch.app
-
Look for the network icon in your menu bar and click it
To have HostSwitch start automatically when you log in:
- Open System Settings (or System Preferences on older macOS)
- Navigate to General → Login Items & Extensions
- Click + next to "Open at Login"
- Browse to and select HostSwitch.app
- HostSwitch will now start automatically when you log in
The app runs silently in the menu bar and will be ready whenever you need it.
If you don't have a managed section yet, the app will create one automatically when you add your first entry. Or manually add it:
sudo echo '' >> /etc/hosts
sudo echo '####### HostSwitchStart' >> /etc/hosts
sudo echo '####### HostSwitchEnd' >> /etc/hosts- Click the network icon in your menu bar
- View current entries - See all managed hosts with their status
- Toggle entries - Click the circle to enable/disable any host
- Add new entries - Click "Add Host" to create new mappings
- Refresh - Click refresh to reload from the file
Your /etc/hosts file will look like:
# System entries remain untouched
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
####### HostsManagerStart
192.168.1.100 dev.mysite.com
# 10.0.0.50 staging.mysite.com # Test server
####### HostsManagerEnd
- Safe operation: Only modifies the designated section between markers
- System protection: Cannot remove or modify hosts outside its managed section
- Admin privileges: Required by macOS for any /etc/hosts modifications
- Atomic changes: Either all succeed or none are applied
- Preservation: All system entries (localhost, broadcasthost) and manual entries are always preserved
- Clear feedback: Status messages show when admin privileges are being requested
- macOS 11.0 or later
- Administrator access for modifying
/etc/hosts