Trying IPv6 Communication with PowerShell — How is the localhost TCP of ::1 Different from IPv4?

ネットワーク・RFCカテゴリを表すパンダのイラスト Networking / RFC

About This Article
This article is created using an automated generation workflow leveraging generative AI. Based on RFC 4291, Microsoft Learn Socket APIs, and existing Daily-Code-Samples, it is structured to observe IPv6 TCP using only ::1 without using an external network.

Verification Status: 📘 Official Information Confirmed / Windows Physical Machine Unverified

IPv6 can be tested using the loopback address ::1 on your own PC, even without an external network. Just like IPv4's 127.0.0.1, you can run a server and client on a single PC to observe differences in endpoint notation and AddressFamily.

Getting Started

The success condition this time is to send HELLO_IPV6 and receive ACK_IPV6. The complete version is hosted on GitHub, and the core part is examined in the text.

$listener = [Net.Sockets.TcpListener]::new(
    [Net.IPAddress]::IPv6Loopback,
    48061
)
$listener.Server.DualMode = $false
$listener.Start()

Write-Host "[LISTEN] $($listener.LocalEndpoint)"

$client = [Net.Sockets.TcpClient]::new(
    [Net.Sockets.AddressFamily]::InterNetworkV6
)
$client.Connect([Net.IPAddress]::IPv6Loopback, 48061)

Write-Host "[SUCCESS] connected to $($client.Client.RemoteEndPoint)"

$client.Dispose()
$listener.Stop()

The IPv6 loopback is defined in the IPv6 Addressing Architecture as ::1.

What to Look At

The output endpoint will not be the IPv4 127.0.0.1:48061, but rather something like [::1]:48061.

sequenceDiagram
    participant C as Client [::1]
    participant S as Server [::1]
    C->>S: TCP connect
    S-->>C: accept
    C->>S: HELLO_IPV6
    S-->>C: ACK_IPV6

The TCP flow of "connect → send → receive → disconnect" shares many commonalities with IPv4; what changes are the addressing scheme and socket configurations.

Changing One Thing

Change only the port from 48061 to 48062 and re-run.

Since the complete sample takes -Port arguments, you can compare them as follows.

.Test-Ipv6LoopbackTcp.ps1 -Port 48062

By changing only the port first without altering the address or DualMode simultaneously, it becomes easier to track "what change caused what result."

Reason for Setting DualMode to False

Since this smoke test aims to observe IPv6 itself, the listener is set to DualMode = $false. DualMode relates to configurations where an IPv6 socket also handles IPv4, so mixing it in from the start would increase the number of variables to observe.

For Production Use

Working on localhost does not prove that external IPv6 communication is available. In actual operations, verify the following items separately as well.

  • Whether IPv6 is enabled on the OS/NIC

  • DNS AAAA records

  • Firewall

  • Listen address

  • Dual-stack policy

  • Handling of IPv4-mapped addresses

Additionally, it is safer to design Sockets/Streams with Dispose() / Stop() so that they can try/finally even in the event of an exception. The complete version includes cleanup handling.

GitHub Sample

Official and Primary Sources

Summary

::1By using

Document information

Article title
Trying IPv6 Communication with PowerShell — How is the localhost TCP of ::1 Different from IPv4?
Published
Updated
Source
https://papanda925.com/?p=15339&lang=en

License: Text and original figures for which this site holds the relevant rights are available under CC BY 4.0 , unless otherwise noted. This article may include content created or edited with generative AI. If code has a separate license notice or a linked GitHub repository license, that license takes precedence for the code. Quotations, third-party materials, images, and trademarks are excluded from this license. Usage policy

Copied title and URL