IP相关

1. Rename a Network Interface from the Command Line

netsh interface ip show interfaces
netsh interface set interface name = "Local Area Connection 5" newname = "iSCSI1"

2. Configure IP/GW/DNS

Set IP/GW:
netsh interface ip show interfaces
netsh interface ip set address "Ethernet0 2" source=static 10.24.101.19 255.255.0.0 10.24.255.254

Set DNS:
netsh interface ip set dnsservers "Ethernet0 2" static 10.110.1.13

Add second DNS:
netsh interface ip add dnsservers "Ethernet0 2" 10.110.1.14

Add second IP:
netsh interface ip add address "Ethernet0 2" 10.24.101.18 255.255.0.0

3. Disable IPv6 Using PowerShell

Get-NetAdapterBinding -ComponentID ms_tcpip6
Disable-NetAdapterBinding -Name "Ethernet0 2" -ComponentID ms_tcpip6

You can use the wildcard * to disable IPv6 on all network adapters, instead of disabling them one by one.

Disable-NetAdapterBinding -Name "*" -ComponentID ms_tcpip6

Whenever you need to enable IPv6 again, just run this command:

Enable-NetAdapterBinding -name * -ComponentID ms_tcpip6

4. Run powershell script with CMD

Powershell.exe -noexit "& ""c:\temp\aa.ps1"""

猜你喜欢

转载自blog.51cto.com/549687/2590005