MacOS VPN 路由設定
使用 root 權限新增腳本 /etc/ppp/ip-up ,記得 chmod +x:
#!/bin/bash
# 參數說明參考:https://superuser.com/questions/4904
# $1 是VPN 使用的介面名稱,比如 ppp0
# $2 沒查到
# $3 VPN Server 的 IP
# $4 VPN gateway IP
# $5 Regular (non-vpn) gateway for your lan connections (複製貼上懶得翻)
# 檢查這次連線的 VPN 是否是適用於此規則的 VPN
if [ "$5" = "1.0.0.1" ]; then
# 要走 VPN 的網段,這裡以 10.0.0.0/8 為例
/sbin/route add -net 10.0.0.0/8 -interface $1
# 刪除預設路由,不然出去的線路會亂跳,控制台那邊的設定好像沒效?
/sbin/route delete -net default -ifscope $1
fi
Leave a Comment