# Cursor 在 VPN 下穩定運作:Split Routing > 本文章適用於 Windows / macOS / Linux 許多公司使用 Fortinet、Cisco AnyConnect、PaloAlto GlobalProtect、SonicWall 等等 VPN。我們在遠端開發時常會需要開 VPN 才能存取公司的 code、SSH 到主機、使用內網 API,但 Cursor 在 VPN 下非常不穩定,會遇到類似狀況: ![image](https://hackmd.io/_uploads/r13pwh1M-x.png) 原因是: > VPN 通常會攔截、修改、掃描或切斷 WebSocket 流量 > 而 Cursor 的 AI 互動(尤其 parallel agents)高度依賴 WebSocket。 結果: * 關 VPN → Cursor 雖然正常但不實際,畢竟你需要 VPN 才能工作 XD * 開 VPN → Cursor 爆炸,沒法正常用 這篇提供一種可以在本地端嘗試的方式。 ## Split Routing 我們透過 `Split Routing` 讓公司內網走 VPN,讓 Cursor 走外網 ## Windows ### Step 1:查 Cursor 的 IP ```bash nslookup cursor.sh ``` 通常得到: ```bash Name: cursor.sh Address: 76.76.21.21 ``` ### Step 2:查你的本地 Gateway(外網出口) ```bash route print ``` 找到: ```bash 0.0.0.0 ... 192.168.1.1 ``` → `192.168.1.1` 就是你的外網 gateway。 ### Step 3:加入「讓 Cursor 走外網」的永久路由 以系統管理員身份執行: ```bash route -p add 76.76.21.21 mask 255.255.255.255 192.168.1.1 metric 1 ``` 把 Cursor 的伺服器 IP(例如 76.76.21.21)導到本地 gateway,不走 VPN。 ### Step 4:確認 ```bash route print | findstr 76.76.21.21 ``` ## macOS ### Step 1:查 Cursor IP ```bash nslookup cursor.sh ``` 通常: ```bash 76.76.21.21 ``` ### Step 2:查本地 gateway ```bash route -n get default ``` 得到: ```bash gateway: 192.168.1.1 ``` ### Step 3:新增 routing(臨時) ```bash sudo route add -host 76.76.21.21 192.168.1.1 ``` ### Step 4:確認: ```bash netstat -nr | grep 76.76.21.21 ``` ### Step 5:如果需要「永久」生效 新增 `/Library/LaunchDaemons/com.cursor.splitrouting.plist`: ```xml <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>com.cursor.splitrouting</string> <key>ProgramArguments</key> <array> <string>/sbin/route</string> <string>add</string> <string>-host</string> <string>76.76.21.21</string> <string>192.168.1.1</string> </array> <key>RunAtLoad</key> <true/> </dict> </plist> ``` 然後使用: ```bash sudo launchctl load /Library/LaunchDaemons/com.cursor.splitrouting.plist ``` ## Linux ### Step 1:查 Cursor IP ```bash nslookup cursor.sh ``` → 通常是 `76.76.21.21` ### Step 2:查本地 gateway ```bash ip route | grep default ``` 通常: ```bash default via 192.168.1.1 dev wlan0 ``` ### Step 3:加入 routing(臨時) ```bash sudo ip route add 76.76.21.21 via 192.168.1.1 ``` ### Step 4:確認 ```bash ip route | grep 76.76.21.21 ``` ### Step 5:如果想永久生效(取決於 distro) **Ubuntu** / **Debian**:加入 `/etc/network/interfaces` 或 `/etc/netplan/*.yaml` 範例(netplan): ```yaml routes: - to: 76.76.21.21/32 via: 192.168.1.1 ``` 然後使用: ```bash sudo netplan apply ``` ## 總結 核心動作只有一件事: > 只把 Cursor 的伺服器 IP 導到本地 gateway,不走 VPN。 ### Why this work: Cursor 是 WebSocket-based 這會造成 VPN 有機會檢查並且切斷 WebSocket 我們透過 routing 讓: * Cursor 流量走外網(避免 VPN) * SSH / Git / 內網仍走 VPN(保留工作需求)