Use powershell config network

1、打开Powershell 或在CMD下进入netsh/powershell
2、在netsh interface ip/ipv4 add/delete 设置有线网络或以太网IP,dns,route
3、查看网卡network Adapter 状态

实例1,Powershell 添加静态IP:

#参考命令
PS C:\Windows\system32> <strong>netsh interface ipv4 
Usage: add address [name=]<string>
             [[address=]<IPv4 address>[/<integer> [[mask=]<IPv4 mask>]]
                  [[type=]unicast|anycast]]
             [[gateway=]<IPv4 address> [gwmetric=]<integer>]
             [[validlifetime=]<integer>|infinite]
             [[preferredlifetime=]<integer>|infinite]
             [[subinterface=]<string>]
             [[store=]active|persistent]
             [[skipassource=]true|false]

Examples:

       add address "Wired Ethernet Connection" 10.0.0.2  255.0.0.0
       add address "Wired Ethernet Connection" gateway=10.0.0.3 gwmetric=2

       The first command adds a static IP address of 10.0.0.2 with a subnet
       mask of 255.0.0.0 to the Wired Ethernet Connection interface. The second
       command adds the IP address of 10.0.0.3 as a second default gateway
       for this interface with a gateway metric of 2.
       
#具体应用:
PS C:\Windows\system32><strong> netsh interface ipv4 add address "AP"  192.168.1.1
#检查配置
PS C:\Windows\system32> netsh interface ip show add

Configuration for interface "AP"
    DHCP enabled:                         No
    <strong>IP Address:                       192.168.1.1   </strong>
    Subnet Prefix:                        192.168.1.0/24 (mask 255.255.255.0)
    IP Address:                           192.168.99.11
    Subnet Prefix:                        192.168.99.0/24 (mask 255.255.255.0)
    InterfaceMetric:                      20

实例2,删除添加的IP地址:

#参考命令
PS C:\Windows\system32> <strong>netsh interface ipv4 delete
Usage: delete address [name=]<string> [[address=]<IPv4 address>]
    
  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值