0

My school allocated a /64 prefix IPv6 block to all my schoolmates, I want to fix the 64 bit suffix of my Windows 10 22H2 PC, so I executed the following PowerShell script to set my custom IPv6 address $ip the only one IP that is actually used for outgoing packages and succeeded.

Add a custom IPv6 address:

New-NetIPAddress -InterfaceAlias Wi-Fi -IPAddress $ip -PolicyStore ActiveStore -PrefixLength 64
Set-NetIPAddress -IPAddress $ip -SkipAsSource $False

Set all other public IPv6 addresses' SkipAsSource to $True to prevent them from being used for outgoing packages:

Get-NetIPAddress -InterfaceAlias Wi-Fi | ForEach-Object {
    if( ($_.AddressFamily.ToString() -eq "IPv6") -And ($_.IPAddress -ne $ip) -And ($_.PrefixOrigin.ToString() -ne "WellKnown") ){
        Set-NetIPAddress -IPAddress $_.IPAddress -SkipAsSource $True
    }
}

But after a few minutes, the IPv6 address whose PrefixOrigin is "Dhcp", its SkipAsSource became $False, which made my PC use the DHCP IPv6 address for outgoing packages. In order to find why, I executed the following PowerShell script to find the accurate time when the DHCP IPv6 address's SkipAsSource became $False:

$isChanged = $false
while( !$isChanged ){
    Start-Sleep 10
    Get-Date
    Get-NetIPAddress -InterfaceAlias "Wi-Fi" -AddressFamily IPv6 | ForEach-Object{
        if($_.PrefixOrigin -eq "Dhcp"){
            if($_.SkipAsSource -eq $False){
                $global:isChanged = $True
                Write-Host -ForegroundColor Red "Found it"
                break
            }else{
                Write-Host "Nothing wrong"
            }
        }
    }
}

The time span I found is between 2023-07-12 02:20:00 UTC+8 and 2023-07-12 02:20:10 UTC+8, then found the following system log whose timestamp is 2023-07-12 02:20:01 UTC+8 which maybe related.

system log about event 7003 - Roam Complete

<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
  <System>
    <Provider Name="Netwtw04" />
    <EventID Qualifiers="16384">7003</EventID>
    <Version>0</Version>
    <Level>4</Level>
    <Task>0</Task>
    <Opcode>0</Opcode>
    <Keywords>0x80000000000000</Keywords>
    <TimeCreated SystemTime="2023-07-11T18:20:01.5397220Z" />
    <EventRecordID>122318</EventRecordID>
    <Correlation />
    <Execution ProcessID="4" ThreadID="9152" />
    <Channel>System</Channel>
    <Computer>ComputerName</Computer>
    <Security />
  </System>
  <EventData>
    <Data>\Device\NDMP5</Data>
    <Data>Intel(R) Dual Band Wireless-AC 3165</Data>
    <Binary>0000080002003800000000005B1B00400000000000000000000000000000000000000000000000000000000000000000</Binary>
  </EventData>
</Event>

And the following two logs from Applications and Services Logs\Microsoft\Windows\Dhcp-Client\Microsoft-Windows-DHCP Client Events/Admin have the same timestamp. There is no log with the same or neighboring timestamp from Applications and Services Logs\Microsoft\Windows\Dhcp-Client\Microsoft-Windows-DHCPv6 Client Events/Admin:

DHCP Client Events/Adminevent log about event 50067

<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
  <System>
    <Provider Name="Microsoft-Windows-Dhcp-Client" Guid="{15a7a4f8-0072-4eab-abad-f98a4d666aed}" />
    <EventID>50067</EventID>
    <Version>0</Version>
    <Level>4</Level>
    <Task>3</Task>
    <Opcode>57</Opcode>
    <Keywords>0x4000000000000000</Keywords>
    <TimeCreated SystemTime="2023-07-11T18:20:01.5559344Z" />
    <EventRecordID>6641</EventRecordID>
    <Correlation />
    <Execution ProcessID="2044" ThreadID="6392" />
    <Channel>Microsoft-Windows-Dhcp-Client/Admin</Channel>
    <Computer>sanfrancisco</Computer>
    <Security UserID="S-1-5-19" />
  </System>
  <EventData>
    <Data Name="NetworkHintString">SSID</Data>
    <Data Name="NetworkHint">SSID hex</Data>
    <Data Name="HWLength">6</Data>
    <Data Name="HWAddress">MAC address</Data>
  </EventData>
</Event>

DHCP Client Events/Adminevent log about event 50065

<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
  <System>
    <Provider Name="Microsoft-Windows-Dhcp-Client" Guid="{15a7a4f8-0072-4eab-abad-f98a4d666aed}" />
    <EventID>50065</EventID>
    <Version>0</Version>
    <Level>4</Level>
    <Task>3</Task>
    <Opcode>55</Opcode>
    <Keywords>0x4000000000000000</Keywords>
    <TimeCreated SystemTime="2023-07-11T18:20:01.5559369Z" />
    <EventRecordID>6642</EventRecordID>
    <Correlation />
    <Execution ProcessID="2044" ThreadID="6392" />
    <Channel>Microsoft-Windows-Dhcp-Client/Admin</Channel>
    <Computer>sanfrancisco</Computer>
    <Security UserID="S-1-5-19" />
  </System>
  <EventData>
    <Data Name="NetworkHintString">SSID</Data>
    <Data Name="NetworkHint">SSID hex</Data>
    <Data Name="HWLength">6</Data>
    <Data Name="HWAddress">MAC address</Data>
  </EventData>
</Event>

So how to prevent the DHCP IPv6 address from being reverted? Or how to disable DHCPv6?

2
  • did you disable DHCP for IPv6 in the adapter properties? Commented Jul 12, 2023 at 8:25
  • Although I've executed the above script to assign a static IPv6 address, Settings\Network & Internet\Status\"Properties" button of the current connected network\IP Settings still shows DHCPv6 is on, then I assigned a IPv6 address here. Thanks for your notice, hoping my problem will be solved in this way! lifewire.com/disable-dhcp-5075607 @JaromandaX
    – Hertz Hu
    Commented Jul 12, 2023 at 10:52

1 Answer 1

1

I found that I can disable DHCPv6 for a net card by Set-NetIPInterface -Dhcp Disable -InterfaceAlias Wi-Fi -AddressFamily IPv6. After executing that, my net card had only 2 public IPv6 addresses, respectively set by myself mannally and SLAAC. But even after I set the SLAAC IPv6's SkipAsSource as $True, it still reverted to $False hours after. Now I disabled SLAAC by netsh interface ipv6 set interface Wi-Fi routerdiscovery=disabled and my problem got solved completely as Windows have only one public IPv6 address.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .