Surge 把你的 Mac 变成最强路由器
date
Jan 16, 2021
slug
MacSurgeRouter
status
Published
tags
路由器
代理
技术
summary
最近一两年我用过很多路由器:斐讯 n1、NanoPi r2s、NanoPi r4s、华硕 ax86u 等等都是蛮热门的产品。但在我前俩天买了用了 Mac 的 Surge 当作家里的路由器后,方便和体验真的是回不去了。
type
Post
最近一两年我用过很多路由器:斐讯 n1、NanoPi r2s、NanoPi r4s、华硕 ax86u 等等都是蛮热门的产品。但在我前俩天买了用了 Mac 的 Surge 当作家里的路由器后,方便和体验真的是回不去了。
关于 surge 4 的教程特别是 DHCP 当做路由器,我看网上的资料教程实在是很少,自己查也废了不少功夫,就写个教程做个视频分享给大家。温馨提示:首先你得有台放在家里,最好接着网线的 Mac 系统电脑;还有就是你要花几百块买 Surge 这个软件。
Surge 是一个很强大的网络工具,不仅仅是一个代理软件;目前 Surge 是版本买断制度的,你可以直接在官网购买,然后就能一直使用 Surge 4 这个大的版本了。
Surge DHCP 接管网络
1 添加 Surge 的配置文件
你订阅的服务应该会给 Surge 的订阅链接,如果没有也没关系,你可以通过第三方 订阅转换 生成(推荐用这个,分流会丰富合理很多):
![notion image](https://www.notion.so/image/https%3A%2F%2Foss.qust.me%2Fimg%2F20210116211324.png?table=block&id=c0dd0d73-4400-42c3-bf86-753e68529663&cache=v2)
- 订阅链接填上你的 v2ray、ss 、trojan 的订阅
- 客户端选择 surge 4
- 选择生成订阅链接就好了
打开 surge 设置中的配置
![notion image](https://www.notion.so/image/https%3A%2F%2Foss.qust.me%2Fimg%2F20210116211500.png?table=block&id=7c548809-ed0e-4eed-a92d-7b95426e7242&cache=v2)
选择从 url 安装配置
![notion image](https://www.notion.so/image/https%3A%2F%2Foss.qust.me%2Fimg%2F20210116211555.png?table=block&id=6b490933-a410-48d2-a732-4c1374f76bfd&cache=v2)
粘贴上你的配置文件订阅地址后选择完成
![notion image](https://www.notion.so/image/https%3A%2F%2Foss.qust.me%2Fimg%2F20210116211622.png?table=block&id=06c8714e-881d-4eca-ad55-e43c23661ac2&cache=v2)
选中刚才添加的点击 应用
![notion image](https://www.notion.so/image/https%3A%2F%2Foss.qust.me%2Fimg%2F20210116211641.png?table=block&id=9a9ea0d9-2318-4186-b9c2-db9202b1f7e4&cache=v2)
在策略里选择 规则判定,这时候你应该就能愉快的上网了。
![notion image](https://www.notion.so/image/https%3A%2F%2Foss.qust.me%2Fimg%2F20210116211714.png?table=block&id=fcb8f778-474d-4a3a-8f64-24413bd85cd1&cache=v2)
如果不行可以重新退出打开下 surge,并检查是否打开了 设置为系统代理 和 增强模式。
![notion image](https://www.notion.so/image/https%3A%2F%2Foss.qust.me%2Fimg%2F20210116211730.png?table=block&id=2c9ea9b4-f7df-4a18-a2c2-ead26c21d987&cache=v2)
2 配置 Surge DHCP 接管网络
设置电脑 IP 为静态IP
打开 系统偏好设置-网络,选择以太网(也就是网线接口),配置 IPv4 选择 使用 DHCP(手动设定地址),我的路由器是 192.168.88.1 所以 IP 地址我就填 192.168.88.2,只用修改最后一位在 2-225 之间就行。(如果你的路由器是 192.168.31.1 你的 IP 地址就可以填 192.168.31.2,以此类推)随后选择 应用。
![notion image](https://www.notion.so/image/https%3A%2F%2Foss.qust.me%2Fimg%2F20210116212721.png?table=block&id=22a1be43-f1e3-4dc4-bc2c-c64c90fdad3c&cache=v2)
关闭路由器 DHCP
一般都在 内部网络-DHCP服务器 选项里,关闭启用 DHCP, 保存并应用。(各家系统的设置位置可能有差别,但基本都是有 DHCP 开关选项的)
![notion image](https://www.notion.so/image/https%3A%2F%2Foss.qust.me%2Fimg%2F20210116212428.png?table=block&id=68d59f31-e93b-43c1-ac19-31cdd947cc16&cache=v2)
打开 Surge DHCP 选项
在左侧 设备 里,点开后有 DHCP 服务器 开关,点开后请认真看下内容,然后选择下一步。
![notion image](https://www.notion.so/image/https%3A%2F%2Foss.qust.me%2Fimg%2F20210116221722.png?table=block&id=cb305704-2fc7-4d79-850a-b4e5f68ca31b&cache=v2)
网络设备和你上面设置固定的 IP 的一致,插网线的选择 Ethernet 就行,继续下一步。
![notion image](https://www.notion.so/image/https%3A%2F%2Foss.qust.me%2Fimg%2F20210116212820.png?table=block&id=b6c2b0c3-3c34-4d30-b54e-8b7ecbadfc9f&cache=v2)
Surge 会检测当前网络环境是否有 DHCP 设置,如果上面你正确关闭了 路由器 DHCP 这里应该能直接过去。
![notion image](https://www.notion.so/image/https%3A%2F%2Foss.qust.me%2Fimg%2F20210116213020.png?table=block&id=523e1301-3126-4db9-81c3-c07d4e451481&cache=v2)
选择 Surge 默认的设置点击完成即可,如果你懂的可以自行修改。
![notion image](https://www.notion.so/image/https%3A%2F%2Foss.qust.me%2Fimg%2F20210116213337.png?table=block&id=9d7a13aa-7709-4374-b558-dd4b96ed01a2&cache=v2)
把你其它设备重新连接 wifi 或者关闭路由器 wifi 再打开即可看到 设备里新增设备。
![notion image](https://www.notion.so/image/https%3A%2F%2Foss.qust.me%2Fimg%2F20210116213153.png?table=block&id=15bf0ce1-ccc4-40b8-a353-c3426755f8a3&cache=v2)
如果你想你连接的设备通过 Surge 走代理服务,你可以右键选择设备名然后选择 使用 Surge 作为网关,再设备重新连接或者关闭路由器 wifi 再打开即可。
![notion image](https://www.notion.so/image/https%3A%2F%2Foss.qust.me%2Fimg%2F20210116213225.png?table=block&id=2dda0666-59e6-4511-be1d-5e7e1cffe5c5&cache=v2)
Surge DHCP 使用模块
我只购买了 Mac 版的 Surge,但我想我的手机也能实现除了能用代理外,也能使用 微博去广告、Netflix 有评分、看 tiktok 不用拔掉 sim 卡。如果你也想使用 Module 的功能可以继续往下看,这部分可能稍微有点麻烦。
Mac 创建证书
- 打开 钥匙串访问 app(Keychain Access.app)
- 选择菜单项 钥匙串访问 (Keychain Access) -> 证书助理 (Certificate Assistant) -> 创建证书颁发机构 Create Certificate Authority…
![notion image](https://www.notion.so/image/https%3A%2F%2Foss.qust.me%2Fimg%2F20210116221318.png?table=block&id=d8c5e14c-2437-4e77-9590-a676d5f4854a&cache=v2)
- 证书参数(名字邮箱随意填写)点击创建即可,记下倒出的位置,后面要用到。
![notion image](https://www.notion.so/image/https%3A%2F%2Foss.qust.me%2Fimg%2F20210116222932.png?table=block&id=7c7faacc-886f-4f64-8988-7770c691deae&cache=v2)
- 证书创建后,在左侧选择 我的证书 (My Certificates),然后在右侧列表中找到该证书,右键点击证书,选择导出,导出格式选择为 .p12 格式,导出时需要设置 密码 (passphrase),不可设置为空。若不可选择 p12 格式,请确认先切换到我的证书 (My Certificates) 后再进行导出。
![notion image](https://www.notion.so/image/https%3A%2F%2Foss.qust.me%2Fimg%2F20210116223054.png?table=block&id=9c417cd3-07e1-4a8f-814c-fe25e209196f&cache=v2)
![notion image](https://www.notion.so/image/https%3A%2F%2Foss.qust.me%2Fimg%2F20210116223108.png?table=block&id=9b782f5b-5322-40e5-af77-e450ce2101f0&cache=v2)
- 将证书复制到左侧 Keychains 列表中的 System 中 粘贴 (不做该步骤会使得 Safari 不认该 CA,不过 Chrome 可以正常工作)输入刚才添加的密码完成。
![notion image](https://www.notion.so/image/https%3A%2F%2Foss.qust.me%2Fimg%2F20210116223550.png?table=block&id=de42eb06-0bdc-426e-b15a-529439850cbf&cache=v2)
![notion image](https://www.notion.so/image/https%3A%2F%2Foss.qust.me%2Fimg%2F20210116223604.png?table=block&id=3c1877f1-fcd3-4f7e-a182-1ce99a15227b&cache=v2)
- 双击证书,将该证书标记为可信,关闭窗口输入登录密码确认操作。
![notion image](https://www.notion.so/image/https%3A%2F%2Foss.qust.me%2Fimg%2F20210116223630.png?table=block&id=ab649221-f8a9-4f42-b1b3-8822549349f2&cache=v2)
- 将得到的 Certificates.p12 文件用在 terminal 中进行 base64 编码,得到结果会用到。
![notion image](https://www.notion.so/image/https%3A%2F%2Foss.qust.me%2Fimg%2F20210116224319.png?table=block&id=b5ba63d5-6fc1-43cc-b759-dea49c59c5e6&cache=v2)
- 编辑 Surge 的配置文件(设置-配置-在 Finder 中找到配置;然后用文本编辑器打开),加入 MITM 段。ca-passphrase = 填写你之前的密码,ca-p12 = 填写你刚 base64 出来的结果。
![notion image](https://www.notion.so/image/https%3A%2F%2Foss.qust.me%2Fimg%2F20210116224523.png?table=block&id=9c84be0d-fe23-4422-9d71-918f33540968&cache=v2)
![notion image](https://www.notion.so/image/https%3A%2F%2Foss.qust.me%2Fimg%2F20210116224533.png?table=block&id=fea4393b-e514-4e2e-a805-ce1866041f9f&cache=v2)
- 打开再文件里右键刚才编辑好的文件选 Surge 打开,选择覆盖,便会使用新的配置文件。
![notion image](https://www.notion.so/image/https%3A%2F%2Foss.qust.me%2Fimg%2F20210116224637.png?table=block&id=79fc9ce9-3f31-4810-87ed-26e8aecb16da&cache=v2)
![notion image](https://www.notion.so/image/https%3A%2F%2Foss.qust.me%2Fimg%2F20210116224646.png?table=block&id=5b9baf21-b8db-443d-b348-ea0e72140845&cache=v2)
- 在 解密 中打开 HTTPS 解密开关。
![notion image](https://www.notion.so/image/https%3A%2F%2Foss.qust.me%2Fimg%2F20210116224919.png?table=block&id=b4614395-511e-4e76-88e6-d9699bd0604f&cache=v2)
发送证书到手机安装
- 在 Surge 解密 中选择为 iOS 模拟器倒出证书
![notion image](https://www.notion.so/image/https%3A%2F%2Foss.qust.me%2Fimg%2F20210116225450.png?table=block&id=da0055ce-153a-4d1d-8ae7-003b85787363&cache=v2)
- 发送证书到手机(airdrop 或者别的方式发到手机上)。
![notion image](https://www.notion.so/image/https%3A%2F%2Foss.qust.me%2Fimg%2F20210116231352.png?table=block&id=75cf10a8-817d-4169-a4ff-1d1a608759ac&cache=v2)
- 在手机打开描述文件,设置里选择已下载的描述文件-安装描述文件-选择同意输入密码即可。
- 最后在 设置通用关于手机 打开对证书的信任。
Surge 安装打开模块
在设置中打开模块选择从 URL 安装模块,安装这个模块选择开启后应用即可。
![notion image](https://www.notion.so/image/https%3A%2F%2Foss.qust.me%2Fimg%2F20210116232936.png?table=block&id=8d62e672-a87d-4291-a602-63ced7dfeb6e&cache=v2)
![notion image](https://www.notion.so/image/https%3A%2F%2Foss.qust.me%2Fimg%2F20210116234315.png?table=block&id=f889eda0-4fdf-4de4-af0d-beb10e98dc78&cache=v2)
更多模块功能可以看看这里(上面是我做了一个合并的,免拔卡看 tiktok、Netflix 评分、微博去广告 等等)
也可以看看这个 module 使用教程:https://merlinblog.xyz/wiki/surge-module.html
总结
如果有有问题可以看看 surge 开发者详细的文章:https://blankwonder.medium.com
如果对这篇教程有疑问也可以发邮件给我 [email protected]