banner
lMingyul

lMingyul

记录穿过自己的万物
jike

Use Surge to turn your Mac into a home network hub

This article documents how to use Surge to turn your Mac into a proxy for other devices in your home to access the internet scientifically.

Background#

This year, during the 618 shopping festival, I got my first handheld gaming console, the Nintendo Switch OLED version (Japanese version). Switch games can be downloaded from the eShop, but accessing and downloading games from the eShop directly in China is extremely slow. I learned that the eShop on the Switch requires a game accelerator to function properly, similar to Steam. However, the UU accelerator requires an annual fee of 283 RMB, which I hesitated to spend (yes, I'm the type who doesn't blink when buying expensive items but is very picky when it comes to cheap accessories 🙄).

I remembered seeing others use Surge to proxy their Mac so that the Apple TV could access the internet smoothly (scientifically). I searched online for tutorials, and indeed it was possible, which led to this tutorial, serving as a record for future reference.

Preliminary Environment Setup#

  • Surge for Mac (using the Mac as an intermediary to proxy other devices)
  • Mac Studio (connected via Ethernet; once configured, it cannot be shut down. I found that the Surge software automatically exits when the Mac goes to sleep, so the computer needs to stay awake. If it does sleep, it needs to be restarted to continue using it.)
    • M1 Max
    • RAM: 64 G
    • OS: macOS Monterey 12.4
    • ANNW94-2022-07-02-162212
  • Airport subscription address (if you don't have one, you'll need to find one 😂; essential for scientific internet access)

The following tutorial assumes that the above three conditions have been met


Surge#

Introduction to Surge#

Overview#

Surge is a network development and proxy tool. It is designed for developers, so a certain level of expertise is required to use it.

7xbnGO-2022-07-02-165248

The following four are the core workflows of Surge.

  • Interception: Intercept network connections initiated by devices. Surge supports two interception modes: proxy server and virtual network card.
  • Processing: Modify intercepted network requests and responses. This includes URL redirection, local file mapping, and custom modifications using JavaScript, among other methods.
  • Forwarding: Forward intercepted network requests to other proxy servers. This can be global forwarding or determined by a flexible rule system for outbound policies.
  • Interception: Intercept and save data from network requests and responses, and decrypt HTTPS traffic via MITM.

We mainly use forwarding here.

Features#

I was mainly attracted to Surge because of its features:

  • High performance, stability, and efficiency: Surge can easily handle network data while consuming very few resources and maintaining high stability, especially when paired with the M1 chip for better energy efficiency and stability.
  • Enhanced mode: Surge sets up a virtual network to intercept all network requests, especially those from software that poorly supports web proxies.
  • Gateway mode: Surge for Mac can act as a three-layer gateway to handle network requests from other devices on the same network. (In simple terms, it can act as a router, becoming the home network hub.)

Downloading and Purchasing Surge#

You can download Surge for Mac directly from the Surge official website. I downloaded the latest version, Surge 4.6.1 (1718). After downloading, it comes as a compressed file; just extract it and drag the app into the Applications folder to open and use it.

enlBCc-2022-07-02-170049

However, after downloading, you cannot access the internet scientifically right away; you still need to purchase a license. Go to the official website to purchase a license: 49.99 USD for one device, 69.99 USD for three devices, and 99.99 USD for five devices. Supports Alipay payment. I purchased a license for three devices (I wanted to set one up at home for the New Year, so I bought three), costing me 471.13 RMB (due to fluctuations in the exchange rate, it hurt my wallet). You can purchase according to your needs, but at least one device must be purchased.

After purchasing, you can activate Surge using the email address you used to purchase and the activation code sent to your email.


Let Surge Take Over Mac's Network#

Next, we can let Surge take over the network of the Mac (allowing the Mac to access the internet scientifically). At this point, you will need your airport subscription address.

Adding Configuration Files to Surge

Here, we will use the URL to install the configuration file. You can also import it via a file or add it manually.

If your airport subscription directly provides a Surge subscription address, you can add it directly. If not, but you have v2ray, ss, or trojan subscriptions, you can generate a Surge-compatible URL using third-party subscription conversion.

5WspOo-2022-07-02-172841

  1. Select basic mode; if you want to customize specific nodes, you can choose advanced mode.
  2. Paste your airport subscription address in the subscription link.
  3. In the client dropdown, select Surge4.
  4. Click the red button to generate the subscription link, and click copy.

Open the main interface of Surge, click on more in the lower left corner, and select Configuration in the settings.

FPlXiy-2022-07-02-173426

Select Install Configuration File from URL.

PFS43A-2022-07-02-173704

Paste the configuration file subscription address generated by the third party, then select finish, and wait a moment for Surge to import the rule policies.

EgzLZb-2022-07-02-174004

Once Surge completes recognition, a new hosted configuration will appear. Select this new configuration and click Apply in the lower right corner.

MePj6m-2022-07-02-175029

Return to the main interface of Surge, select the policy under proxy, and choose Rule Determination. At this point, check if scientific internet access is successful. If not, click the Surge tab to check if Set as System Proxy and Enhanced Mode are checked. If not, check them and restart Surge.

9d3KT2-2022-07-02-175857

At this point, your Mac can happily access the internet!


Making Mac the Home Network Hub#

The above steps have allowed the Mac to access the internet happily, but it's better to share the joy. How can we let other devices in the home access the internet happily as well?

This is where Surge's DHCP server feature comes into play, which is the Gateway Mode introduced above.

Set Computer IP to Static IP#

  1. Open System Preferences - Network, and select Ethernet (the wired connection).
  2. For IPv4 configuration, select Using DHCP (Manually Set Address).
  3. My router is 192.168.1.1, so I set the IP address to 192.168.1.2, only changing the last digit to be between 2-225. (If your router is 192.168.0.1, you can set your IP address to 192.168.0.2, and so on.)
  4. Then select Apply.

Note: Before setting this, make sure to turn off Surge's system proxy setting, as it may affect the IP address configuration. It is recommended to turn it off first and then turn it back on after completing the settings.

uTcDOP-2022-07-02-181712

Disable Router DHCP#

Log into your home router's management interface, find the DHCP server settings on the management page, and turn off the router's DHCP (most routers will have this option).

kiUr1q-2022-07-02-182242

Enable Surge DHCP Option#

In Surge, on the left side under Devices, click to open and find the DHCP Server switch at the bottom. Turn it on and select the next step.

XaJAvP-2022-07-02-183102

AKpMao-2022-07-02-183144

Select Ethernet for the wired connection and click next.

uPhRre-2022-07-02-183408

Surge will check the current network environment for DHCP settings. If you correctly disabled the router's DHCP, it should generate the configuration directly here.

iME4T0-2022-07-02-183608

Select Surge's default settings and click Finish. If you find that the router address is empty here (I got stuck here for a while because I selected the wrong network device, choosing Ethernet Adapter (en6)), you need to check where you went wrong.

eYfMhS-2022-07-02-183225

0qFKq7-2022-07-02-183745

After starting the DHCP server, you may see that there are no devices listed. At this point, you need to restart the router or have the devices you want to use reconnect to the Wi-Fi, and you should see them in the new devices list.

R6rAZy-2022-07-02-184417

Adding Device Members#

For devices that want to access the internet scientifically, you can right-click on the device name and select Use Surge as Gateway, then have the device reconnect to Wi-Fi or turn off the router's Wi-Fi and turn it back on.

If it doesn't connect, it will show waiting for connection. It is recommended to also check Set Fixed IP Address, which is the recommended practice on the official website for easier device management and connection in the future.

PLnbhq-2022-07-02-184957

m9E18F-2022-07-02-184849

For Apple phones and tablets, due to privacy concerns, they will default to using a private Wi-Fi address when connecting to Wi-Fi (using a private address helps reduce tracking of the iPhone across different wireless networks). You need to turn off this option and reconnect to Wi-Fi for Surge to recognize your device.

OwVf1i-2022-07-02-19070170fZUl-2022-07-02-190929EiIKd0-2022-07-02-191059

If you are unsure which IP address corresponds to which device, you can check the router management interface or infer based on the manufacturer of the IP.

Finally, it is recommended to change the IPv4 address of the device connected to Wi-Fi to manual, because if you enable automatic DHCP, the IP address may change the next time you connect to this Wi-Fi. If the connection fails, you can change the IPv4 address to manual according to the following configuration.

IMG_2A213714640D-1-2022-07-05-221811

Now, all devices in the home that want to access the internet scientifically can happily do so through the Mac computer as a network hub!

Special Cases#

Initially, when I used Surge as a gateway, I encountered a situation where the Mac could open YouTube videos and watch them, but other devices at home connected via Wi-Fi could not access Google. I checked and could open the YouTube app, but could only see the video thumbnails. When I clicked to open the video to watch, it remained in a loading state and could not be viewed. Strangely, I could open Netflix and watch shows normally.

The solution I found for this situation was to modify the DNS configuration of the Wi-Fi connection on the device needing to access YouTube, changing it from automatic to manual, and adding a DNS server of 192.0.2.2.

9pLUgY-2022-07-02-191508D4hRaT-2022-07-02-191714

YrtDRs-2022-07-02-192758

As for why this DNS address was set, I'm not quite sure; I just know that's what the manual says 🐶. This resolved the issue of not being able to access YouTube!


Conclusion#

In the future, if there are other devices that want to access the internet happily, they can use this Mac computer, enchanted by Surge, as a forwarding proxy, saving on the annual fee for an accelerator and providing better functionality with a wider coverage area. However, the Mac must remain powered on; otherwise, other devices in the home will not be able to access the internet.

This article only briefly used Surge's basic functions (the access policy rules were not customized) and there are many more customizations that can be made to Surge. These deeper features will be explored gradually in the future. For now, let's happily play with the newly arrived Switch! If you have any fun games to recommend, feel free to share!


References#

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.