使用netsh命令行进行网络管理

发布时间 2023-04-14 17:34:36作者: 哥伦布

显示网络适配器状态

netsh interface show interface
显示各个网络适配器的名称和状态
image

启用(禁用)网络适配器

本系列命令需要以“以管理员身份运行”。

  • 禁用网络适配器命令
    netsh interface set interface "公司网络" disabled

  • 启用网络适配器命令
    netsh interface set interface "公司网络" enabled

设置IP地址

本系列命令需要以“以管理员身份运行”。
netsh interface ip set address
用法 : set address [name=] [[addr=]IP address [mask=]IP subnet mask] [[gateway=]IP address [gwmetric=]integer]
netsh interface ip add address name="公司网络" addr=192.168.200.182 mask=255.255.255.0 gateway=192.168.200.254
set address命令用来为适配器设置一个IP,原来的IP会被清除并使用这个IP地址替换

增加IP地址

本系列命令需要以“以管理员身份运行”。
netsh interface ip add address
用法 : add address [name=] [[addr=]IP address [mask=]IP subnet mask] [[gateway=]IP address [gwmetric=]integer]
netsh interface ip add address name="公司网络" addr=192.168.200.182 mask=255.255.255.0 gateway=192.168.200.254
add address命令用来新增一个IP,原来的IP并不会被删除(或替换)