Skip to content
GoodBranPublic

About

Toggle the wifi between manual (home) and DHCP (away)

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Homeaway

A CLI tool to quickly toggle your macOS WiFi between manual (static IP) and DHCP mode.

Features

  • Smart IP Detection: Automatically scans and finds an available IP in your subnet
  • DNS Management: Clears DNS settings when switching to DHCP (configurable)
  • First-Run Wizard: Interactive setup on first run
  • Simple Interface: Just run homeaway and toggle with a single keypress

Installation

Via RubyGems (Recommended)

gem install homeaway

Via curl (One-liner)

curl -L https://raw.githubusercontent.com/GoodBran/homeaway/main/bin/homeaway -o /usr/local/bin/homeaway && chmod +x /usr/local/bin/homeaway

From Source

git clone https://github.com/GoodBran/homeaway.git
cd homeaway
ruby -Ilib bin/homeaway

Usage

Simply run:

homeaway

First Run

On first run, you'll be prompted to configure:

  • Default router address (default: 192.168.1.1)
  • Whether to clear DNS when toggling to DHCP (default: yes)
  • Default DNS server (default: 8.8.8.8)

Configuration is stored at ~/.config/homeaway/config.yml.

Normal Usage

$ homeaway
Current mode: DHCP

Toggle to Manual mode? [Y/n]: y

Scanning for available IP in 192.168.1.x range...
Configuring static IP:
  IP Address: 192.168.1.42
  Subnet Mask: 255.255.255.0
  Router: 192.168.1.1
  DNS Server: 8.8.8.8

Successfully switched to Manual mode!
Your IP is now: 192.168.1.42

How It Works

Finding Available IP

When switching to manual mode, the tool:

  1. Scans the range 192.168.1.2 through 192.168.1.254
  2. Pings each IP to check if it's in use
  3. Returns the first available IP address

Network Commands Used

The tool uses macOS's built-in networksetup command:

  • networksetup -listallhardwareports - Detects WiFi interface
  • networksetup -getinfo <device> - Gets current configuration
  • networksetup -setmanual <device> <ip> <subnet> <router> - Sets static IP
  • networksetup -setdhcp <device> - Enables DHCP
  • networksetup -setdnsservers <device> <dns> - Sets DNS
  • networksetup -setdnsservers <device> empty - Clears DNS

Requirements

  • macOS (uses networksetup command)
  • Ruby 2.6 or higher
  • Administrator privileges (for changing network settings)

Configuration File

# ~/.config/homeaway/config.yml
router: 192.168.1.1
clear_dns_on_dhcp: true
dns_server: 8.8.8.8
subnet_mask: 255.255.255.0

Security Note

This tool modifies system network settings. On macOS, you may need to:

  1. Run with sudo: sudo homeaway
  2. Or grant Terminal/ITerm permission to modify network settings in System Preferences

License

MIT

About

Toggle the wifi between manual (home) and DHCP (away)

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages