【问题标题】:Enable Jump Frame启用跳帧
【发布时间】:2017-09-22 01:47:34
【问题描述】:

我正在尝试创建一个 powershell 脚本以在 Openstack windows VM 上启用 Jumpframe。查找活动网卡的命令和当前 MTU 值以及更改 MTU 值的命令都在下面。

从下面的命令中,我首先找到活动网卡,然后尝试找到该 NIC 的 MTU 值,如果我发现 MTU 值小于 1600,我需要将其更改为 9000。

PS C:\> **wmic nic where "netconnectionid like '%'" get netconnectionid**
NetConnectionID
Ethernet

PS C:\> **netsh.exe int ipv4 show subint**

   MTU  MediaSenseState   Bytes In  Bytes Out  Interface
------  ---------------  ---------  ---------  -------------
4294967295                1          0       1400  Loopback Pseudo-Interface 1
  1200                1  1335974344    5867793  Ethernet

PS C:\> **netsh int ipv4 set subint "Ethernet" mtu=9000 store=persistent**

谁能告诉我如何写一个条件来完成我正在寻找的东西?

【问题讨论】:

  • 使用 -Name 参数尝试 Get-NetAdapter
  • 你可以使用Get-NetIPInterface |? {$_.NlMtu -lt 1600}

标签: powershell


【解决方案1】:

尝试以下方法:

$enabledAdaptersNames = Get-NetAdapter |? {$_.status -eq "Up" -or $_.status -eq "Disconnected"} | Select -ExpandProperty name

Get-NetIPInterface |? { $enabledAdapterNames -contains $_.InterfaceAlias -and $_.NlMtu -lt 1600} |  Set-NetIPInterface -NlMtuBytes 9000

【讨论】:

  • Get-NetAdapter 和 Set-NetIPInterface 命令不起作用,因为我在基于 KVM 的 windows VM 上运行此命令。
  • 我可以使用您与我的命令共享的方法。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多