How to Configure Multipath TCP (MPTCP) on Linux: Aggregate Bandwidth and Keep Connections Alive

Network tutorial - IT technology blog
Network tutorial - IT technology blog

At 2:15 AM, my phone wouldn’t stop buzzing with alerts from our monitoring system. The server that syncs around 120 GB of data every night between two branch offices was suddenly throwing timeout errors across the board. Our rsync jobs and long-lived API connections kept dropping mid-transfer, even though when I SSHed in to check, the backup network link was running without a hitch.

1. The Real-World Problem: Two Active Links, Yet Connections Still Drop

That server had two physical NICs connected to two separate ISPs. eth0 used our primary 100 Mbps fiber line, while eth1 connected to a 50 Mbps backup line on a different subnet. Normally, all file-sync traffic went out over eth0. That night, unscheduled maintenance on the primary ISP caused eth0 to drop up to 40% of its packets, stalling active TCP sessions before throwing Connection reset by peer.

Half-asleep, I checked the routing table to see if the two interfaces had overlapping IPs or a misconfigured gateway. When my brain is fried, I usually pull up toolcraft.app/en/tools/developer/ip-subnet-calculator to quickly calculate subnets — just type in the CIDR and you immediately get the network range, broadcast address, and host count without doing mental math. Both the IPs and routes were completely fine. So why were TCP connections dying when two healthy links were available?

2. The Root Cause: Traditional TCP’s Rigid Binding

The culprit wasn’t a bad cable or NIC — it was the design of legacy TCP itself. A standard TCP connection is rigidly bound to a 4-tuple:

  • Source IP
  • Source Port
  • Destination IP
  • Destination Port

When an application opens a session over eth0 (IP 10.10.10.15), that connection is “locked” to that address. Even though eth1 (IP 10.10.20.15) still has full Internet access, the Linux kernel cannot just move an active data stream over to the other IP. If the source IP changes mid-session, the remote server treats those packets as unknown traffic and rejects them immediately.

At this point, many engineers think of Network Bonding (LACP). However, Bonding operates at Layer 2. It requires both network ports to plug into the same switch (or switch stack) and share the same subnet. With two independent ISPs, two routers, and two completely separate subnets like on my server, Bonding simply won’t work.

3. Choosing a Solution: Why I Skipped the Usual Workarounds

Before settling on the final approach, I weighed three options:

  • Failover routing via metrics or healthcheck scripts: This only saves new connections by routing them through eth1 after eth0 goes down. Any in-progress file transfer or long-lived database connection still drops. On top of that, eth1 sits idle during normal operation, wasting bandwidth.
  • Building tunnels (WireGuard/GRE) with ECMP or modifying app code: Writing custom stream-splitting logic at the application layer takes way too much effort. Meanwhile, wrapping traffic in a VPN tunnel to aggregate links reduces MTU, adds latency, and burns extra CPU on packet encapsulation.
  • Enabling Multipath TCP (MPTCP) in the Linux kernel: This is a TCP extension (RFC 8684) built directly into the Linux kernel since version 5.6.

At the application layer, MPTCP still looks like a normal TCP socket. Underneath, the kernel automatically creates multiple sub-streams (called subflows) running in parallel across both eth0 and eth1. This aggregates the bandwidth of both links. If one link drops unexpectedly, traffic immediately shifts to the remaining subflow without the application ever noticing.

4. Deploying Multipath TCP (MPTCP) on Linux

We don’t need to modify or recompile Nginx, curl, or rsync. Just enable MPTCP in the kernel and wrap the application with the included mptcpize tool, and it’s ready for production.

Step 1: Check Your Kernel Version and Enable MPTCP

First, make sure the server is running Linux kernel 5.6 or newer (Ubuntu 22.04/24.04, Debian 12, and RHEL 9 all include it out of the box):

uname -r
# Example output: 6.8.0-45-generic

Next, enable MPTCP via sysctl and write it to a config file so it persists across reboots:

sudo sysctl -w net.mptcp.enabled=1
echo "net.mptcp.enabled=1" | sudo tee /etc/sysctl.d/99-mptcp.conf

Step 2: Install mptcpd and iproute2

Modern versions of iproute2 already include the ip mptcp command. You just need to install mptcpd to get the mptcpize utility for legacy TCP applications:

# On Ubuntu / Debian
sudo apt update && sudo apt install -y mptcpd iproute2

# On RHEL / Rocky Linux / AlmaLinux
sudo dnf install -y mptcpd iproute

Step 3: Configure Endpoints and Subflow Limits

Assume the Client has IP 10.10.10.15 on eth0 (primary) and 10.10.20.15 on eth1 (secondary). The destination server also has multiple IPs, or at least one public IP with MPTCP enabled.

On the Client, cap the maximum number of subflows per connection at 2. At the same time, declare eth1 as a secondary path so the kernel proactively opens an additional subflow during the MPTCP handshake:

# Allow up to 2 subflows per MPTCP connection
sudo ip mptcp limits set subflow 2 add_addr_accepted 2

# Add endpoint on eth1 with the subflow flag
sudo ip mptcp endpoint add 10.10.20.15 dev eth1 subflow

# Verify the configuration
ip mptcp endpoint show
ip mptcp limits show

On the Destination Server (for example, if it has a secondary IP 192.168.50.10 on eth1), use the signal flag so the server advertises its available addresses to the client:

sudo ip mptcp limits set subflow 2 add_addr_accepted 2
sudo ip mptcp endpoint add 192.168.50.10 dev eth1 signal

Important note: To prevent packets from eth1 from mistakenly routing out through eth0‘s gateway (asymmetric routing), you need to configure Policy-Based Routing (ip rule) with a separate routing table for each NIC.

Step 4: Wrap Applications with mptcpize Without Touching Code

Most software written in C or Python still calls socket(AF_INET, SOCK_STREAM, IPPROTO_TCP) instead of IPPROTO_MPTCP. Rather than editing source code, just launch the command with mptcpize run on both ends (note that this uses LD_PRELOAD, so it works for dynamically linked binaries like Nginx, curl, and rsync):

# On the Destination Server: wrap the listening service
sudo mptcpize run python3 -m http.server 8080

# On the Client: test downloading a large file over MPTCP
mptcpize run curl -O http://DEST_SERVER_IP:8080/backup-db.tar.gz

For services managed by systemd, run sudo systemctl edit service-name and prepend mptcpize run right before the executable path on the ExecStart= line.

Step 5: Verify Subflows and Run a Pull-the-Plug Test

While the file is downloading, open another terminal to inspect MPTCP connections with ss -M or check kernel packet counters:

ss -M
nstat -az | grep -i MPTcp

When you see MPTcpExtMPCapableSYNTX, MPTcpExtMPCapableSYNACKRX, and MPTcpExtMPJoinSynAckRx climbing steadily, both ends have completed the handshake and are running multiple subflows in parallel. In my real-world test across the 100 Mbps + 50 Mbps links, combined download throughput hit around 140 Mbps. Now let’s bring down the primary NIC:

sudo ip link set eth0 down

Watch the curl or rsync process: throughput dips briefly for 1–2 seconds and then continues at 50 Mbps over eth1, with zero errors and no restart from scratch. Once eth0 comes back up, new connections automatically use both links again.

5. A Few Things to Check Before Going to Production

  • Both sides must have MPTCP enabled: If one side doesn’t support it, the connection automatically falls back to standard TCP, so you won’t break existing services.
  • Check firewalls and middleboxes: MPTCP uses TCP Option 30 in SYN packets. Some older hardware firewalls with strict rulesets may strip or block this option, forcing the session to fall back to regular TCP.
  • Monitor per-interface traffic: Use iftop or nload on each interface to confirm traffic is actually being balanced across both links.

After that late-night incident, switching our sync pipeline to MPTCP completely eliminated mid-transfer drops whenever an ISP hiccupped. And our 50 Mbps backup line, which used to sit idle, now helps carry the nightly load.

Share: