Skip to content

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hosts Manager for macOS

Hosts Manager icon

A native SwiftUI utility that selects a managed section of /etc/hosts from the current Wi-Fi SSID, default-router IP address, or default-router MAC address.

Hosts Manager for macOS profile management window

How it works

The app edits JSON-backed profiles and installs an embedded Swift daemon as /Library/Application Support/HostsManager/HostsManagerDaemon. A system LaunchDaemon runs it as root so network changes can be handled without repeated password prompts. Installation and removal require an administrator password.

The daemon is independent of the management app. It starts at system boot, continues running after the GUI quits, does not require a logged-in user, and is restarted by launchd if it exits unexpectedly. Turning Enabled off leaves the daemon installed but removes its managed hosts block; Remove Service unloads and deletes the installed daemon.

The daemon only owns this section of /etc/hosts:

# ## ============= ## HostsManager ## ============= ## #
<hosts data>
# ## =====END===== ## HostsManager ## =====END===== ## #

If the markers are absent, the section is appended. If they are present, only that section is replaced. Disabling the manager, finding no matching profile, or removing the service removes the managed section.

Configuration

The GUI writes /Library/Application Support/HostsManager/config.json:

{
  "enabled": true,
  "profiles": [
    {
      "id": "11C3369A-194C-4D63-BADD-E5A3D2714295",
      "name": "Office",
      "matchKind": "wifiSSID",
      "matchValue": "Office WiFi",
      "entries": "10.0.0.20 git.internal\n10.0.0.21 docs.internal"
    }
  ]
}

matchKind accepts wifiSSID, routerIP, or routerMAC. Profiles are evaluated in list order and the first match wins.

Install in Applications

  1. Open HostsManagerForMacOS/HostsManagerForMacOS.xcodeproj in Xcode.
  2. Select the HostsManagerForMacOS scheme and My Mac as the destination.
  3. Choose Product → Archive.
  4. In the Organizer, select the new archive and click Distribute App.
  5. Select Custom, click Next, select Copy App, and export it.
  6. Drag HostsManager.app into /Applications.
  7. Launch the app from Applications, configure at least one network profile, and click Install / Repair.
  8. Approve the administrator prompt. This installs and starts the system LaunchDaemon used to update /etc/hosts.

Copy App is appropriate for installing a local build on your own Mac. For distribution to other users outside the Mac App Store, choose Direct Distribution and complete Developer ID signing and notarization instead.

After installation, the GUI can be closed. The daemon continues running and starts automatically at system boot. Use Enabled to suspend hosts management without uninstalling it, or Remove Service to unload and delete the background service.

When replacing the app with a newer build, launch the updated copy from /Applications and click Install / Repair again so the installed daemon is updated as well.

Build and test

Open HostsManagerForMacOS/HostsManagerForMacOS.xcodeproj in Xcode. The app build embeds the daemon automatically.

xcodebuild -project HostsManagerForMacOS/HostsManagerForMacOS.xcodeproj \
  -scheme HostsManagerForMacOS -destination 'platform=macOS' \
  -only-testing:HostsManagerForMacOSTests test

Licensed under the MIT License. Copyright © 2026 Glenn R. Martin.

About

A native macOS app that automatically switches managed /etc/hosts entries based on Wi-Fi SSID, router IP, or router MAC—with a SwiftUI GUI

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages