windows通过命令获取mtu和修改mtu

2023-03-16 19:42:04 浏览数 (1)

windows通过命令获取mtu

代码语言:javascript复制
一、支持>2008R2的系统,不支持≤2008R2

#快
$NICName=(Get-WmiObject Win32_NetworkAdapter -Filter 'NetEnabled=True').NetConnectionID
Get-NetAdapter $NICName| Format-List *|findstr /i mtu

#快
$NICName=(Get-WmiObject Win32_NetworkAdapter -Filter 'NetEnabled=True').NetConnectionID
(Get-NetAdapter $NICName).MtuSize

#有点慢
$NICName=(Get-WmiObject Win32_NetworkAdapter -Filter 'NetEnabled=True').NetConnectionID
(Get-NetIPConfiguration -InterfaceAlias $NICName -Detailed).NetIPv4Interface.NlMTU




二、支持≥2008R2的系统

#快
$NICName=(Get-WmiObject Win32_NetworkAdapter -Filter 'NetEnabled=True').NetConnectionID
((netsh interface ipv4 show subinterface $NICName| Select-Object -Index 3).substring(0,14)).Trim(" `t`n`r")

windows通过命令修改mtu:

https://cloud.google.com/vpc/docs/change-mtu-vpc-network?hl=zh-cn

代码语言:javascript复制
$NICName=(Get-WmiObject Win32_NetworkAdapter -Filter 'NetEnabled=True').NetConnectionID
$idx=(Get-WmiObject win32_networkadapterconfiguration -filter "ipenabled = 'true'").InterfaceIndex

0 人点赞