- Смена MTU
- Windows
- Командная строка
- Реестр
- Linux
- Разово
- Постоянно (permanently)
- Роутер
- Читайте также
- How can I setup the MTU for my network interface?
- Узнать значение и поменять MTU в Linux
- Linux MTU Change Size
- Changing the MTU size with ifconfig command
- Changing the MTU size permanently unde r CentOS / RHEL / Fedora Linux
- Changing the MTU size permanently under Debian / Ubuntu Linux
- Changing the MTU size permanently (other Linux distros)
Смена MTU
Рассмотрим процесс смены значения MTU для операционных систем семейства Windows и Linux, а также роутерах.
Windows
Командная строка
Открываем командную строку от имени администратора.
Вводим команду для просмотра текущего значения MTU и названия сетевого интерфейса:
netsh interface ipv4 show subinterfaces
Получаем, примерно, следующее:
MTU Состояние определения носителя Вх. байт Исх. байт Интерфейс
—— ————— ——— ——— ————-
1500 1 81324794839 5376993884 Ethernet
* где 1500 — значение MTU (по умолчанию для сетей Etnernet); Ethernet — название интерфейса.
Меняем MTU следующей командой:
netsh interface ipv4 set subinterface «Ethernet» mtu=1492 store=persistent
* где Ethernet — название сетевого интерфейса, которое мы получили предыдущей командой; 1492 — новое значение MTU
Реестр
Открываем реестр (команда regedit) и переходим по ветке HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\<4D36E972-E325-11CE-BFC1-08002bE10318.
Внутри будут находиться другие ветки с названиями 0000, 0001, 0002 и так далее. Необходимо пройтись по каждой и найти ключ DriverDesc со значением, похожим на название нашего сетевого адаптера и записать значение ключа NetCfgInstanceId, например:
Переходим в ветку HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces. Находим ветку с нашим идентификатором, который мы записали и меняем ключ MTU (при его отсутствии, создаем — тип DWORD):
Чтобы настройки применились выключаем и снова включаем сетевой интерфейс или перезагружаем компьютер.
Linux
Для примера, рассмотрим наиболее популярные дистрибутивы — CentOS и Ubuntu.
Разово
Разово (до перезагрузки) для данных двух систем настройку можно выполнить одной командой:
ip link set mtu 1400 dev eth0
* где 1400 — новое значение MTU; eth0 — сетевой интерфейс, для которого поменяли максимальный размер пакетов.
или в старых системах:
ifconfig eth0 mtu 1400
Постоянно (permanently)
Для систем на базе Debian (Ubuntu) и Red Hat (CentOS) процедура немного отличается.
Ubuntu
Открываем настройку сетевых интерфейсов:
К нужному адаптеру добавляем строчку:
iface eth0 inet static
.
mtu 9000
systemctl restart networking
CentOS
Открываем конфигурационный файл для соответствующего сетевого интерфейса:
Перезапускаем сетевую службу:
systemctl restart network
Роутер
Смена MTU на роутерах различных производителей выполняется, примерно, по одному и тому же принципу — зайти на веб-интерфейс для настройки маршрутизатора, найти раздел с настройкой сети Интернет, задать значение MTU.
Например, для большинства устройств TP-Link: Network — WAN:
Читайте также
Инструкция по смене значения MTU на Windows и Linux
Источник
How can I setup the MTU for my network interface?
MTU (Maximum Transmission Unit) is related to TCP/IP networking in Linux/BSD/UNIX oses. It refers to the size (in bytes) of the largest datagram that a given layer of a communications protocol can pass at a time.
You can see current MTU setting with ifconfig command under Linux:
A better way is to use ip command:
As you see, MTU set to 1500 for eth0. Let us say you want this to 1400 then you can use any one of the following command to setup MTU:
# ifconfig eth0 mtu 1400
# ip link set dev eth0 mtu 1400
Verify that new mtu is setup with following command:
- No ads and tracking
- In-depth guides for developers and sysadmins at Opensourceflare✨
- Join my Patreon to support independent content creators and start reading latest guides:
- How to set up Redis sentinel cluster on Ubuntu or Debian Linux
- How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
- How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
- A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
- How to protect Linux against rogue USB devices using USBGuard
Join Patreon ➔
To make the setting permanent for eth0, edit the configuration file:
/etc/network/interfaces (Debian Linux file)
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
name Ethernet LAN card
address 192.168.1.2
netmask 255.255.255.0
broadcast 192.168.1.255
network 192.168.1.0
gateway 192.168.1.254
mtu 1400
post-up /etc/fw.start
post-down /etc/fw.stop
/etc/sysconfig/network-scripts/ifcfg-eth0 (Red Hat Linux )
DEVICE=eth0
BOOTPROTO=static
BROADCAST=192.168.1.255
HWADDR=00:0F:EA:91:04:07
IPADDR=192.168.1.111
NETMASK=255.255.255.0
NETWORK=192.168.1.0
MTU=1400
ONBOOT=yes
TYPE=Ethernet
Save the file and restart network service
If you are using Redhat:
# service network restart
If you are using Debian:
🐧 Get the latest tutorials on Linux, Open Source & DevOps via
Источник
Узнать значение и поменять MTU в Linux
Узнать значение MTU для всех интерфейсов можно выполнив в консоли команду ip link
1: lo: mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0:
mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
link/ether 54:52:00:91:96:85 brd ff:ff:ff:ff:ff:ff
Чаще всего встречается 1500 — это значение по умолчанию для Ethernet интерфейсов.
Поменять MTU на сервере с Debian можно так:
ip link set dev eth0 mtu 1400
При этом начинает использоваться значение 1400, после перезагрузки эти изменения не сохранятся.
Чтобы сделать их постоянными нужно отредактировать файл /etc/network/interfaces
Для CentOS это скрипты /etc/sysconfig/network-scripts/*, для других систем иначе — для Debian также возможны варианты, но чаще всего это /etc/network/interfaces
К нужному интерфейсу достаточно дописать mtu 1400 отдельной строкой
IFACE при этом заменить именем интерфейса, таким как eth0
Если настройки сети выдаются DHCP, то секция примет такой вид:
iface eth0 inet dhcp
pre-up /sbin/ifconfig $IFACE mtu 1454
Для сервера, к которому нет доступа по SSH MTU можно узнать экспериментальным путем. Значение может потребоваться при поиске сетевых неполадок.
Это делается за счет опции -M do утилиты ping.
ICMP пакеты при этом будут отправляться с заданным MTU, из ответа будет видно реальное значение.
PING ya.ru (87.250.250.242) 1572(1600) bytes of data.
ping: local error: Message too long, mtu=1500
— ya.ru ping statistics —
1 packets transmitted, 0 received, +1 errors, 100% packet loss, time 0ms
28 байт вычитается, поскольку они отданы под хэдеры IP и ICMP.
При установке 1500 байт PING проходит успешно.
PING ya.ru (87.250.250.242) 1472(1500) bytes of data.
1480 bytes from ya.ru (87.250.250.242): icmp_seq=1 ttl=57 time=32.0 ms
— ya.ru ping statistics —
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 32.040/32.040/32.040/0.000 ms
Читайте про iface inet — директиву, которую можно увидеть в /etc/network/interfaces
Источник
Linux MTU Change Size
W e’ve gigabit networks, and large maximum transmission units (MTU) sizes (JumboFrames) can provide better network performance for our HPC environment. How do I change MTU size under Linux?
You need support in both network hardware and card in order to use JumboFrames. If you want to transfer large amounts of data at gigabit speeds, increasing the default MTU size can provide significant performance gains.
Changing the MTU size with ifconfig command
In order to change the MTU size, use /sbin/ifconfig command as follows:
Note this will only work if supported by both the network nterface card and the network components such as switch.
- No ads and tracking
- In-depth guides for developers and sysadmins at Opensourceflare✨
- Join my Patreon to support independent content creators and start reading latest guides:
- How to set up Redis sentinel cluster on Ubuntu or Debian Linux
- How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
- How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
- A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
- How to protect Linux against rogue USB devices using USBGuard
Join Patreon ➔
Changing the MTU size permanently unde r CentOS / RHEL / Fedora Linux
Edit /etc/sysconfig/network-scripts/ifcfg-eth0, enter
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
Add MTU, settings:
MTU=»9000″
Save and close the file. Restart networking:
# service network restart
Note for IPV6 set dedicated MTU as follows:
IPV6_MTU=»1280″
Changing the MTU size permanently under Debian / Ubuntu Linux
Edit /etc/network/interfaces, enter:
# vi /etc/network/interfaces
Add mtu as follows for required interface:
mtu 9000
Save and close the file. Restart the networking, enter:
# /etc/init.d/networking restart
Changing the MTU size permanently (other Linux distros)
Edit /etc/rc.local and add the following line:
Updated for accuracy!
🐧 Get the latest tutorials on Linux, Open Source & DevOps via
Category | List of Unix and Linux commands |
---|---|
Documentation | help • mandb • man • pinfo |
Disk space analyzers | df • duf • ncdu • pydf |
File Management | cat • cp • less • mkdir • more • tree |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Linux Desktop Apps | Skype • Spotify • VLC 3 |
Modern utilities | bat • exa |
Network Utilities | NetHogs • dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • glances • gtop • jobs • killall • kill • pidof • pstree • pwdx • time • vtop |
Searching | ag • grep • whereis • which |
Shell builtins | compgen • echo • printf |
Text processing | cut • rev |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
Comments on this entry are closed.
You can use alse another command:
ip link set eth0 mtu 9000
ip link set eth0 up
iface eth0 inet static
address 192.168.1.2
network 192.168.1.0
gateway 192.168.1.1
netmask 255.255.255.0
mtu 9000
Hello, the “printable version” link adds an extra / slash to the url and then gives a 404. I think it happends on many other pages.
Great job on this site, i follow it by mail and i also use the forum, it’s one of my reference sites. nice job.
Thanks for the heads up! I’ve fixed the problem. Earlier, today I patched up WP and something did went wrong with my functions file. Let me know if you’ve any more problem.
The /etc/rc.local file is severely deprecated, and shouldn’t be used at all. If you want to set MTU sizes on your NIC, then you should be editing the NIC’s config file, not init’s.
For RHEL/Fedora add “MTU=9000” to /etc/sysconfig/network/ifcfg-eth0
For Debian/Ubuntu add “mtu 9000” to /etc/network/interfaces
Take the interface down, then back up, and the setting should be applied. This gets a bit more troublesome on NICs that are bound together or for TAP/Bridge devices, but the concept is the same: edit the appropriate NIC config to make the setting.
The faq has been updated.
Appreciate your posts!
I tied using MTU 9000 under using Debian under /etc/network/ interfaces with a DHCP applied address and the mtu seems to be taken from the DHCP settings which seems logical, but is a little frustrating.
Should this only be enable on interfaces that have local traffic only? What happens to the packets if they are routed to devices that do not support an MTU of that size?
I have tried the same but it is not working & giving the following error
[root@server home]# /etc/init.d/network restart
Shutting down interface eth0: [ OK ]
Shutting down loopback interface: [ OK ]
Bringing up loopback interface: [ OK ]
Bringing up interface eth0: SIOCSIFMTU: Invalid argument
and what did you change?
I have givren the below.
DEVICE=eth0
#MTU=5000
BOOTPROTO=static
ONBOOT=yes
IPADDR=192.168.138.129
NETMASK=255.255.255.0
#MTU=5000
i think here is the driver limitation…
i have similar situation
root@bigboy:
# ifconfig eth0 mtu 1490
root@bigboy:
# ifconfig eth0 mtu 1501
SIOCSIFMTU: Invalid argument
It happened to me (in our company cluster) that the issue was with the mode that interface was in. It was in the datagram instead in the connected. With “# echo connected >> echo connected > /sys/class/net/ethX/mode” you can change the mode, and that enables you to also change the MTU.
Hope it helps. -R
“SIOCSIFMTU: Invalid argument” is the drivers way to tell you that the hardware doesn’t support that framesize. Try increment iteratively til reaching the roof.
Remember that both sides needs to support this MTU or else fragmentation will occur!
Try your setting out by pinging with a specific MTU:
ping -s [MTU-28] -M do [ip-address]
Remember to substract 28 from the set MTU giving space for headers. If packets are dropped or messages about fragmentation is recieved, lower MTU size further.
my linux does’nt haveinternet accses in dual-boot system
Источник