DEV Community

Cover image for How to modify the MTU of the VPN connection to solve the problem of frequent disconnections and pages that cannot be opened
Keith
Keith

Posted on

How to modify the MTU of the VPN connection to solve the problem of frequent disconnections and pages that cannot be opened

How to modify the MTU of the VPN connection to solve the problem of frequent disconnections and pages that cannot be opened
MTU is the maximum transmission unit, which refers to the maximum packet size that can pass through a certain layer of a communication protocol. Why do you need to modify the MTU? Most devices originally support automatic MTU negotiation through the ICMP protocol. But unfortunately, more and more networks block ICMP transmission, which makes the function of MTU auto-negotiation impossible. An incorrect MTU will cause many problems: • Repeatedly dropped connections • Sudden congestion during large data transfers • Pages that won't open, or open slowly • Parts of the page content or styles are lost.
How to modify the MTU of the VPN connection to solve the problem of frequent disconnections and pages that cannot be opened.
MTU introduction: MTU is the maximum transmission unit, which refers to the maximum packet size that can pass through a certain layer of a communication protocol.
Why do you need to modify the MTU
Most devices natively support MTU auto-negotiation via the ICMP protocol.
But unfortunately, more and more networks block ICMP transmission, which makes the function of MTU auto-negotiation impossible. Incorrect MTU will cause many problems:
• Repeatedly disconnected connections
• Sudden congestion when a large amount of data is transmitted
• The page does not open, or opens slowly
• Part of the page content or style is missing
No problems, no need to modify: If you do not encounter any of the above problems, it means that your current network environment has perfectly supported MTU auto-negotiation, and it is recommended not to modify any settings.
How to modify MTU
•Windows
•Mac OS X
•Linux
•iPhone, iPad, Android modify MTU
Windows 8 and Windows 7 modify MTU
On Windows 8 and Windows 7, you can permanently modify the MTU of a VPN connection by using the following methods, and you do not need to set it again after reconnecting or restarting the computer in the future.

  1. Connect to the VPN whose MTU you want to modify
  2. Open a command prompt with administrator privileges, enter the following command in it, it will list all network connections (including VPN connections) in your system netsh interface ipv4 show subinterfaces
  3. Find the VPN name you are connected to in the returned information

4. Enter the following command to modify and save the MTU of this VPN connection. (Please modify the VPN connection name in the following command to the VPN connection of your choice.)

Mac OS X modify MTU
Because OS X adjusts the VPN's MTU based on the MTU of your network connection (WiFi or Ethernet). Therefore, you only need to reduce the MTU of the network connection to reduce the MTU of the VPN.
Proceed as follows:

  1. Open System Preferences
  2. Click Network
  3. In the list on the left, select your network connection. Choose WiFi when you usually use WiFi, and choose Ethernet when you usually use a network cable.
  4. Click the Advanced button on the right
  5. Select the Hardware tab
  6. Select Manual for configuration, select Custom for MTU, enter 1328 in the following, which is right, click Save.
  7. When the interface returns to the network connection, click the Apply button in the lower right corner.
  8. If you are on WiFi, click to turn off WiFi and then re-enable it. If you are connected by a network cable, unplug the network cable and plug it back in again.

In this way, when connecting to the VPN, the MTU of the VPN will be the smaller 1280.

Linux modify MTU

Under Linux, only connections established manually under /etc/ppp/peers can modify mtu and mru through configuration files. Connections established using NetworkManager, on the other hand, ignore the MTU setting in the configuration file.
You can use the following command to temporarily modify the MTU after connecting, but this modification will be invalid after the connection is disconnected or the system is restarted.
sudo ifconfig ppp0 mtu 1280


iPhone, iPad, Android modify MTU
Due to the limitation of the operating system, the MTU cannot be modified temporarily, or the modification method is very complicated.
If these devices cannot use PPTP due to MTU reasons, you can try L2TP instead.

Top comments (0)