查看网卡名称及编号:
netsh int ipv4 show int
查看当前ip地址:
netsh int ipv4 show ipadd level=verbose
开启dhcp和静态ip共存:
netsh int ipv4 set int "Ethernet0" dhcpstaticipcoexistence=enabled
添加ip地址,skipassource设置是否使用此ip为出口源ip,默认新添加的ip为出口ip:
netsh int ipv4 add add "Ethernet0" 192.168.1.22/24 skipassource=true
已添加的ip修改skipassource参数:
Get-NetIPAddress 192.168.1.22 | Set-NetIPAddress -SkipAsSource $True
Set-NetIPAddress -IPAddress "192.168.1.22" -InterfaceAlias "Ethernet0" -SkipAsSource $false
多网卡可修改路由及网卡metric跃点数指定优先网络出口:
netsh int ipv4 show rou
netsh int ipv4 set int "Ethernet0" metric=2
netsh int ipv4 set rou 0.0.0.0/0 "Ethernet0" 192.168.1.1 metric=100
route change 0.0.0.0 mask 0.0.0.0 192.168.1.1 metric 100 if 4