How can I change MTU size permanently?












0















I go to this file /etc/dhcp/dhclient.confand add these two line before request line



default interface-mtu 1200;

supercede interface-mtu 1200;


and after I restart and system boot up and run ifconfig command , it says my MTU size is 1280 , Why??
How can I change it to exact 1200 ??



Update:



cat /etc/resolv.conf



lrwxrwxrwx 1 root root 29 Mar 19 13:05 /etc/resolv.conf -> ../run/resolvconf/resolv.conf


and the resolv.conf file



nameserver 1.1.1.1
nameserver 8.8.8.8
nameserver 2606:4700:4700::1111
nameserver 127.0.0.53
options edns0


the resolvectl output is :



Current DNS Server: 1.1.1.1
DNS Servers: 1.1.1.1
8.8.8.8
2606:4700:4700::1111
DNSSEC NTA: 10.in-addr.arpa


and the dpkg -l *dnsmasq* output is :



Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-
aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture
Description
+++-======================-================-================-
==================================================
un dnsmasq <none> <none> (no
description available)
ii dnsmasq-base 2.79-1 amd64 Small
caching DNS proxy and DHCP/TFTP server
un dnsmasq-base-lua <none> <none> (no
description available)









share|improve this question

























  • Which file? How are you obtaining your IP address?

    – waltinator
    Mar 21 at 12:47











  • Please explain. I don't know of ANY situation where MTU of 1200 is valid. What version Ubuntu? Using NetworkManager or netplan? Report back to @heynnema

    – heynnema
    Mar 21 at 14:10











  • sorry , my bad , I forgot to tell which file I changed , I edit the post , and I get my IP from dhcp @waltinator

    – Afshin
    Mar 21 at 20:15













  • I am using ubuntu 18.10 and when I used VPN I couldn't browse some websites like twitter and facebook etc but I could ping them with Domain Name , and I searched a lot so I saw a topic that says change your MTU size to 1200 ,and after I've done that my problem solved , but when I edit /etc/dhcp/dhclient.conf for changing MTU permanently the system change MTU to 1280 @heynnema

    – Afshin
    Mar 21 at 20:21











  • Maybe check my question and answer here askubuntu.com/questions/1007171/no-internet-over-vpn-connection

    – oscar1919
    Mar 21 at 20:34
















0















I go to this file /etc/dhcp/dhclient.confand add these two line before request line



default interface-mtu 1200;

supercede interface-mtu 1200;


and after I restart and system boot up and run ifconfig command , it says my MTU size is 1280 , Why??
How can I change it to exact 1200 ??



Update:



cat /etc/resolv.conf



lrwxrwxrwx 1 root root 29 Mar 19 13:05 /etc/resolv.conf -> ../run/resolvconf/resolv.conf


and the resolv.conf file



nameserver 1.1.1.1
nameserver 8.8.8.8
nameserver 2606:4700:4700::1111
nameserver 127.0.0.53
options edns0


the resolvectl output is :



Current DNS Server: 1.1.1.1
DNS Servers: 1.1.1.1
8.8.8.8
2606:4700:4700::1111
DNSSEC NTA: 10.in-addr.arpa


and the dpkg -l *dnsmasq* output is :



Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-
aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture
Description
+++-======================-================-================-
==================================================
un dnsmasq <none> <none> (no
description available)
ii dnsmasq-base 2.79-1 amd64 Small
caching DNS proxy and DHCP/TFTP server
un dnsmasq-base-lua <none> <none> (no
description available)









share|improve this question

























  • Which file? How are you obtaining your IP address?

    – waltinator
    Mar 21 at 12:47











  • Please explain. I don't know of ANY situation where MTU of 1200 is valid. What version Ubuntu? Using NetworkManager or netplan? Report back to @heynnema

    – heynnema
    Mar 21 at 14:10











  • sorry , my bad , I forgot to tell which file I changed , I edit the post , and I get my IP from dhcp @waltinator

    – Afshin
    Mar 21 at 20:15













  • I am using ubuntu 18.10 and when I used VPN I couldn't browse some websites like twitter and facebook etc but I could ping them with Domain Name , and I searched a lot so I saw a topic that says change your MTU size to 1200 ,and after I've done that my problem solved , but when I edit /etc/dhcp/dhclient.conf for changing MTU permanently the system change MTU to 1280 @heynnema

    – Afshin
    Mar 21 at 20:21











  • Maybe check my question and answer here askubuntu.com/questions/1007171/no-internet-over-vpn-connection

    – oscar1919
    Mar 21 at 20:34














0












0








0








I go to this file /etc/dhcp/dhclient.confand add these two line before request line



default interface-mtu 1200;

supercede interface-mtu 1200;


and after I restart and system boot up and run ifconfig command , it says my MTU size is 1280 , Why??
How can I change it to exact 1200 ??



Update:



cat /etc/resolv.conf



lrwxrwxrwx 1 root root 29 Mar 19 13:05 /etc/resolv.conf -> ../run/resolvconf/resolv.conf


and the resolv.conf file



nameserver 1.1.1.1
nameserver 8.8.8.8
nameserver 2606:4700:4700::1111
nameserver 127.0.0.53
options edns0


the resolvectl output is :



Current DNS Server: 1.1.1.1
DNS Servers: 1.1.1.1
8.8.8.8
2606:4700:4700::1111
DNSSEC NTA: 10.in-addr.arpa


and the dpkg -l *dnsmasq* output is :



Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-
aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture
Description
+++-======================-================-================-
==================================================
un dnsmasq <none> <none> (no
description available)
ii dnsmasq-base 2.79-1 amd64 Small
caching DNS proxy and DHCP/TFTP server
un dnsmasq-base-lua <none> <none> (no
description available)









share|improve this question
















I go to this file /etc/dhcp/dhclient.confand add these two line before request line



default interface-mtu 1200;

supercede interface-mtu 1200;


and after I restart and system boot up and run ifconfig command , it says my MTU size is 1280 , Why??
How can I change it to exact 1200 ??



Update:



cat /etc/resolv.conf



lrwxrwxrwx 1 root root 29 Mar 19 13:05 /etc/resolv.conf -> ../run/resolvconf/resolv.conf


and the resolv.conf file



nameserver 1.1.1.1
nameserver 8.8.8.8
nameserver 2606:4700:4700::1111
nameserver 127.0.0.53
options edns0


the resolvectl output is :



Current DNS Server: 1.1.1.1
DNS Servers: 1.1.1.1
8.8.8.8
2606:4700:4700::1111
DNSSEC NTA: 10.in-addr.arpa


and the dpkg -l *dnsmasq* output is :



Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-
aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture
Description
+++-======================-================-================-
==================================================
un dnsmasq <none> <none> (no
description available)
ii dnsmasq-base 2.79-1 amd64 Small
caching DNS proxy and DHCP/TFTP server
un dnsmasq-base-lua <none> <none> (no
description available)






networking






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 3 hours ago









heynnema

20.8k22259




20.8k22259










asked Mar 21 at 11:44









AfshinAfshin

266




266













  • Which file? How are you obtaining your IP address?

    – waltinator
    Mar 21 at 12:47











  • Please explain. I don't know of ANY situation where MTU of 1200 is valid. What version Ubuntu? Using NetworkManager or netplan? Report back to @heynnema

    – heynnema
    Mar 21 at 14:10











  • sorry , my bad , I forgot to tell which file I changed , I edit the post , and I get my IP from dhcp @waltinator

    – Afshin
    Mar 21 at 20:15













  • I am using ubuntu 18.10 and when I used VPN I couldn't browse some websites like twitter and facebook etc but I could ping them with Domain Name , and I searched a lot so I saw a topic that says change your MTU size to 1200 ,and after I've done that my problem solved , but when I edit /etc/dhcp/dhclient.conf for changing MTU permanently the system change MTU to 1280 @heynnema

    – Afshin
    Mar 21 at 20:21











  • Maybe check my question and answer here askubuntu.com/questions/1007171/no-internet-over-vpn-connection

    – oscar1919
    Mar 21 at 20:34



















  • Which file? How are you obtaining your IP address?

    – waltinator
    Mar 21 at 12:47











  • Please explain. I don't know of ANY situation where MTU of 1200 is valid. What version Ubuntu? Using NetworkManager or netplan? Report back to @heynnema

    – heynnema
    Mar 21 at 14:10











  • sorry , my bad , I forgot to tell which file I changed , I edit the post , and I get my IP from dhcp @waltinator

    – Afshin
    Mar 21 at 20:15













  • I am using ubuntu 18.10 and when I used VPN I couldn't browse some websites like twitter and facebook etc but I could ping them with Domain Name , and I searched a lot so I saw a topic that says change your MTU size to 1200 ,and after I've done that my problem solved , but when I edit /etc/dhcp/dhclient.conf for changing MTU permanently the system change MTU to 1280 @heynnema

    – Afshin
    Mar 21 at 20:21











  • Maybe check my question and answer here askubuntu.com/questions/1007171/no-internet-over-vpn-connection

    – oscar1919
    Mar 21 at 20:34

















Which file? How are you obtaining your IP address?

– waltinator
Mar 21 at 12:47





Which file? How are you obtaining your IP address?

– waltinator
Mar 21 at 12:47













Please explain. I don't know of ANY situation where MTU of 1200 is valid. What version Ubuntu? Using NetworkManager or netplan? Report back to @heynnema

– heynnema
Mar 21 at 14:10





Please explain. I don't know of ANY situation where MTU of 1200 is valid. What version Ubuntu? Using NetworkManager or netplan? Report back to @heynnema

– heynnema
Mar 21 at 14:10













sorry , my bad , I forgot to tell which file I changed , I edit the post , and I get my IP from dhcp @waltinator

– Afshin
Mar 21 at 20:15







sorry , my bad , I forgot to tell which file I changed , I edit the post , and I get my IP from dhcp @waltinator

– Afshin
Mar 21 at 20:15















I am using ubuntu 18.10 and when I used VPN I couldn't browse some websites like twitter and facebook etc but I could ping them with Domain Name , and I searched a lot so I saw a topic that says change your MTU size to 1200 ,and after I've done that my problem solved , but when I edit /etc/dhcp/dhclient.conf for changing MTU permanently the system change MTU to 1280 @heynnema

– Afshin
Mar 21 at 20:21





I am using ubuntu 18.10 and when I used VPN I couldn't browse some websites like twitter and facebook etc but I could ping them with Domain Name , and I searched a lot so I saw a topic that says change your MTU size to 1200 ,and after I've done that my problem solved , but when I edit /etc/dhcp/dhclient.conf for changing MTU permanently the system change MTU to 1280 @heynnema

– Afshin
Mar 21 at 20:21













Maybe check my question and answer here askubuntu.com/questions/1007171/no-internet-over-vpn-connection

– oscar1919
Mar 21 at 20:34





Maybe check my question and answer here askubuntu.com/questions/1007171/no-internet-over-vpn-connection

– oscar1919
Mar 21 at 20:34










3 Answers
3






active

oldest

votes


















1














You can automate the setting of the mtu for the VPN port when the VPN goes up as suggested in script
/etc/NetworkManager/dispatcher.d/01-ifupdown. Scripts in the dispatcher.d folder are called with the port and event as argument.
So, create a script in folder dispatcher.d, with following contents (if you want mtu 1200)



    #!/bin/sh  

#info : pre-up and pre-down are not implemented in network-manager

if [ "$2" = "vpn-up" ]; then
/sbin/ifconfig "$1" mtu 1200
fi


The name of the script does not matter, make it executable with chmod +x.






share|improve this answer
























  • I should just append these lines to 01-ifupdown ??

    – Afshin
    yesterday











  • I think that is possible, but, as 01-ifupdown is an example script, I would not touch it and create a new one. Any name is ok, as long as it is executable and in the same folder. You will need sudo to put it in that folder.

    – oscar1919
    yesterday











  • @Afshin you should first focus on determining what the correct MTU for your environment is, before trying to change it. Use the procedure in my answer first.

    – heynnema
    yesterday



















1














To determine the correct MTU setting, start with all MTU settings = 1500 and VPN = off. (VPN requires different testing).



Note: first remove your mods to /etc/dhcp/dhclient.conf and reboot.



In terminal:



ping [-c count] [-M do] [-s packet_size] [host]


The options used are:





  • c count: number of times to ping


  • M hint: Select Path MTU Discovery strategy. may be either do (prohibit fragmentation, even local one), want (do PMTU discovery, fragment locally when packet size is large), or dont (do not set DF flag).


  • s packet_size: Specifies the number of data bytes to be sent.


You should always start at 1472 and work your way down by 10 each time. Once you get a reply, go up by 1 until you get a fragmented packet. Take that value (last good value) and add 28 to the value to account for the various TCP/IP headers. Eg. let's say that 1452 was the proper packet size (where you first got an ICMP reply to your ping). The actual MTU size would be 1480, which is the optimum for the network we're working with.



ping -c 4 -M do -s 1472 8.8.8.8 # this will probably show fragmentation

ping -c 4 -M do -s 1462 8.8.8.8 # may show fragmentation

ping -c 4 -M do -s 1452 8.8.8.8 # no fragmentation?

ping -c 4 -M do -s 1453 8.8.8.8 # still no fragmentation?


reference: How to determine the proper MTU size with ICMP pings



Update #1:



I would recommend that you remove the 3 extra nameservers that you added to /etc/resolvconf/resolv.conf.d/head and let systemd-resolved properly manage /etc/resolv.conf. That should work better with VPN.



Update #2:



You can also setup a DIFFERENT wired/wireless connection profile, just for VPN, that hardwires the MTU=1200. In terminal, type nm-connection-editor and there you can customize a profile just for VPN with autoconnect and MTU.



enter image description hereenter image description here






share|improve this answer


























  • my problem is when I use VPN , so I just do it for when the vpn connects , right ?

    – Afshin
    yesterday











  • if it is ok , with vpn connecting , the number for me is 1400 (1372+28) , but when I change my mtu size of my wifi to 1400 , I can ping for example facebook.com but I can't browse it with firefox or chrome (but when I change it to 1270 , the problem goes away and I can ping and browse all the websites

    – Afshin
    yesterday











  • First test without VPN. Get that 100% right first. For wi-fi, the MTU should be 1500 (or maybe 1492 for DSL). Also, check what MTU your router is set to. It should be 1500 when testing.

    – heynnema
    yesterday













  • Without using VPN my wifi mtu size is 1500 and works fine with ping -c 4 -M do -s 1472 8.8.8.8 and in router MTU size is set to 1500 @heynnema

    – Afshin
    yesterday













  • @Afshin 1500 is correct without VPN. Check your VPN connection scripts, and see if they're setting MTU there. That's the only time when you have Internet problems, correct? Is your VPN software properly updating /etc/resolv.conf? Edit your question and show me ls -al /etc/resolv.conf and cat /etc/resolv.conf and resolvectl with VPN up.

    – heynnema
    yesterday





















1














You could use tracepath ( from the iputils-tracepath package) to determine the Path MTU:



walt@bat:~(0)$ dpkg -S $(type -p tracepath)
iputils-tracepath: /usr/bin/tracepath
walt@bat:~(0)$ tracepath primus.ip4.torontointernetxchange.net
1?: [LOCALHOST] pmtu 1500
1: spark3y 0.525ms
1: spark3y 0.497ms
2: spark3y 0.465ms pmtu 1492
2: dsl-xxx-xxx-xxx-xxx.tor.primus.ca 32.701ms
3: 10.201.117.2 34.726ms asymm 5
4: bb1.tor.primus.ca 39.238ms
5: primus.ip4.torontointernetxchange.net 33.295ms reached
Resume: pmtu 1492 hops 5 back 4





share|improve this answer
























  • Good one. BTW, it looks like you've got DSL, and need to lower your Ubuntu MTU too :-)

    – heynnema
    3 hours ago











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1127497%2fhow-can-i-change-mtu-size-permanently%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























3 Answers
3






active

oldest

votes








3 Answers
3






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














You can automate the setting of the mtu for the VPN port when the VPN goes up as suggested in script
/etc/NetworkManager/dispatcher.d/01-ifupdown. Scripts in the dispatcher.d folder are called with the port and event as argument.
So, create a script in folder dispatcher.d, with following contents (if you want mtu 1200)



    #!/bin/sh  

#info : pre-up and pre-down are not implemented in network-manager

if [ "$2" = "vpn-up" ]; then
/sbin/ifconfig "$1" mtu 1200
fi


The name of the script does not matter, make it executable with chmod +x.






share|improve this answer
























  • I should just append these lines to 01-ifupdown ??

    – Afshin
    yesterday











  • I think that is possible, but, as 01-ifupdown is an example script, I would not touch it and create a new one. Any name is ok, as long as it is executable and in the same folder. You will need sudo to put it in that folder.

    – oscar1919
    yesterday











  • @Afshin you should first focus on determining what the correct MTU for your environment is, before trying to change it. Use the procedure in my answer first.

    – heynnema
    yesterday
















1














You can automate the setting of the mtu for the VPN port when the VPN goes up as suggested in script
/etc/NetworkManager/dispatcher.d/01-ifupdown. Scripts in the dispatcher.d folder are called with the port and event as argument.
So, create a script in folder dispatcher.d, with following contents (if you want mtu 1200)



    #!/bin/sh  

#info : pre-up and pre-down are not implemented in network-manager

if [ "$2" = "vpn-up" ]; then
/sbin/ifconfig "$1" mtu 1200
fi


The name of the script does not matter, make it executable with chmod +x.






share|improve this answer
























  • I should just append these lines to 01-ifupdown ??

    – Afshin
    yesterday











  • I think that is possible, but, as 01-ifupdown is an example script, I would not touch it and create a new one. Any name is ok, as long as it is executable and in the same folder. You will need sudo to put it in that folder.

    – oscar1919
    yesterday











  • @Afshin you should first focus on determining what the correct MTU for your environment is, before trying to change it. Use the procedure in my answer first.

    – heynnema
    yesterday














1












1








1







You can automate the setting of the mtu for the VPN port when the VPN goes up as suggested in script
/etc/NetworkManager/dispatcher.d/01-ifupdown. Scripts in the dispatcher.d folder are called with the port and event as argument.
So, create a script in folder dispatcher.d, with following contents (if you want mtu 1200)



    #!/bin/sh  

#info : pre-up and pre-down are not implemented in network-manager

if [ "$2" = "vpn-up" ]; then
/sbin/ifconfig "$1" mtu 1200
fi


The name of the script does not matter, make it executable with chmod +x.






share|improve this answer













You can automate the setting of the mtu for the VPN port when the VPN goes up as suggested in script
/etc/NetworkManager/dispatcher.d/01-ifupdown. Scripts in the dispatcher.d folder are called with the port and event as argument.
So, create a script in folder dispatcher.d, with following contents (if you want mtu 1200)



    #!/bin/sh  

#info : pre-up and pre-down are not implemented in network-manager

if [ "$2" = "vpn-up" ]; then
/sbin/ifconfig "$1" mtu 1200
fi


The name of the script does not matter, make it executable with chmod +x.







share|improve this answer












share|improve this answer



share|improve this answer










answered yesterday









oscar1919oscar1919

50748




50748













  • I should just append these lines to 01-ifupdown ??

    – Afshin
    yesterday











  • I think that is possible, but, as 01-ifupdown is an example script, I would not touch it and create a new one. Any name is ok, as long as it is executable and in the same folder. You will need sudo to put it in that folder.

    – oscar1919
    yesterday











  • @Afshin you should first focus on determining what the correct MTU for your environment is, before trying to change it. Use the procedure in my answer first.

    – heynnema
    yesterday



















  • I should just append these lines to 01-ifupdown ??

    – Afshin
    yesterday











  • I think that is possible, but, as 01-ifupdown is an example script, I would not touch it and create a new one. Any name is ok, as long as it is executable and in the same folder. You will need sudo to put it in that folder.

    – oscar1919
    yesterday











  • @Afshin you should first focus on determining what the correct MTU for your environment is, before trying to change it. Use the procedure in my answer first.

    – heynnema
    yesterday

















I should just append these lines to 01-ifupdown ??

– Afshin
yesterday





I should just append these lines to 01-ifupdown ??

– Afshin
yesterday













I think that is possible, but, as 01-ifupdown is an example script, I would not touch it and create a new one. Any name is ok, as long as it is executable and in the same folder. You will need sudo to put it in that folder.

– oscar1919
yesterday





I think that is possible, but, as 01-ifupdown is an example script, I would not touch it and create a new one. Any name is ok, as long as it is executable and in the same folder. You will need sudo to put it in that folder.

– oscar1919
yesterday













@Afshin you should first focus on determining what the correct MTU for your environment is, before trying to change it. Use the procedure in my answer first.

– heynnema
yesterday





@Afshin you should first focus on determining what the correct MTU for your environment is, before trying to change it. Use the procedure in my answer first.

– heynnema
yesterday













1














To determine the correct MTU setting, start with all MTU settings = 1500 and VPN = off. (VPN requires different testing).



Note: first remove your mods to /etc/dhcp/dhclient.conf and reboot.



In terminal:



ping [-c count] [-M do] [-s packet_size] [host]


The options used are:





  • c count: number of times to ping


  • M hint: Select Path MTU Discovery strategy. may be either do (prohibit fragmentation, even local one), want (do PMTU discovery, fragment locally when packet size is large), or dont (do not set DF flag).


  • s packet_size: Specifies the number of data bytes to be sent.


You should always start at 1472 and work your way down by 10 each time. Once you get a reply, go up by 1 until you get a fragmented packet. Take that value (last good value) and add 28 to the value to account for the various TCP/IP headers. Eg. let's say that 1452 was the proper packet size (where you first got an ICMP reply to your ping). The actual MTU size would be 1480, which is the optimum for the network we're working with.



ping -c 4 -M do -s 1472 8.8.8.8 # this will probably show fragmentation

ping -c 4 -M do -s 1462 8.8.8.8 # may show fragmentation

ping -c 4 -M do -s 1452 8.8.8.8 # no fragmentation?

ping -c 4 -M do -s 1453 8.8.8.8 # still no fragmentation?


reference: How to determine the proper MTU size with ICMP pings



Update #1:



I would recommend that you remove the 3 extra nameservers that you added to /etc/resolvconf/resolv.conf.d/head and let systemd-resolved properly manage /etc/resolv.conf. That should work better with VPN.



Update #2:



You can also setup a DIFFERENT wired/wireless connection profile, just for VPN, that hardwires the MTU=1200. In terminal, type nm-connection-editor and there you can customize a profile just for VPN with autoconnect and MTU.



enter image description hereenter image description here






share|improve this answer


























  • my problem is when I use VPN , so I just do it for when the vpn connects , right ?

    – Afshin
    yesterday











  • if it is ok , with vpn connecting , the number for me is 1400 (1372+28) , but when I change my mtu size of my wifi to 1400 , I can ping for example facebook.com but I can't browse it with firefox or chrome (but when I change it to 1270 , the problem goes away and I can ping and browse all the websites

    – Afshin
    yesterday











  • First test without VPN. Get that 100% right first. For wi-fi, the MTU should be 1500 (or maybe 1492 for DSL). Also, check what MTU your router is set to. It should be 1500 when testing.

    – heynnema
    yesterday













  • Without using VPN my wifi mtu size is 1500 and works fine with ping -c 4 -M do -s 1472 8.8.8.8 and in router MTU size is set to 1500 @heynnema

    – Afshin
    yesterday













  • @Afshin 1500 is correct without VPN. Check your VPN connection scripts, and see if they're setting MTU there. That's the only time when you have Internet problems, correct? Is your VPN software properly updating /etc/resolv.conf? Edit your question and show me ls -al /etc/resolv.conf and cat /etc/resolv.conf and resolvectl with VPN up.

    – heynnema
    yesterday


















1














To determine the correct MTU setting, start with all MTU settings = 1500 and VPN = off. (VPN requires different testing).



Note: first remove your mods to /etc/dhcp/dhclient.conf and reboot.



In terminal:



ping [-c count] [-M do] [-s packet_size] [host]


The options used are:





  • c count: number of times to ping


  • M hint: Select Path MTU Discovery strategy. may be either do (prohibit fragmentation, even local one), want (do PMTU discovery, fragment locally when packet size is large), or dont (do not set DF flag).


  • s packet_size: Specifies the number of data bytes to be sent.


You should always start at 1472 and work your way down by 10 each time. Once you get a reply, go up by 1 until you get a fragmented packet. Take that value (last good value) and add 28 to the value to account for the various TCP/IP headers. Eg. let's say that 1452 was the proper packet size (where you first got an ICMP reply to your ping). The actual MTU size would be 1480, which is the optimum for the network we're working with.



ping -c 4 -M do -s 1472 8.8.8.8 # this will probably show fragmentation

ping -c 4 -M do -s 1462 8.8.8.8 # may show fragmentation

ping -c 4 -M do -s 1452 8.8.8.8 # no fragmentation?

ping -c 4 -M do -s 1453 8.8.8.8 # still no fragmentation?


reference: How to determine the proper MTU size with ICMP pings



Update #1:



I would recommend that you remove the 3 extra nameservers that you added to /etc/resolvconf/resolv.conf.d/head and let systemd-resolved properly manage /etc/resolv.conf. That should work better with VPN.



Update #2:



You can also setup a DIFFERENT wired/wireless connection profile, just for VPN, that hardwires the MTU=1200. In terminal, type nm-connection-editor and there you can customize a profile just for VPN with autoconnect and MTU.



enter image description hereenter image description here






share|improve this answer


























  • my problem is when I use VPN , so I just do it for when the vpn connects , right ?

    – Afshin
    yesterday











  • if it is ok , with vpn connecting , the number for me is 1400 (1372+28) , but when I change my mtu size of my wifi to 1400 , I can ping for example facebook.com but I can't browse it with firefox or chrome (but when I change it to 1270 , the problem goes away and I can ping and browse all the websites

    – Afshin
    yesterday











  • First test without VPN. Get that 100% right first. For wi-fi, the MTU should be 1500 (or maybe 1492 for DSL). Also, check what MTU your router is set to. It should be 1500 when testing.

    – heynnema
    yesterday













  • Without using VPN my wifi mtu size is 1500 and works fine with ping -c 4 -M do -s 1472 8.8.8.8 and in router MTU size is set to 1500 @heynnema

    – Afshin
    yesterday













  • @Afshin 1500 is correct without VPN. Check your VPN connection scripts, and see if they're setting MTU there. That's the only time when you have Internet problems, correct? Is your VPN software properly updating /etc/resolv.conf? Edit your question and show me ls -al /etc/resolv.conf and cat /etc/resolv.conf and resolvectl with VPN up.

    – heynnema
    yesterday
















1












1








1







To determine the correct MTU setting, start with all MTU settings = 1500 and VPN = off. (VPN requires different testing).



Note: first remove your mods to /etc/dhcp/dhclient.conf and reboot.



In terminal:



ping [-c count] [-M do] [-s packet_size] [host]


The options used are:





  • c count: number of times to ping


  • M hint: Select Path MTU Discovery strategy. may be either do (prohibit fragmentation, even local one), want (do PMTU discovery, fragment locally when packet size is large), or dont (do not set DF flag).


  • s packet_size: Specifies the number of data bytes to be sent.


You should always start at 1472 and work your way down by 10 each time. Once you get a reply, go up by 1 until you get a fragmented packet. Take that value (last good value) and add 28 to the value to account for the various TCP/IP headers. Eg. let's say that 1452 was the proper packet size (where you first got an ICMP reply to your ping). The actual MTU size would be 1480, which is the optimum for the network we're working with.



ping -c 4 -M do -s 1472 8.8.8.8 # this will probably show fragmentation

ping -c 4 -M do -s 1462 8.8.8.8 # may show fragmentation

ping -c 4 -M do -s 1452 8.8.8.8 # no fragmentation?

ping -c 4 -M do -s 1453 8.8.8.8 # still no fragmentation?


reference: How to determine the proper MTU size with ICMP pings



Update #1:



I would recommend that you remove the 3 extra nameservers that you added to /etc/resolvconf/resolv.conf.d/head and let systemd-resolved properly manage /etc/resolv.conf. That should work better with VPN.



Update #2:



You can also setup a DIFFERENT wired/wireless connection profile, just for VPN, that hardwires the MTU=1200. In terminal, type nm-connection-editor and there you can customize a profile just for VPN with autoconnect and MTU.



enter image description hereenter image description here






share|improve this answer















To determine the correct MTU setting, start with all MTU settings = 1500 and VPN = off. (VPN requires different testing).



Note: first remove your mods to /etc/dhcp/dhclient.conf and reboot.



In terminal:



ping [-c count] [-M do] [-s packet_size] [host]


The options used are:





  • c count: number of times to ping


  • M hint: Select Path MTU Discovery strategy. may be either do (prohibit fragmentation, even local one), want (do PMTU discovery, fragment locally when packet size is large), or dont (do not set DF flag).


  • s packet_size: Specifies the number of data bytes to be sent.


You should always start at 1472 and work your way down by 10 each time. Once you get a reply, go up by 1 until you get a fragmented packet. Take that value (last good value) and add 28 to the value to account for the various TCP/IP headers. Eg. let's say that 1452 was the proper packet size (where you first got an ICMP reply to your ping). The actual MTU size would be 1480, which is the optimum for the network we're working with.



ping -c 4 -M do -s 1472 8.8.8.8 # this will probably show fragmentation

ping -c 4 -M do -s 1462 8.8.8.8 # may show fragmentation

ping -c 4 -M do -s 1452 8.8.8.8 # no fragmentation?

ping -c 4 -M do -s 1453 8.8.8.8 # still no fragmentation?


reference: How to determine the proper MTU size with ICMP pings



Update #1:



I would recommend that you remove the 3 extra nameservers that you added to /etc/resolvconf/resolv.conf.d/head and let systemd-resolved properly manage /etc/resolv.conf. That should work better with VPN.



Update #2:



You can also setup a DIFFERENT wired/wireless connection profile, just for VPN, that hardwires the MTU=1200. In terminal, type nm-connection-editor and there you can customize a profile just for VPN with autoconnect and MTU.



enter image description hereenter image description here







share|improve this answer














share|improve this answer



share|improve this answer








edited 10 hours ago

























answered 2 days ago









heynnemaheynnema

20.8k22259




20.8k22259













  • my problem is when I use VPN , so I just do it for when the vpn connects , right ?

    – Afshin
    yesterday











  • if it is ok , with vpn connecting , the number for me is 1400 (1372+28) , but when I change my mtu size of my wifi to 1400 , I can ping for example facebook.com but I can't browse it with firefox or chrome (but when I change it to 1270 , the problem goes away and I can ping and browse all the websites

    – Afshin
    yesterday











  • First test without VPN. Get that 100% right first. For wi-fi, the MTU should be 1500 (or maybe 1492 for DSL). Also, check what MTU your router is set to. It should be 1500 when testing.

    – heynnema
    yesterday













  • Without using VPN my wifi mtu size is 1500 and works fine with ping -c 4 -M do -s 1472 8.8.8.8 and in router MTU size is set to 1500 @heynnema

    – Afshin
    yesterday













  • @Afshin 1500 is correct without VPN. Check your VPN connection scripts, and see if they're setting MTU there. That's the only time when you have Internet problems, correct? Is your VPN software properly updating /etc/resolv.conf? Edit your question and show me ls -al /etc/resolv.conf and cat /etc/resolv.conf and resolvectl with VPN up.

    – heynnema
    yesterday





















  • my problem is when I use VPN , so I just do it for when the vpn connects , right ?

    – Afshin
    yesterday











  • if it is ok , with vpn connecting , the number for me is 1400 (1372+28) , but when I change my mtu size of my wifi to 1400 , I can ping for example facebook.com but I can't browse it with firefox or chrome (but when I change it to 1270 , the problem goes away and I can ping and browse all the websites

    – Afshin
    yesterday











  • First test without VPN. Get that 100% right first. For wi-fi, the MTU should be 1500 (or maybe 1492 for DSL). Also, check what MTU your router is set to. It should be 1500 when testing.

    – heynnema
    yesterday













  • Without using VPN my wifi mtu size is 1500 and works fine with ping -c 4 -M do -s 1472 8.8.8.8 and in router MTU size is set to 1500 @heynnema

    – Afshin
    yesterday













  • @Afshin 1500 is correct without VPN. Check your VPN connection scripts, and see if they're setting MTU there. That's the only time when you have Internet problems, correct? Is your VPN software properly updating /etc/resolv.conf? Edit your question and show me ls -al /etc/resolv.conf and cat /etc/resolv.conf and resolvectl with VPN up.

    – heynnema
    yesterday



















my problem is when I use VPN , so I just do it for when the vpn connects , right ?

– Afshin
yesterday





my problem is when I use VPN , so I just do it for when the vpn connects , right ?

– Afshin
yesterday













if it is ok , with vpn connecting , the number for me is 1400 (1372+28) , but when I change my mtu size of my wifi to 1400 , I can ping for example facebook.com but I can't browse it with firefox or chrome (but when I change it to 1270 , the problem goes away and I can ping and browse all the websites

– Afshin
yesterday





if it is ok , with vpn connecting , the number for me is 1400 (1372+28) , but when I change my mtu size of my wifi to 1400 , I can ping for example facebook.com but I can't browse it with firefox or chrome (but when I change it to 1270 , the problem goes away and I can ping and browse all the websites

– Afshin
yesterday













First test without VPN. Get that 100% right first. For wi-fi, the MTU should be 1500 (or maybe 1492 for DSL). Also, check what MTU your router is set to. It should be 1500 when testing.

– heynnema
yesterday







First test without VPN. Get that 100% right first. For wi-fi, the MTU should be 1500 (or maybe 1492 for DSL). Also, check what MTU your router is set to. It should be 1500 when testing.

– heynnema
yesterday















Without using VPN my wifi mtu size is 1500 and works fine with ping -c 4 -M do -s 1472 8.8.8.8 and in router MTU size is set to 1500 @heynnema

– Afshin
yesterday







Without using VPN my wifi mtu size is 1500 and works fine with ping -c 4 -M do -s 1472 8.8.8.8 and in router MTU size is set to 1500 @heynnema

– Afshin
yesterday















@Afshin 1500 is correct without VPN. Check your VPN connection scripts, and see if they're setting MTU there. That's the only time when you have Internet problems, correct? Is your VPN software properly updating /etc/resolv.conf? Edit your question and show me ls -al /etc/resolv.conf and cat /etc/resolv.conf and resolvectl with VPN up.

– heynnema
yesterday







@Afshin 1500 is correct without VPN. Check your VPN connection scripts, and see if they're setting MTU there. That's the only time when you have Internet problems, correct? Is your VPN software properly updating /etc/resolv.conf? Edit your question and show me ls -al /etc/resolv.conf and cat /etc/resolv.conf and resolvectl with VPN up.

– heynnema
yesterday













1














You could use tracepath ( from the iputils-tracepath package) to determine the Path MTU:



walt@bat:~(0)$ dpkg -S $(type -p tracepath)
iputils-tracepath: /usr/bin/tracepath
walt@bat:~(0)$ tracepath primus.ip4.torontointernetxchange.net
1?: [LOCALHOST] pmtu 1500
1: spark3y 0.525ms
1: spark3y 0.497ms
2: spark3y 0.465ms pmtu 1492
2: dsl-xxx-xxx-xxx-xxx.tor.primus.ca 32.701ms
3: 10.201.117.2 34.726ms asymm 5
4: bb1.tor.primus.ca 39.238ms
5: primus.ip4.torontointernetxchange.net 33.295ms reached
Resume: pmtu 1492 hops 5 back 4





share|improve this answer
























  • Good one. BTW, it looks like you've got DSL, and need to lower your Ubuntu MTU too :-)

    – heynnema
    3 hours ago
















1














You could use tracepath ( from the iputils-tracepath package) to determine the Path MTU:



walt@bat:~(0)$ dpkg -S $(type -p tracepath)
iputils-tracepath: /usr/bin/tracepath
walt@bat:~(0)$ tracepath primus.ip4.torontointernetxchange.net
1?: [LOCALHOST] pmtu 1500
1: spark3y 0.525ms
1: spark3y 0.497ms
2: spark3y 0.465ms pmtu 1492
2: dsl-xxx-xxx-xxx-xxx.tor.primus.ca 32.701ms
3: 10.201.117.2 34.726ms asymm 5
4: bb1.tor.primus.ca 39.238ms
5: primus.ip4.torontointernetxchange.net 33.295ms reached
Resume: pmtu 1492 hops 5 back 4





share|improve this answer
























  • Good one. BTW, it looks like you've got DSL, and need to lower your Ubuntu MTU too :-)

    – heynnema
    3 hours ago














1












1








1







You could use tracepath ( from the iputils-tracepath package) to determine the Path MTU:



walt@bat:~(0)$ dpkg -S $(type -p tracepath)
iputils-tracepath: /usr/bin/tracepath
walt@bat:~(0)$ tracepath primus.ip4.torontointernetxchange.net
1?: [LOCALHOST] pmtu 1500
1: spark3y 0.525ms
1: spark3y 0.497ms
2: spark3y 0.465ms pmtu 1492
2: dsl-xxx-xxx-xxx-xxx.tor.primus.ca 32.701ms
3: 10.201.117.2 34.726ms asymm 5
4: bb1.tor.primus.ca 39.238ms
5: primus.ip4.torontointernetxchange.net 33.295ms reached
Resume: pmtu 1492 hops 5 back 4





share|improve this answer













You could use tracepath ( from the iputils-tracepath package) to determine the Path MTU:



walt@bat:~(0)$ dpkg -S $(type -p tracepath)
iputils-tracepath: /usr/bin/tracepath
walt@bat:~(0)$ tracepath primus.ip4.torontointernetxchange.net
1?: [LOCALHOST] pmtu 1500
1: spark3y 0.525ms
1: spark3y 0.497ms
2: spark3y 0.465ms pmtu 1492
2: dsl-xxx-xxx-xxx-xxx.tor.primus.ca 32.701ms
3: 10.201.117.2 34.726ms asymm 5
4: bb1.tor.primus.ca 39.238ms
5: primus.ip4.torontointernetxchange.net 33.295ms reached
Resume: pmtu 1492 hops 5 back 4






share|improve this answer












share|improve this answer



share|improve this answer










answered 7 hours ago









waltinatorwaltinator

22.8k74169




22.8k74169













  • Good one. BTW, it looks like you've got DSL, and need to lower your Ubuntu MTU too :-)

    – heynnema
    3 hours ago



















  • Good one. BTW, it looks like you've got DSL, and need to lower your Ubuntu MTU too :-)

    – heynnema
    3 hours ago

















Good one. BTW, it looks like you've got DSL, and need to lower your Ubuntu MTU too :-)

– heynnema
3 hours ago





Good one. BTW, it looks like you've got DSL, and need to lower your Ubuntu MTU too :-)

– heynnema
3 hours ago


















draft saved

draft discarded




















































Thanks for contributing an answer to Ask Ubuntu!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1127497%2fhow-can-i-change-mtu-size-permanently%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

GameSpot

connect to host localhost port 22: Connection refused

Getting a Wifi WPA2 wifi connection