Repolode
YTwsy

YTwsy/OpenSurge-for-Mac

A macOS gateway app that turns a Mac into a Surge-style transparent proxy with per-device routing, DHCP/DNS via dnsmasq, and mihomo as the proxy engine.

Open-source alternative to:Surge

Stars
2,603
Forks
184
Open issues
10
Last commit
3 days ago

What is it?

OpenSurge for Mac runs a Mac as a home network gateway. dnsmasq provides DHCP and DNS, mihomo handles proxying and routing, and macOS pf and IP forwarding carry IPv4 traffic. The default mode is a bypass router: the main router keeps its DHCP, and selected devices are pointed at the Mac as gateway and DNS. A LAN DHCP takeover mode and a separate downstream LAN mode with its own AP, SSID or VLAN are also available for automatic onboarding.

Each registered device can use its own egress policy, such as rule-based routing for a phone, a US node for a game console, and a streaming node for a TV. Policies are defined through a JSON file or the web GUI, and per-device connections, traffic and egress chains are shown in real time. Subscriptions and existing mihomo profiles can be imported, and Tailscale or Headscale can be added as an outbound.

A menu bar app and a local web GUI handle status, network recovery alerts, and start or stop operations. An experimental downstream IPv6 path routes IPv6 traffic through a BPF packet broker into a patched mihomo. The repository also documents an AI-agent-oriented workflow with a virtual LAN lab for testing high-risk network changes.

Key features

  • 01Per-device egress policies for registered LAN devices, including rule, global-proxy and reject actions
  • 02DHCP and DNS served by dnsmasq, with bypass-router, LAN takeover and downstream LAN modes
  • 03mihomo-based transparent proxying through TUN, plus explicit mixed-port proxy
  • 04Real-time per-device connection, traffic and egress chain views in the web GUI
  • 05Import of existing mihomo profiles and subscriptions, with rollback on failed starts
  • 06Experimental downstream IPv6 takeover via RA/SLAAC and a BPF packet broker

Use cases

  • Routing a phone, TV or game console through different proxy nodes without configuring each app
  • Taking over DHCP and DNS on a home LAN so new devices get the proxy automatically
  • Adding a separate Wi-Fi network or VLAN whose traffic all goes through a chosen egress
  • Routing traffic from a Mac through a Tailscale exit node alongside other policies

In collections

Topics

#proxy#gateway#dnsmasq#mihomo#dhcp#dns#policy-routing#transparent-proxy#home-network#macos

FAQ

What is OpenSurge-for-Mac?
A macOS gateway app that turns a Mac into a Surge-style transparent proxy with per-device routing, DHCP/DNS via dnsmasq, and mihomo as the proxy engine. OpenSurge for Mac runs a Mac as a home network gateway. dnsmasq provides DHCP and DNS, mihomo handles proxying and routing, and macOS pf and IP forwarding carry IPv4 traffic. The default mode is a bypass router: the main router keeps its DHCP, and selected devices are pointed at the Mac as gateway and DNS. A LAN DHCP takeover mode and a separate downstream LAN mode with its own AP, SSID or VLAN are also available for automatic onboarding.
Is OpenSurge-for-Mac free to use? What license does it have?
OpenSurge-for-Mac is open source under the GPL-3.0 license. Check the license terms before using it in commercial products.
Is OpenSurge-for-Mac still maintained?
Actively maintained. The last commit to OpenSurge-for-Mac was on Nov 4, 2026.
What can I use OpenSurge-for-Mac for?
Routing a phone, TV or game console through different proxy nodes without configuring each app Taking over DHCP and DNS on a home LAN so new devices get the proxy automatically Adding a separate Wi-Fi network or VLAN whose traffic all goes through a chosen egress Routing traffic from a Mac through a Tailscale exit node alongside other policies
Where can I get OpenSurge-for-Mac?
The source code and installation instructions are on GitHub: https://github.com/YTwsy/OpenSurge-for-Mac

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects