Search

How to configure IPv6 address Windows 2022 using PowerShell

Follow below steps to configure IPv6 address and other TCP/IP settings (Default Gateway address and DNS Server addresses) in Windows Server 2022 using PowerShell cmdlets. These configuration cmdlets are very helpful, if you are working in a ServerCore based machine.

Step 1 - You must run PowerShell as administrator, to configure IPv6 address and related TCP/IP settings in Windows Server 2022. To run PowerShell as administrator, create a Power Shell shortcut on your Windows Server desktop, right-click the PowerShell shortcut icon and then select "Run as administrator", as shown below.

new-ipv6-address-powershell-windows-2022-runas-01.jpg

 

In a ServerCore based Windows Server 2022 computer, you can use "runas" commmand from cmd or PowerShell, to run PowerShell as administrator. Enter the password of administrator, when prompted.

new-ipv6-address-powershell-windows-2022-runas-02.jpg

Step 2 - Next step is to identify the InterfaceIndex number of the network adapter, where you are going to configure IPv6 address. Use Get-NetAdapter PowerShell cmdlet as shown below to get the InterfaceIndex number of the network adapter where you want to configure IPv6 address.


Get-NetAdapter | Format-List

 

new-IPv6-address-powershell-windows-2022-get-netadapter.jpg

There can be many network adapters in a computer. As you can see from above output, the InterfaceIndex number is 3. We need to properly identify the network adapter and note it’s InterfaceIndex number. Every time when a PowerShell cmdlet related with this network adapter is run, we need to provide this InterfaceIndex number.

Step 3 - Once we had identified the network adapter and its InterfaceIndex number, we can use PowerShell "New-NetIPAddress" cmdlet to configure a new IPv6 address and Default Gateway address. You can see from the below PowerShell cmdlet, you need to provide InterfaceIndex number when you run the cmdlet, to identify the network adapter.

From the below cmdlet, you can understand that the IPv6 address we are configuring now is 2001:db8:8211:12::8080, IPv6 address prefix is 64 (-PrefixLength 64) and Default Gateway address we are configuring is 2001:db8:8211:12::1. When you configure in your environment change those IPv6 numbers according to your requirement.

You can also note that the InterfaceIndex number used in below "New-NetIPAddress" PowerShell cmdlet is 3. We found that number from "Get-NetAdapter" PowerShell cmdlet.


New-NetIPAddress -IPAddress 2001:db8:8211:12::8080 -InterfaceIndex 3 -DefaultGateway 2001:db8:8211:12::1 -AddressFamily IPv6 -PrefixLength 64

 

new-ipv6-address-powershell-windows-2022-new-netipaddress.jpg

Step 4 - Now we have configured a new IPv6 address and Default Gateway address for the network adapter with InterfaceIndex number 3. To check whether the IPv6 address is configured properly, use PowerShell "Get-NetIPAddress" cmdlet as shown below.


Get-NetIPAddress -InterfaceIndex 3 -AddressFamily IPv6 -Type Unicast -PrefixOrigin Manual

 

new-ipv6-address-powershell-windows-2022-get-netipaddress.jpg

From the above cmdlet output, we can see that the IPv6 address configured is 2001:db8:8211:12::8080. Now, to check whether Default Gateway address is configured properly, use "Get-NetRoute" command as shown below.


Get-NetRoute -InterfaceIndex 3 -AddressFamily IPv6 -DestinationPrefix "::/0"

new-ipv6-address-powershell-windows-2022-get-netroute.jpg

From the above cmdlet output, we can see that the Default Gateway address configured is 2001:db8:8211:12::1.

Step 5 - Last TCP/IP setting we are going to configure is DNS server addresses. Use "Set-DnsClientServerAddress" PowerShell cmdlet to configure DNS Server addresses, as shown below.


Set-DnsClientServerAddress -InterfaceIndex 3 -ServerAddresses  2001:4860:4860::8888

 

new-ipv6-address-powershell-windows-2022-set-dnsclientserveraddress.jpg

Step 6 - To check whether the DNS Server addresses are configured properly, use PowerShell "Get-DnsClientServerAddress" cmdlet as shown below.


Get-DnsClientServerAddress -InterfaceIndex 3 -AddressFamily IPv6

 

new-ipv6-address-powershell-windows-2022-get-dnsclientserveraddress.jpg

Written by Jajish Thomas.
Last updated on 9 April, 2022.
Related Tutorials
Introduction to Windows Server 2022
New features of Windows Server 2022
Hardware requirements for Windows Server
Different editions of Windows Server 2022
Difference between Server Core and Server with Desktop experience (GUI)
How to install Windows 2022 Server
How to use search functionality in Windows Server 2022
How to hide or unhide search box
How to add This PC icon to desktop in windows 2022
How to add Network icon to desktop in windows 2022
How to rename computer name in Windows 2022
How to rename computer name using PowerShell
How to configure IPv4 Address in Windows 2022
How to configure IPv6 Address in Windows 2022
How to configure IPv4 address Windows 2022 using PowerShell
How to configure IPv6 address Windows 2022 using PowerShell
How to shut down or restart Windows 2022
How to sign out from Windows Server 2022
How to run a program or app as administrator