AD SPACE AVAILABLE · BRAND PARTNERS WELCOME

Put 365 Wiki to work with your AI

Copy the prompt below, paste it into the AI you already use, then ask your question.

Download full Skill

Try it with the prompt first. If you use 365 Wiki often, install the full 365Wiki Skill so you do not have to paste it again. No regular AI? Gemini or Microsoft Copilot on the web will work.

365Wiki Skill

i365Finds Editorial is the independent research and editorial organization behind 365 Wiki. We follow changes in tools, products, services, entertainment, and digital life around the world, turning scattered and fast-moving information into clearly sourced, well-structured public content that is easier to understand and compare.
Indexed 90,207 Wiki articles

Why Cross-Border Git Operations and SSH File Transfers Freeze Over VPNs

傅星達 · 365Finds Editorial

Your SSH shell opens instantly. Running ls, git status, or editing a file in Vim works without the slightest hiccup. Then you run git push origin main or attempt to transfer a build artifact via scp, and everything stops dead. The terminal displays Writing objects: 100% (42/42), 1.20 MiB | 312.00 KiB/s, and the cursor just blinks. Minutes pass. No error message appears, no connection reset is sent, and the session eventually dies of a broken pipe or silent timeout.

At 365Finds, we encounter this exact failure pattern constantly when debugging cross-border remote developer setups. It is not an SSH authentication bug, it is not a corrupted Git packfile, and it is rarely severe network congestion. What you are witnessing is a Path MTU Discovery (PMTUD) black hole, triggered by the collision of VPN encapsulation overhead, the IP Don't Fragment bit, and border firewalls that treat ICMP error packets as hostile traffic.

The Anatomy of the Freeze

To understand why small interactive packets fly through while large file transfers freeze mid-stream, you have to look at the packet sizes negotiated during a TCP handshake.

Standard physical Ethernet carries a Maximum Transmission Unit (MTU) of 1500 bytes. In an unencapsulated IPv4 TCP connection, subtracting the 20-byte IP header and the 20-byte TCP header leaves a Maximum Segment Size (MSS) of 1460 bytes. During the initial three-way handshake (SYN, SYN-ACK), your client and the remote Git host or SSH server agree to send packets up to this size.

When you bring a cross-border VPN into the equation—whether based on WireGuard, OpenVPN, or IPsec—the tunnel wraps your original IP packet inside another layer of transport and encryption headers:

If your physical network link has a base MTU of 1500 bytes, a WireGuard tunnel must lower its internal interface MTU to 1420 bytes (or 1280 bytes on IPv6) so that the encapsulated packet does not exceed 1500 bytes on the physical wire.

Standard Ethernet Frame:
[ IP (20B) ] [ TCP (20B) ] [ Payload / MSS (up to 1460B) ] = 1500 Bytes

VPN Encapsulated Frame:
[ Outer IP ] [ Tunnel / Crypto Header ] [ Inner IP ] [ Inner TCP ] [ Payload ]
|<---------------------------- Max 1500 Bytes on Wire -------------------------->|
|<---------- Tunnel Overhead --------->|<-------- Inner MTU (e.g., 1420B) -------->|

Here is where the breakdown occurs. When you type commands in an interactive SSH session, each keystroke and output line generates packets measuring between 60 and 200 bytes. They slip effortlessly through any tunnel.

When you push a Git commit containing binaries or transfer a tarball via scp, the operating system's TCP stack enters bulk transfer mode. It immediately saturates the connection with maximum-length segments (typically 1460 bytes of data payload plus headers).

To prevent IP fragmentation—which degrades routing efficiency and reassembly performance—operating systems set the Don't Fragment (DF) flag in the IP header of these TCP packets.

How the PMTU Black Hole Is Created

According to RFC 1191, when a packet with the DF flag set arrives at an intermediate router or tunnel endpoint whose next-hop MTU is smaller than the packet size, the router must perform two actions:

  1. Drop the oversized packet.
  2. Send an ICMP Type 3, Code 4 message (Destination Unreachable: Fragmentation Needed and DF Set) back to the sender, containing the MTU of the restrictive link.

Upon receiving that ICMP notice, your local TCP stack dynamically reduces its Path MTU (PMTU) estimate for that connection and retransmits the data in smaller chunks.

In cross-border scenarios, this feedback loop breaks down entirely:

[ Developer Client ]                     [ Border / Cloud Gateway ]                 [ GitHub / Remote Host ]
         |                                           |                                          |
         |=== TCP SYN (MSS=1460, DF=1) =============>|=========================================>|
         |<== TCP SYN-ACK (MSS=1460, DF=1) ==========|<=========================================|
         |                                           |                                          |
         |--- Interactive SSH (Small packets, OK) -->|----------------------------------------->|
         |                                           |                                          |
         |=== Bulk Data (1500B packet, DF=1) =======>| (Link MTU = 1380B)                       |
         |                                           | PACKET DROPPED                           |
         |                                           | Attempts to send ICMP Type 3 Code 4      |
         |                                           X  <-- BLOCKED by ISP / Transit Firewall   |
         |                                                                                      |
         | (No ICMP received: sender waits, retransmits 1500B, packet dropped again)             |
         | CONNECTION SILENTLY FREEZES (PMTU Black Hole)                                        |
  1. Overzealous Border Firewalls: Cross-border transit providers, national firewalls, and aggressive enterprise network edge devices frequently drop all incoming ICMP packets indiscriminately, miscategorizing them as security vulnerabilities, ping sweeps, or DDoS attack vectors.
  2. Asymmetric Routing and Anycast: When connecting to cloud hosting providers like GitHub or AWS, outbound traffic may exit through one transit link while return traffic flows across another. The ICMP error message generated by a middlebox often routes back toward an interface that is not tracking the original state, discarding the notification.
  3. Underlying PPPoE and Carrier Encapsulation: Many remote developers connect via residential or regional broadband using PPPoE, which already trims the base MTU down to 1492 bytes. Add double NAT, carrier-grade MPLS labels (4 to 8 bytes each), and corporate VPN tunnels, and the true clear-path MTU may drop to 1380 or 1360 bytes without either endpoint realizing it.

Because your machine never receives the ICMP "Fragmentation Needed" notice, it assumes the lost packet was merely a casualty of standard network packet loss. It retransmits the exact same 1500-byte segment. The intermediate router drops it again. Your machine retransmits again, backing off exponentially, while the remote server sits waiting for data that will never arrive. The connection hangs frozen in place until a timeout threshold is reached.

Diagnosing the Black Hole on Your Connection

Before changing system configurations, confirm whether an MTU bottleneck is actually causing your stall.

1. Test the Maximum Path MTU via Ping

Send ICMP echo packets with the Don't Fragment bit enabled, testing progressively smaller payload sizes. Remember that an IPv4 header takes 20 bytes and an ICMP header takes 8 bytes (total 28 bytes of protocol overhead). A payload size of 1472 bytes tests a total packet size of 1500 bytes (1472 + 28 = 1500).

On Linux:

ping -M do -s 1472 <remote_host_or_ip>

If you get ping: local error: Message too long, mtu=... or no replies at all, step the payload size down:

ping -M do -s 1380 <remote_host_or_ip>
ping -M do -s 1352 <remote_host_or_ip>

On macOS:

ping -D -s 1472 <remote_host_or_ip>

On Windows (PowerShell or Command Prompt):

ping -f -l 1472 <remote_host_or_ip>

When you find the largest payload size that returns replies without fragmentation errors, add 28 to that number to determine your true workable Path MTU. If a payload of 1372 bytes succeeds while 1373 fails, your Path MTU is exactly 1400 bytes.

2. Inspect SSH and Git Verbose Logs

Run your Git push or SSH command with elevated debug verbosity:

GIT_SSH_COMMAND="ssh -vvv" git push origin main

In a PMTU black hole scenario, you will observe the SSH key exchange and session authentication succeed rapidly. The freeze will occur immediately after the debug log prints lines related to opening the session channel or sending bulk payload streams:

debug2: channel 0: window 2097152 sent adjust 131072
Writing objects:  45% (18/40)

No errors will follow; the client simply stops receiving TCP ACKs for full-frame packets.

How to Fix It: Practical Solutions

Depending on whether you manage the client machine, the VPN gateway, or only your local configuration, here are the targeted remedies.

Solution 1: TCP MSS Clamping on the VPN Gateway or Router (The Institutional Fix)

If you administer the VPN server, corporate border router, or home firewall, configuring TCP MSS clamping is the cleanest approach. It dynamically intercepts TCP SYN packets passing through the router and rewrites the advertised MSS value so that neither endpoint ever attempts to transmit a packet larger than the tunnel MTU.

On Linux / iptables:

# Clamp MSS automatically to the path MTU
sudo iptables -t mangle -A FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu

# Or clamp explicitly to a conservative safe value (e.g., 1360 bytes)
sudo iptables -t mangle -A FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --set-mss 1360

On nftables:

table inet filter {
    chain forward {
        type filter hook forward priority 0; policy accept;
        tcp flags syn tcp option maxseg size set rt mtu
    }
}

On pfSense / OPNsense: Navigate to Interfaces > [Your WAN or VPN Interface], and set MSS to 1360 (or go to System > Advanced > Networking and adjust the global MSS clamping value).

Solution 2: Enable RFC 4821 Packetization Layer MTU Probing (Linux Clients)

RFC 4821 defines Packetization Layer Path MTU Discovery (PLPMTUD). Instead of relying on unreliable ICMP messages, the Linux TCP stack probes the path directly by sending full-sized and smaller segments, automatically detecting when large segments fail to receive acknowledgments.

To enable it temporarily:

sudo sysctl -w net.ipv4.tcp_mtu_probing=1

A value of 1 turns on probing when a black hole is suspected (retransmissions spike). A value of 2 forces probing on all outgoing TCP connections unconditionally.

To make this persistent across reboots, add the directive to /etc/sysctl.conf or /etc/sysctl.d/99-pmtud.conf:

net.ipv4.tcp_mtu_probing = 1

Then apply the change:

sudo sysctl -p

We at 365Finds consider this one of the most effective client-side safeguards for Linux engineers working across international corporate VPNs, because it works transparently without requiring server reconfiguration.

Solution 3: Manually Reduce Client Interface MTU

If your VPN client software created an interface with an MTU that is too optimistic (for example, WireGuard defaulting to 1420 on a connection that actually traverses PPPoE and double encapsulation), lower the interface MTU directly.

On Linux:

# For a WireGuard interface
sudo ip link set dev wg0 mtu 1360

# For a TUN interface (OpenVPN)
sudo ip link set dev tun0 mtu 1360

On macOS: Open Terminal and find your active network interface name via ifconfig, then lower its MTU:

# For Wi-Fi (typically en0)
sudo networksetup -setMTU en0 1360
# Or directly via ifconfig
sudo ifconfig en0 mtu 1360

On Windows (PowerShell as Administrator):

# View subinterfaces and their current MTU
netsh interface ipv4 show subinterfaces

# Set MTU on your VPN adapter or Wi-Fi
netsh interface ipv4 set subinterface "Wi-Fi" mtu=1360 store=persistent

Setting the interface MTU to 1360 or 1280 eliminates oversized packet creation at the source. The slight cost is a negligible increase in packet headers across bulk downloads, but the stall is eradicated.

Solution 4: OpenSSH and Git Configuration Adjustments

If you cannot change network interfaces or sysctl parameters—such as on a restricted work laptop—you can adjust how OpenSSH and Git operate.

In ~/.ssh/config, add the following rules for your Git repository hosts:

Host github.com gitlab.com *.company.internal
    IPQoS lowdelay throughput
    ServerAliveInterval 15
    ServerAliveCountMax 3

Certain intermediate enterprise proxies and packet inspection engines drop SSH packets tagged with modern DSCP QoS markers (such as af21). Setting IPQoS lowdelay throughput or IPQoS 0x00 forces OpenSSH to avoid markers that confuse cross-border transit routers.

Alternatively, switch Git from SSH to HTTPS if the remote repository supports it:

git remote set-url origin https://github.com/org/repo.git

While HTTPS connections still run over TCP and can theoretically encounter PMTU drops, HTTPS traffic is heavily prioritized and accelerated through CDN edge nodes (such as Cloudflare or Fastly), where TLS termination and MSS clamping are routinely handled by the provider's reverse proxies.

Summary Comparison of Mitigation Strategies

Mitigation LevelImplementation MethodRoot Cause Addressed?Requires Admin Privileges?Operational Scope
Router / Gatewayiptables TCPMSS clamp-to-pmtuYes, prevents oversized segments at network edgeYes (Router root)All devices on local or VPN network
Kernel Stack (Linux)net.ipv4.tcp_mtu_probing = 1Yes, discovers safe MTU without ICMPYes (Client root)All TCP traffic from the client host
Interface MTUSet tunnel or NIC MTU to 1360Yes, forces lower MSS at TCP connection setupYes (Client root/admin)All traffic passing through that interface
SSH / Git ConfigIPQoS lowdelay throughputPartially, bypasses DSCP filtering issuesNoGit and SSH operations only
Transport SwitchMove from SSH to HTTPS remote URLWorkaround, uses edge reverse proxiesNoTarget Git repository only

References