用 PowerShell 把网卡改回自动获取 IP(DHCP)

静态 IP 试完之后,一条命令让网卡恢复自动获取地址。

Windows网络DHCPPowerShell低风险
以管理员运行 `Set-NetIPInterface -InterfaceAlias "Ethernet" -Dhcp Enabled`,即可让网卡恢复 DHCP 自动获取。

01命令

命令
$ Set-NetIPInterface -InterfaceAlias "Ethernet" -Dhcp Enabled

02作用说明

如果之前设置的静态 IP 导致网络异常,把网卡的 DHCP 标志改回 Enabled 后,Windows 会重新从路由器获取地址、网关和 DNS。设置立即生效;如果网卡没有立刻连上,再执行一次 ipconfig /renew 即可。可用 Get-NetIPAddress -AddressFamily IPv4 核对结果。

03风险

风险低风险
使用条件Administrator PowerShell; built-in NetTCPIP module on Windows 8.1/10/11.

04撤销

✓无需撤销——该命令不会改变持久状态。

05来源

  • NetTCPIP module reference
    Microsoft Learn · vendor-doc · 2026-09-17
    依据: Module reference lists Set-NetIPInterface among the TCP/IP configuration cmdlets.
  • Set-NetIPInterface (NetTCPIP)
    Microsoft Learn · vendor-doc · 2026-09-17
    依据: Documents the -Dhcp parameter with Enabled/Disabled values and -InterfaceAlias for selecting the adapter.

最后验证: 2026-09-19 · 分类: 网络

06相关方案