Use the following steps to change the MTU size on a Windows Server virtual machine:
Sign-in to vm-1.
Open a PowerShell window as an administrator.
Use Get-NetIPAddress
to show the IP address of vm-1. Record the IP address for the subsequent steps. In this example, the IP address is 10.0.0.4.
Get-NetIPAddress -AddressFamily IPv4
PS C:\Users\azureuser> Get-NetIPAddress -AddressFamily IPv4
IPAddress : 10.0.0.4
InterfaceIndex : 7
InterfaceAlias : Ethernet
AddressFamily : IPv4
Type : Unicast
PrefixLength : 24
PrefixOrigin : Dhcp
SuffixOrigin : Dhcp
AddressState : Preferred
ValidLifetime : Infinite ([TimeSpan]::MaxValue)
PreferredLifetime : Infinite ([TimeSpan]::MaxValue)
SkipAsSource : False
PolicyStore : ActiveStore
IPAddress : 127.0.0.1
InterfaceIndex : 1
InterfaceAlias : Loopback Pseudo-Interface 1
AddressFamily : IPv4
Type : Unicast
PrefixLength : 8
PrefixOrigin : WellKnown
SuffixOrigin : WellKnown
AddressState : Preferred
ValidLifetime : Infinite ([TimeSpan]::MaxValue)
PreferredLifetime : Infinite ([TimeSpan]::MaxValue)
SkipAsSource : False
PolicyStore : ActiveStore
Use Get-NetAdapter
in the following example to display the current network interfaces.
Get-NetAdapter
PS C:\Users\azureuser> Get-NetAdapter
Name InterfaceDescription ifIndex Status MacAddress LinkSpeed
---- -------------------- ------- ------ ---------- ---------
Ethernet 2 Mellanox ConnectX-5 Virtual Adapter 10 Up 60-45-BD-CC-77-01 100 Gbps
Ethernet Microsoft Hyper-V Network Adapter 6 Up 60-45-BD-CC-77-01 100 Gbps
The virtual machine has two network interfaces displayed in the output.
Record the value of the MAC address of the network interface and the name. You'll need these values for the next step. For the purposes of this article, the example values are 60-45-BD-CC-77-01 and Ethernet 2. Replace the values with your own value.
Use the following example to display the current MTU value for the network interface.
Get-NetAdapter -Name "Ethernet 2" | Format-List -Property MtuSize
PS C:\Users\azureuser> Get-NetAdapter -Name "Ethernet 2" | Format-List -Property MtuSize
MtuSize : 1500
Windows Virtual machine support both the Mellanox interface and the Microsoft Azure Network Adapter.
- To set the value on the Mellanox interface, use the following example to set the MTU value to 4088. Replace the value of the MAC address with your own value.
Get-NetAdapter | ? {$_.MacAddress -eq "60-45-BD-CC-77-01"} | Set-NetAdapterAdvancedProperty -RegistryKeyword "*JumboPacket" -RegistryValue 4088
- To set the value on the Microsoft Azure Network Adapter, use the following example to set the MTU value to 9014. Replace the value of the MAC address with your own value.
Get-NetAdapter | ? {$_.MacAddress -eq "60-45-BD-CC-77-01"} | Set-NetAdapterAdvancedProperty -RegistryKeyword "*JumboPacket" -RegistryValue 9014
Use the following example to verify the MTU value is set on the network interface.
Get-NetAdapter -Name "Ethernet 2" | Format-List -Property MtuSize
PS C:\Users\azureuser> Get-NetAdapter -Name "Ethernet 2" | Format-List -Property MtuSize
MtuSize : 4074
Internet Control Message Protocol (ICMP) traffic is required between the source and destination to test the MTU size. Use the following example to enable ICMP traffic on vm-1:
Set-NetFirewallRule -DisplayName 'File and Printer Sharing (Echo Request - ICMPv4-In)' -enabled True
Sign-in to vm-2 to repeat the previous steps to set the MTU value to the highest value supported by the network interface.
Sign-in to vm-1.
Open a PowerShell window as an administrator.
Use the following example to execute the PowerShell command Test-Connection
test the network path. Replace the value of the destination host with the IP address of vm-2.
Test-Connection -TargetName 10.0.0.5 -MtuSize
The output is similar to the following example. If the command's output doesn't display the setting on the network interface, it indicates that the MTU size isn't set correctly. Alternatively, it could mean that a network device along the path only supports the MTU size returned by the Test-Connection
command.
PS C:\Users\azureuser> Test-Connection -TargetName 10.0.0.5 -MtuSize
Destination: 10.0.0.5
Source Address Latency Status MtuSize
(ms) (B)
------ ------- ------- ------ -------
vm-1 10.0.0.5 1 Success 3892
Verify the MTU size on the network interface using PING
. For Windows, use -f and -l. The -f option instructs ping to NOT fragment and -l sets the packet size. Use the value returned by the Test-Connection
command for the MtuSize property. In this example, it's 3892.
ping 10.0.0.5 -f -l 3892
PS C:\Users\azureuser> ping 10.0.0.5 -f -l 3892
Pinging 10.0.0.5 with 3892 bytes of data:
Reply from 10.0.0.5: bytes=3892 time=1ms TTL=128
Reply from 10.0.0.5: bytes=3892 time<1ms TTL=128
Reply from 10.0.0.5: bytes=3892 time=1ms TTL=128
Reply from 10.0.0.5: bytes=3892 time=1ms TTL=128
Ping statistics for 10.0.0.5:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 1ms, Average = 0ms
An indication that there is a mismatch in settings between the source and destination displays as an error message in the output. In this case, the MTU isn't set on the source network interface.
PS C:\Users\azureuser> ping 10.0.0.5 -f -l 3892
Pinging 10.0.0.5 with 3892 bytes of data:
Packet needs to be fragmented but DF set.
Packet needs to be fragmented but DF set.
Packet needs to be fragmented but DF set.
Packet needs to be fragmented but DF set.
Ping statistics for 10.0.0.5:
Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),
Use Get-NetIPInterface
to determine the interface alias and the current MTU value.
Get-NetIPInterface
PS C:\Users\azureuser> Get-NetIPInterface
ifIndex InterfaceAlias AddressFamily NlMtu(Bytes) InterfaceMetric Dhcp ConnectionState PolicyStore
------- -------------- ------------- ------------ --------------- ---- --------------- -----------
6 Ethernet IPv6 4074 10 Enabled Connected ActiveStore
1 Loopback Pseudo-Interface 1 IPv6 4294967295 75 Disabled Connected ActiveStore
6 Ethernet IPv4 4074 10 Enabled Connected ActiveStore
1 Loopback Pseudo-Interface 1 IPv4 4294967295 75 Enabled Connected ActiveStore
In the example, the interface alias is Ethernet and the MTU value is 4074.
Use Set-NetIPInterface
to set the MTU value for vm-1 to persist reboots. For the MTU value, 3892 is used in this example. Replace this value with your value returned by the Test-Connection
command. The interface alias is Ethernet in this example. Replace this value with your value.
Set-NetIPInterface -InterfaceAlias "Ethernet" -NIMtuBytes 3892
- Microsoft Azure Network Adapter:
Set-NetIPInterface -InterfaceAlias "Ethernet" -NIMtuBytes 9000
Use Get-NetIPInterface
to verify the MTU was set with Set-NetIPInterface
.
Get-NetIPInterface -InterfaceAlias "Ethernet"
PS C:\Users\azureuser> Get-NetIPInterface -InterfaceAlias "Ethernet"
ifIndex InterfaceAlias AddressFamily NlMtu(Bytes) InterfaceMetric Dhcp ConnectionState PolicyStore
------- -------------- ------------- ------------ --------------- ---- --------------- -----------
6 Ethernet IPv6 3892 10 Enabled Connected ActiveStore
6 Ethernet IPv4 3892 10 Enabled Connected ActiveStore
Sign-in to vm-2.
Open a PowerShell window as an administrator.
Use the following example to execute the PowerShell command Test-Connection
test the network path. Replace the value of the destination host with the IP address of vm-2.
Test-Connection -TargetName 10.0.0.4 -MtuSize
The output is similar to the following example. If the command's output doesn't display the setting on the network interface, it indicates that the MTU size isn't set correctly. Alternatively, it could mean that a network device along the path only supports the MTU size returned by the Test-Connection
command.
PS C:\Users\azureuser> Test-Connection -TargetName 10.0.0.4 -MutSize
Destination: 10.0.0.4
Source Address Latency Status MtuSize
(ms) (B)
------ ------- ------- ------ -------
vm-2 10.0.0.4 1 Success 3892
Verify the MTU size on the network interface using PING
. For Windows, use -f and -l. The -f option instructs ping to NOT fragment and -l sets the packet size. To determine the packet size, subtract 28 from the MTU setting of 3900.
ping 10.0.0.4 -f -l 3892
PS C:\Users\azureuser> ping 10.0.0.4 -f -l 3892
Pinging 10.0.0.4 with 3892 bytes of data:
Reply from 10.0.0.4: bytes=3892 time=1ms TTL=128
Reply from 10.0.0.4: bytes=3892 time<1ms TTL=128
Reply from 10.0.0.4: bytes=3892 time=1ms TTL=128
Reply from 10.0.0.4: bytes=3892 time=1ms TTL=128
Ping statistics for 10.0.0.4:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 1ms, Average = 0ms
An indication that there is a mismatch in settings between the source and destination displays as an error message in the output. In this case, the MTU isn't set on the source network interface.
PS C:\Users\azureuser> ping 10.0.0.4 -f -l 3892
Pinging 10.0.0.4 with 3892 bytes of data:
Packet needs to be fragmented but DF set.
Packet needs to be fragmented but DF set.
Packet needs to be fragmented but DF set.
Packet needs to be fragmented but DF set.
Ping statistics for 10.0.0.4:
Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),
Use Get-NetIPInterface
to determine the interface alias and the current MTU value.
Get-NetIPInterface
PS C:\Users\azureuser> Get-NetIPInterface
ifIndex InterfaceAlias AddressFamily NlMtu(Bytes) InterfaceMetric Dhcp ConnectionState PolicyStore
------- -------------- ------------- ------------ --------------- ---- --------------- -----------
6 Ethernet IPv6 4074 10 Enabled Connected ActiveStore
1 Loopback Pseudo-Interface 1 IPv6 4294967295 75 Disabled Connected ActiveStore
6 Ethernet IPv4 4074 10 Enabled Connected ActiveStore
1 Loopback Pseudo-Interface 1 IPv4 4294967295 75 Enabled Connected ActiveStore
In the example, the interface alias is Ethernet and the MTU value is 4074.
Use Set-NetIPInterface
to set the MTU value for vm-2 to persist reboots. For the MTU value, 3892 is used in this example. Replace this value with your value returned by the Test-Connection
command. The interface alias is Ethernet in this example. Replace this value with your value.
Set-NetIPInterface -InterfaceAlias "Ethernet" -NIMtuBytes 3892
- Microsoft Azure Network Adapter:
Set-NetIPInterface -InterfaceAlias "Ethernet" -NIMtuBytes 9000
Use Get-NetIPInterface
to verify the MTU was set with Set-NetIPInterface
.
Get-NetIPInterface -InterfaceAlias "Ethernet"
PS C:\Users\azureuser> Get-NetIPInterface -InterfaceAlias "Ethernet"
ifIndex InterfaceAlias AddressFamily NlMtu(Bytes) InterfaceMetric Dhcp ConnectionState PolicyStore
------- -------------- ------------- ------------ --------------- ---- --------------- -----------
6 Ethernet IPv6 3892 10 Enabled Connected ActiveStore
6 Ethernet IPv4 3892 10 Enabled Connected ActiveStore