VPN Setup by sergei-thinker

repository·master·Indexed 41 days ago

https://github.com/sergei-thinker/vpn-setup

A multi-layered VPN deployment system designed to bypass advanced internet censorship (DPI/TSPU) in Russia. It utilizes VLESS Reality, Cloudflare CDN, and 3X-UI, featuring automated deployment via Claude Code and advanced split routing for iOS (Shadowrocket), Android (v2rayNG), and Windows/Android (Hiddify) to ensure Russian services remain accessible via direct connections.

Tokens
29.6K
Snippets
65
Records
129
Agent score
51%

What's inside vpn-setup

  1. Overview of the Multi-layer VPN System

    master

    This project provides a multi-layer VPN infrastructure designed to bypass internet censorship (DPI/TSPU) using VLESS Reality. The system masks VPN traffic as standard HTTPS requests to major providers like Microsoft, Google, or Apple.

    Key features include:

    • Automatic Failover: The system switches between connection layers if one is blocked.
    • Split Routing: Russian websites (banks, government services, VK, Yandex) are routed directly without VPN to ensure speed and avoid suspicion.
    • Layered Architecture:
      • Layer 0 (Primary): VLESS Reality via a foreign VPS.
      • Layer 1 (Relay): Russian Relay VPS (e.g., Timeweb, VDSina) used if the primary VPS IP is blocked.
      • Layer 2 (Emergency): WebRTC / Telemost (Desktop only).
      • Layer 3 (Backup): Cloudflare CDN (for Wi-Fi environments).
  2. Overview of the VPN Infrastructure Project

    master
    This project provides complete documentation for setting up a personal VPN based on the VLESS Reality protocol combined with Cloudflare CDN. It is designed to bypass censorship and provide a secure, private connection using a multi-layered architecture.
  3. How DPI and TSPU blocking methods work

    master

    TSPU (Technical Means of Counteracting Threats) devices managed by regulators use DPI (Deep Packet Inspection) to analyze traffic. They use several methods to identify and block VPNs:

    MethodDescription
    IP BlockingComplete blocking of TCP traffic, including SSH
    Signature BlockingDetecting VPN protocols by analyzing the first bytes of a packet
    Behavioral AnalysisAnalyzing patterns such as volume, frequency, and connection types
    ThrottlingReducing connection speeds to unusable levels rather than a hard block
    Session FreezingTSPU 'freezes' TCP sessions that exceed 15-20 KB

    Note on Network Types: Mobile operators (e.g., MTS, Megafon, Beeline) apply much more aggressive blocking than home Wi-Fi providers. A VPN configuration that works on Wi-Fi may fail on LTE.

  4. Avoid risky desktop applications when using VPN

    master

    Certain applications are known to use system calls (like getifaddrs() or GetAdaptersAddresses()) to bypass VPN tunnels or leak the real IP to local services. It is recommended NOT to run these on the same machine as an active VPN:

    ApplicationRisk
    Яндекс.Браузер (Yandex Browser)Built-in leak mechanisms
    VK МессенджерSimilar to Yandex
    Антивирус Касперского (Kaspersky)High privileges, hidden connections
    Яндекс.Диск / Яндекс.МузыкаEcosystem data aggregation
    RuStore, МойОфис, Р7-ОфисNon-transparent technical specifications
    ICQ New, 2GISPotential for reverse engineering

    Alternatives: Use web versions in containerized browsers, an isolated VM/Docker, or a separate Windows user profile.

  5. How VLESS + XTLS Reality works

    master

    VLESS Reality is a protocol designed to make VPN traffic indistinguishable from a standard HTTPS connection to a major website (like Microsoft, Google, or Apple).

    The workflow is as follows:

    1. The client establishes a TLS connection with your server.
    2. To an external observer (DPI), the connection appears to be directed at a legitimate site (e.g., www.microsoft.com).
    3. If a 'suspicious' check is performed, Reality provides the real certificate of the target site.
    4. Your actual traffic is transmitted via the VLESS protocol inside the TLS tunnel.
    5. The xtls-rprx-vision flow is used to optimize data transmission by avoiding double-encryption of already encrypted data.
  6. Understand Layer 3: Cloudflare CDN (Domain Fronting)

    master

    Layer 3 uses Cloudflare CDN to mask your VPS IP address. This is useful on home Wi-Fi if your provider blocks your VPS IP directly. Instead of connecting to your VPS, the client connects to Cloudflare, which then proxies the traffic to your VPS.

    Warning: As of April 2026, Cloudflare is actively being blocked by TSPU. Layer 3 does not work on mobile networks with white-list restrictions. For mobile internet, use Layer 1 (relay on a Russian VPS).

  7. Understand the connection priority (auto-select) logic

    master

    The client follows a specific priority order when attempting to establish a connection. It will attempt to use the highest priority method that is currently unblocked:

    1. reality-main:443 (Lowest latency)
    2. reality-google:8443 (Fallback SNI)
    3. reality-apple:2053 (Fallback SNI)
    4. Relay via Russian VPS (Timeweb/VDSina/Selectel/VK Cloud) - Used if the main VPS IP is blacklisted. Note: Yandex Cloud is not recommended for this layer as it does not bypass TSPU white-lists effectively.
    5. WebRTC (Emergency fallback for strict white-lists)
    6. ws-cloudflare:2082 (Cloudflare CDN - Wi-Fi only, subject to TSPU blocks).
  8. Understand the VPN architecture layers

    master

    The project implements a multi-layered VPN architecture to bypass different types of network restrictions (DPI, white-lists, etc.):

    • Layer 0 (Direct Connection): Uses a VPS (EU, KVM, Debian 12) running VLESS Reality on port 443 with microsoft.com as the SNI. Includes BBR, TCP tuning, and Nginx camouflage.
    • Layer 1 (Relay via RU VPS): Uses a Russian VPS (e.g., Timeweb, VDSina) as a relay. The client connects to the RU relay via VLESS xHTTP Reality (port 10443), which then relays traffic to the main EU VPS. This is the recommended method for bypassing mobile network white-lists.
    • Layer 3 (Cloudflare CDN): Uses a domain and Cloudflare Workers (vpn-ws-proxy) to front the connection. Note: This layer may be ineffective against white-lists implemented by TSPU (middle-of-2025 onwards).

    Critical Note: Avoid using Yandex Cloud for this setup, as its IP ranges are subject to blocking under active white-list regimes.

  9. Compare VPN router compatibility and methods

    master

    When choosing a router setup, consider the platform and the protocol. Standard protocols like WireGuard or OpenVPN are easily detected by DPI in Russia. VLESS Reality is recommended because it masks traffic as standard HTTPS (e.g., to microsoft.com).

    PlatformVLESS RealityComplexityRecommendation
    Keenetic (XKeen)ExcellentMediumBest for RU
    OpenWrt (PassWall2)ExcellentHighUniversal
    ASUS Merlin (XrayUI)GoodMediumFor ASUS owners
    MikroTik (container)PoorVery HighNot recommended
    TP-Link (stock)No support—Flash to OpenWrt
    Xiaomi (stock)No support—Flash to OpenWrt
  10. How the VLESS WebSocket Proxy works

    master

    The proxy facilitates a connection between a client and a VLESS backend through the Cloudflare CDN using the following flow:

    Client (v2ray/xray) ──WSS 443──▶ Cloudflare CDN ──WS 2082──▶ VPS (VLESS)

    1. The client initiates a WebSocket connection to the worker URL on port 443.
    2. Cloudflare terminates the TLS connection.
    3. The Worker forwards the WebSocket connection to the backend VPS on port 2082.
    4. Any requests that do not match the configured WS_PATH are served a generic landing page, hiding the existence of the proxy.
  11. Configure Split Routing for Russian Sites

    master

    Split routing allows Russian domains and IP addresses to connect directly (DIRECT) while routing all other traffic through the VLESS Reality VPN. This prevents latency issues, avoids CAPTCHAs on Yandex/VK, and prevents banks or government services (Gosuslugi) from blocking Swedish IP addresses.

    Ready-to-use configuration files are located in the client-configs/ directory for various platforms:

    • shadowrocket-rules.conf: iOS (Shadowrocket)
    • v2rayng-routing.json: Android (v2rayNG)
    • hiddify-routing.txt: Windows (Hiddify)
    • xray-server-routing.json: Server (3X-UI)
  12. Advanced DPI Bypass Methods

    master

    Beyond the VPN setup, several methods can be used to bypass Deep Packet Inspection (DPI) locally:

    ECH (Encrypted Client Hello)

    Encrypts the SNI field in the TLS ClientHello so DPI cannot see the destination domain.

    • Cloudflare (Layer 3): Works automatically.
    • Xray-core: Does not support this natively yet.
    • Client Support: Chrome 117+ and Firefox 118+ support ECH.

    QUIC Transport

    Uses UDP-based transport to bypass TCP-focused DPI.

    • Warning: Many Russian operators throttle or block unknown UDP. Use with caution; not recommended as a primary method.

    Local DPI Bypass Tools (No Server Required)

    These tools use TCP/TLS fragmentation to bypass DPI. They generally work on home Wi-Fi but often fail on mobile LTE.