没有不值得去解决的问题,也没有不值得去学习的技术!

Optimizing WireGuard VPN: Direct Local Access With VPN for Foreign Traffic

Mobile optimized configuration (for form field editing, only change 2 fields) as shown in Figure 1

⚠️ Important Update (2026-06)

The approach in this article is an early practice version of WireGuard traffic splitting.

In practical use, this method has clear limitations in the following scenarios:

  • Complex route maintenance
  • Insufficient GeoIP accuracy
  • Inability to adapt to the Clash rule system
  • Prone to mistakenly routing domestic traffic through the VPN

👉 Latest recommended solution (tested and optimized):
🚀 WireGuard + Clash Verge Rev for Direct Domestic / Split Foreign Traffic (Vultr & ZgoCloud Practical Evolution Edition)

I recently set up my own WireGuard VPN with the original intention of accessing overseas websites, only to encounter a frustrating issue: domestic websites loaded extremely slowly, stuttered, and occasionally timed out. Upon investigation, I found that all traffic (including domestic websites) was being routed through the WireGuard VPN by default, and detouring naturally slowed things down.
The core requirement was clear: allow domestic websites and local network devices to connect directly without going through the VPN, while routing only overseas websites through the WireGuard tunnel. This ensures smooth overseas access without affecting domestic web page loading speeds. Based on my own configuration and hands-on process, I have put together a complete solution suitable for the official Windows and mobile WireGuard clients, which beginners can directly copy and use.
Note: I recommend also referring to: WireGuard Direct Domestic + Foreign Tunnel Configuration Pitfalls and Perfect Solution (Tested and Working) , as this blog post offers a more thorough solution.

1. Root Cause: Default Global Proxy Causes Domestic Traffic to Detour
First, let’s look at my initial WireGuard configuration (common for both PC and mobile), which is the default configuration issue many encounter after setting up their own VPN:

Plaintext
[Interface]
PrivateKey = MNcoOjHNvao4gH1+xDV5IO6...
Address = 10.66.66.2/32, fd42:42:42::2/128
DNS = 1.1.1.1, 1.0.0.1

[Peer]
PublicKey = XZ2LNJxO7RqjGKHyubFw...
PresharedKey = Fz04FNeapuPYQ+QAH+yNQHIT...
AllowedIPs = 0.0.0.0/0, ::/0
Endpoint = 139.180.154.26:57586

The problem lies in two areas:

  1. Poor DNS choice: Using 1.1.1.1 and 1.0.0.1, which are overseas DNS servers, causes detours when resolving domestic websites, leading to high resolution latency or even resolution failures.
  2. Global proxy via AllowedIPs: 0.0.0.0/0, ::/0 means all IPv4 and IPv6 traffic goes through the VPN tunnel. Traffic to domestic websites and local network devices is forcibly relayed, naturally slowing it down.

2. Optimization Strategy: Precise Traffic Splitting, Direct Domestic, Foreign via VPN
The core optimization logic is simple and requires no complex scripts. You only need to modify two configuration points to let WireGuard automatically distinguish between domestic and overseas traffic:

  • Change the DNS to a domestic public DNS to improve domestic website resolution speed;
  • Adjust AllowedIPs so that only overseas IP ranges go through the VPN, while domestic IPs and local network IPs connect directly.
    Let’s focus on the adjustment logic for AllowedIPs: instead of manually adding all domestic IP ranges (which is too cumbersome), we use reverse thinking—specifying “overseas IP ranges” to go through the VPN, leaving all remaining IPs (domestic, internal network) to connect directly.
    The selected overseas IP range combination: 0.0.0.0/1, 128.0.0.0/2. Together, these two network ranges exactly cover all overseas public IPv4 addresses. Domestic IP ranges and local network IPs (192.168.x.x, 172.16.x.x, 10.x.x.x) will automatically be excluded from the VPN tunnel.

3. Final Optimized Configuration (Independent configs for PC and mobile, just change 2 core fields in each)
Note: I created 2 separate WireGuard configurations for my PC and mobile, rather than using a single shared config. However, whether on PC (editing the config file) or mobile (editing form fields), you only need to modify 2 core fields without changing anything else. Below are the complete optimized configurations for both (you can copy/modify the corresponding fields directly).
(1) PC Optimized Configuration (For file editing, direct copy and replace)
On PC, you can directly edit the configuration file, select all, and replace the original content. Only the DNS and AllowedIPs fields have been modified:

Plaintext
[Interface]
PrivateKey = MNcoOjHNvao4gH1+xDV5IO6...
Address = 10.66.66.2/32, fd42:42:42::2/128
# Domestic Alibaba public DNS, fast resolution speed, avoids detours
DNS = 223.5.5.5, 223.6.6.6

[Peer]
PublicKey = XZ2LNJxO7RqjGKHyubFw...
PresharedKey = Fz04FNeapuPYQ+QAH+yNQHIT...
# Only overseas IPv4 traffic goes through VPN, domestic and internal network connect directly
AllowedIPs = 0.0.0.0/1, 128.0.0.0/2
# Remove IPv6 global proxy (::/0) to prevent domestic IPv6 traffic from detouring
Endpoint = 139.180.154.26:57586

(2) Mobile Optimized Configuration (For form field editing, only change 2 fields) as shown in Figure 1

Mobile optimized configuration (for form field editing, only change 2 fields) as shown in Figure 1


The mobile configuration is independent; there is no need to copy the entire file. Just modify the following 2 fields in the form (keep all other fields unchanged):

  • DNS servers: Delete the original 1.1.1.1, 1.0.0.1 and change to 223.5.5.5, 223.6.6.6
  • Remote (Peer) – Routed IP addresses (ranges): Delete the original 0.0.0.0/0, ::/0 and change to 0.0.0.0/1, 128.0.0.0/2
    Tip: Other fields on the mobile client (such as PrivateKey, PublicKey, Endpoint, etc.) should remain exactly as they were when the configuration was created. No changes are needed; just modify the two core fields above.
    Additional note: The core optimization logic for both the PC and mobile configurations is exactly the same. Both achieve traffic splitting by modifying DNS and AllowedIPs. The only difference is that the PC edits the full file while the mobile edits the corresponding form fields. Both operations are extremely simple.

4. Key Precautions (Crucial for Avoiding Pitfalls)
The first time I modified the config, I only changed the DNS and AllowedIPs, overlooking one detail that caused minor issues. Make sure to pay attention to this:

  • You must remove the IPv6 global proxy ::/0: If you do not remove it, all IPv6 traffic from your phone/PC will still go through the VPN, causing domestic apps (like WeChat, Douyin) to stutter and suffer high latency;
  • No need to add extra scripts: Many tutorials recommend using a China IP list + routing scripts. In fact, for the official client, simply adjusting AllowedIPs achieves precise traffic splitting without complex operations;
  • No server-side modifications needed: All optimizations are done on the client side. Keep the server configuration as is to avoid misconfigurations that could prevent the VPN from connecting.

5. Verification Method (Ensuring the Configuration Works)
After configuration, verify with these 3 simple steps to confirm direct domestic connection and foreign traffic via VPN:

  1. Test domestic websites: Open Baidu, Bilibili, Taobao, Douyin. They should load extremely fast, identical to when the VPN is disabled, with no latency;
  2. Test overseas websites: Open GitHub, Google, etc. If they load normally, it means the VPN is working;
  3. Test the local network: Access your home router’s backend (e.g., 192.168.1.1). If it opens normally, it means local network traffic is not going through the VPN.

6. Common Issue Resolution
If you encounter the following issues after configuration, refer to the corresponding solutions:

  • Certain overseas websites won’t open: Most likely the website’s IP is not within the 0.0.0.0/1, 128.0.0.0/2 network range. You can tell me the website’s domain, and I can fine-tune the network range;
  • Increased battery drain or connection drops on mobile: You can streamline the configuration by removing IPv6-related addresses (fd42:42:42::2/128) and keeping only the IPv4 configuration;
  • Domestic websites still stuttering: Check if you removed ::/0, or restart the WireGuard tunnel and reboot the device.
    Summary
    After setting up a WireGuard VPN, the core reason for domestic website stuttering is the “global proxy”. By precisely adjusting DNS and AllowedIPs, you can achieve the goal of “direct domestic connection, foreign via VPN”. This configuration requires no complex scripts, is compatible with the official mobile and PC clients, and is ready to use via simple copy-paste, making it easy for beginners to pick up.
    If your WireGuard configuration is similar to mine and you encounter the same issues, simply replace it with the configuration above to perfectly resolve the stuttering problem, balancing overseas access with domestic experience.

⚠️ This solution is no longer recommended.

As Clash Verge Rev and its rule-based traffic splitting system have matured,
the current best practice has evolved into a “WireGuard + Clash hybrid traffic splitting architecture”.

👉 For the new solution, please refer to:
🚀 WireGuard + Clash Verge Rev for Direct Domestic / Split Foreign Traffic (Vultr & ZgoCloud Practical Evolution Edition)

系列导航

关于作者 · 持续学习与技术实践

我是一名拥有 15 年以上开发经验的技术从业者,自 2013 年起持续运营个人技术博客,记录工作与个人项目中遇到的真实问题,以及解决问题过程中的探索、实践和思考。

除了技术写作,我也在持续开发和维护自己的独立项目,探索新技术和新工具在实际场景中的应用。我始终相信,没有不值得去解决的问题,也没有不值得去学习的技术。

如果这篇文章对你有所帮助,欢迎浏览博客中的其他文章,也欢迎交流技术经验与想法。

关于我  ·  GitHub  ·  邮件联系