When using the Wireguard VPN client on Unifi devices, users often encounter problems with TCP connections. These issues can include degraded performance, frequent connection drops, and packet loss. You will notice this issue when you are trying to load some website or streaming a videos. The root cause of these problems is typically related to the Maximum Segment Size (MSS) of TCP packets.
This issue has been discussed in detail on the Unifi community forum.
These steps will ensure that iptables
rules is applied to fix TCP MSS issues automatically at boot and periodically by the cron job (every minute). Kudos to @Arrange6704 and @sgoneil for detailing the steps on the Unifi forum.
-
Connect to your Unifi device using SSH as root:
- Open a terminal and connect to your Unifi device:
ssh root@<IP_ADDRESS>
- Replace
<IP_ADDRESS>
with the IP address of your Unifi device.
- Open a terminal and connect to your Unifi device:
-
Install
on-boot-script
by following this guide unifios-utilities:- Easy install (not recommended):
curl -fsL "https://raw.githubusercontent.com/unifi-utilities/unifios-utilities/HEAD/on-boot-script/remote_install.sh" | /bin/bash
- Easy install (not recommended):
-
Navigate to the
on_boot.d
directory:cd /data/on_boot.d
-
Download the cron-jobs on-boot example script:
wget https://raw.githubusercontent.com/unifi-utilities/unifios-utilities/main/on-boot-script/examples/udm-files/on_boot.d/25-add-cron-jobs.sh
-
Make the script executable:
chmod +x 25-add-cron-jobs.sh
-
Create the cronjobs directory and navigate to directory:
mkdir /data/cronjobs cd /data/cronjobs
-
Create and edit the cron job for Wireguard MSS:
vi /data/cronjobs/wg_mss
- Add the content of
wg_mss
to the file:
- Add the content of
-
Create the scripts directory and navigate to directory:
mkdir /data/scripts cd /data/scripts
-
Create and edit the Wireguard MSS script:
vi /data/scripts/1-set-wireguard-mss.sh
- Add the content of
1-set-wireguard-mss.sh
to the file
- Add the content of
-
Make the script executable:
chmod +x /data/scripts/1-set-wireguard-mss.sh
-
Copy cron jobs to the system cron directory:
cp /data/cronjobs/* /etc/cron.d/
-
Restart the cron service:
/etc/init.d/cron restart