cmd中netsh工具的使用
程序员文章站
2022-07-03 09:09:14
...
1 查看帮助
// 打印帮助,功能非常强大
netsh /?
// 进入工具更方便,"?"可查看帮助
netsh
2 创建wifi热点
//创建一个虚拟网卡,并共享到该网卡:
netsh wlan set hostednetwork mode=allow ssid=[wifi name] key=[wifi password]
//启用/禁用承载网络
netsh wlan start/stop hostednetwork
3 设置ip和dns
// 显示接口,"interface"可简写成"int"
netsh interface show interface
// 启用/禁用接口,接口重命名
//注意:如果interface_name是中文,有可能报错:“此名称的接口未与路由器一起注册”
netsh int set int "interface_name" admin=enabled
netsh int set int "interface_name" newname="new_interface_name"
// 设置ip和dns,分别是ip/掩码/网关,参数名称(name/source/address/mask/gateway)可省略
netsh interface ipv4 set address name="无线网络连接" source=dhcp //自动获取ip
netsh interface ipv4 set address name="无线网络连接" source=static address="192.168.100.60" mask="255.255.255.0" gateway="192.168.100.1" //静态ip完整写法
netsh interface ipv4 set address "无线网络连接" static 192.168.100.60 255.255.255.0 192.168.100.1 //静态ip省略写法
netsh interface ipv4 set dns name="无线网络连接" source=dhcp //自动
netsh interface ipv4 set dns name="无线网络连接" source=static address="202.106.0.20" //静态
netsh interface ipv4 set dns "无线网络连接" static 202.106.0.20 //静态