Skip to content

lakminagamage/macNetty

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

macNetty 🌐🍎

A beautiful, interactive CLI wizard for macOS network configuration and auto-switching

macNetty simplifies network management for macOS users by providing an elegant command-line interface to create location-based network profiles and automatically switch between them based on your Wi-Fi connection.

macOS Bash License

✨ Features

  • πŸ”§ Network Profile Management - Create and delete location-based profiles for different Wi-Fi networks
  • πŸ“‘ Static IP Configuration - Set custom IP addresses, gateways, and subnet masks
  • 🌐 DNS Server Configuration - Set custom DNS servers (Google DNS, Cloudflare, OpenDNS, etc.)
  • πŸ” Proxy Support - Configure HTTP/HTTPS proxies per network location
  • πŸ”„ Auto-Switching - Automatically switch network profiles when connecting to different Wi-Fi networks
  • πŸ—‘οΈ Easy Profile Deletion - Remove unwanted network profiles with confirmation prompts
  • 🍏 Apple Silicon Compatible - Uses ipconfig for M1/M2/M3 Mac compatibility
  • 🚫 Zero Dependencies - Pure Bash - no Python, Node.js, or external libraries required
  • 🎨 Beautiful CLI Interface - Color-coded output with ASCII art for a modern terminal experience

πŸš€ Quick Start

Prerequisites

  • macOS 10.12 or later
  • Administrator (sudo) access

Installation

  1. Download macNetty:

    curl -O https://raw.githubusercontent.com/lakminagamage/macNetty/main/macNetty.sh
    chmod +x macNetty.sh
  2. Run the wizard:

    sudo ./macNetty.sh

That's it! No compilation, no dependencies, no package managers.

πŸ“– Usage

Main Menu Options

When you run macNetty, you'll see four options:

[1] Create New Network Profile
[2] Delete Network Profile
[3] Install Auto-Switcher (Set & Forget)
[4] Exit

Option 1: Create New Network Profile

Create a custom network configuration for a specific Wi-Fi network:

  1. Enter the exact Wi-Fi SSID (network name)
  2. Choose whether to use Static IP (optional)
    • Enter IP Address, Gateway, and Subnet Mask
  3. Choose whether to configure a Proxy (optional)
    • Enter Proxy Host and Port
  4. Choose whether to set custom DNS servers (optional)
    • Enter Primary DNS (e.g., 8.8.8.8 for Google DNS)
    • Enter Secondary DNS (optional, e.g., 8.8.4.4)

Example Use Case: Configure your office Wi-Fi with a static IP, custom DNS, and proxy, while your home Wi-Fi uses DHCP.

Option 2: Delete Network Profile

Remove an existing network profile:

  1. Select option [2] from the main menu
  2. View the list of all available network profiles
  3. Enter the exact name of the profile you want to delete
  4. Confirm deletion when prompted

Safety Features:

  • Lists all profiles before deletion
  • Requires exact profile name match
  • Asks for confirmation before removing
  • Shows clear success/error messages

Example Use Case: Remove old network profiles for Wi-Fi networks you no longer use, such as previous workplace networks or temporary hotspots.

Option 3: Install Auto-Switcher

Set up automatic network profile switching:

  • Monitors your Wi-Fi connection every 10 seconds
  • Automatically switches to the matching network profile when you connect to a known Wi-Fi network
  • Runs silently in the background via macOS LaunchAgent
  • Logs activity to /tmp/wifichanger.log

Perfect for: Users who frequently move between home, office, coffee shops, etc.

πŸ”§ How It Works

Network Profiles

macNetty uses macOS's built-in Network Locations feature (networksetup) to create and manage profiles. Each Wi-Fi SSID gets its own location with custom settings.

Auto-Switching

The auto-switcher works by:

  1. Creating a monitor script (~/.locationchanger/monitor.sh)
  2. Installing a LaunchAgent that runs the script every 10 seconds
  3. Comparing current Wi-Fi SSID to current network location
  4. Switching locations automatically when they don't match

The monitor script uses ipconfig getsummary en0 for Apple Silicon compatibility, ensuring it works on both Intel and ARM-based Macs.

πŸ“ Examples

Configure Static IP for Office Network

sudo ./macNetty.sh
# Select [1] Create New Network Profile
# Enter SSID: OfficeWiFi
# Static IP? y
# IP: 192.168.10.100
# Gateway: 192.168.10.1
# Subnet: 255.255.255.0
# Proxy? n
# Custom DNS? n

Configure Home Network with Custom DNS

sudo ./macNetty.sh
# Select [1] Create New Network Profile
# Enter SSID: HomeWiFi
# Static IP? n
# Proxy? n
# Custom DNS? y
# Primary DNS: 8.8.8.8          # Google DNS
# Secondary DNS: 8.8.4.4        # Google DNS backup

Popular DNS Providers

  • Google Public DNS: 8.8.8.8 / 8.8.4.4
  • Cloudflare DNS: 1.1.1.1 / 1.0.0.1
  • OpenDNS: 208.67.222.222 / 208.67.220.220
  • Quad9: 9.9.9.9 / 149.112.112.112

Delete Old Network Profile

sudo ./macNetty.sh
# Select [2] Delete Network Profile
# View the list of profiles
# Enter profile name: OldOfficeWiFi
# Confirm deletion: y
# Profile deleted!

Setup Auto-Switching

sudo ./macNetty.sh
# First, create profiles for each network (option 1)
# Then select [3] Install Auto-Switcher
# Done! Your Mac will now auto-switch

πŸ› Troubleshooting

Auto-switcher not working?

Check if the LaunchAgent is running:

launchctl list | grep wifichanger

View logs:

tail -f /tmp/wifichanger.log

Permission errors?

Make sure you're running with sudo:

sudo ./macNetty.sh

Network not switching?

Verify the location was created:

networksetup -listlocations

Check current location:

networksetup -getcurrentlocation

🀝 Contributing

Contributions are welcome! Here's how you can help:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Ideas for Contributions

  • IPv6 support
  • VPN integration
  • Export/import profiles
  • Network quality testing (ping, speed test)
  • GUI wrapper
  • Homebrew formula
  • Bluetooth network configuration

πŸ“„ License

This project is licensed under the MIT License.

πŸ™ Acknowledgments

The Wi-Fi network based automation tool is inspired by eprev's locationchanger script. Thanks for your contribution!

πŸ“¬ Support

If you find macNetty useful, please:

  • ⭐ Star this repository
  • πŸ› Report bugs via Issues
  • πŸ’‘ Suggest features via Issues
  • πŸ“’ Share with others who might benefit

Made with ❀️ for Mac users who love the terminal

About

Simple Network config manager and WIFI Network based automation CLI tool for MacOS

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors