0
点赞
收藏
分享

微信扫一扫

Powershell 配置IP和网关地址

以下介绍配置IP和网关地址,同时禁用IPv6.

function Set_IPAddress{
Param(
[Parameter(Mandatory=$true)]
[string]$IPAddress,
[Parameter(Mandatory=$true)]
[string]$IPGateway,
[Parameter(Mandatory=$true)]
$InterfaceIndex,
[Parameter(Mandatory=$true)]
$InterfaceName
)

# Configuration IP Gateway and DNS
New-NetIPAddress -InterfaceIndex $InterfaceIndex -IPAddress $IPAddress -AddressFamily IPv4 -PrefixLength 24 -DefaultGateway $IPGateway
Set-DnsClientServerAddress -InterfaceIndex $InterfaceIndex -ServerAddresses $IPAddress

# Disable IPv6
Disable-NetAdapterBinding -Name $InterfaceName -ComponentID ms_tcpip6
}


$IPAddress = "10.1.1.1"
$IPGateway = "10.1.1.254"
$InterfaceIndex = (Get-NetAdapter).InterfaceIndex
$InterfaceName = (Get-NetAdapter).Name

Set_IPAddress -InterfaceIndex $InterfaceIndex -InterfaceName $InterfaceName -IPAddress $IPAddress -IPGateway $IPGateway

Powershell 配置IP和网关地址_IP

Powershell 配置IP和网关地址_DNS_02

举报

相关推荐

0 条评论