Skip to content

Instantly share code, notes, and snippets.

@zoredache
Created December 21, 2021 07:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zoredache/995bb5bea01f6fd8dced0fda708c97c8 to your computer and use it in GitHub Desktop.
Save zoredache/995bb5bea01f6fd8dced0fda708c97c8 to your computer and use it in GitHub Desktop.
Windows Wireguard tunnel configured as only IPv6 gets an IPv4 APIPA address

wg_zoredache.conf

[Interface]
PrivateKey = ...
Address = 2001:db8:0:0:24ae:ebff:fef0:97e6/128

Will result in an interface looks like this.

PS C:\ProgramData\Wireguard> Get-NetIPAddress -ifAlias wg_zoredache

IPAddress         : 2001:db8:0:0:24ae:ebff:fef0:97e6
InterfaceIndex    : 49
InterfaceAlias    : wg_zoredache
AddressFamily     : IPv6
Type              : Unicast
PrefixLength      : 128
PrefixOrigin      : Manual
SuffixOrigin      : Manual
AddressState      : Preferred
ValidLifetime     : Infinite ([TimeSpan]::MaxValue)
PreferredLifetime : Infinite ([TimeSpan]::MaxValue)
SkipAsSource      : False
PolicyStore       : ActiveStore

IPAddress         : 169.254.39.88
InterfaceIndex    : 49
InterfaceAlias    : wg_zoredache
AddressFamily     : IPv4
Type              : Unicast
PrefixLength      : 16
PrefixOrigin      : WellKnown
SuffixOrigin      : Link
AddressState      : Preferred
ValidLifetime     : Infinite ([TimeSpan]::MaxValue)
PreferredLifetime : Infinite ([TimeSpan]::MaxValue)
SkipAsSource      : False
PolicyStore       : ActiveStore

PS C:\ProgramData\Wireguard> Get-NetIPInterface wg_zoredache | Format-List

InterfaceIndex                  : 49
InterfaceAlias                  : wg_zoredache
CompartmentId                   : 1
AddressFamily                   : IPv6
Forwarding                      : Disabled
ClampMss                        : Disabled
Advertising                     : Disabled
NlMtu(Bytes)                    : 1420
AutomaticMetric                 : Enabled
InterfaceMetric                 : 5
NeighborDiscoverySupported      : Yes
NeighborUnreachabilityDetection : Enabled
BaseReachableTime(ms)           : 30000
ReachableTime(ms)               : 38000
RetransmitTime(ms)              : 1000
DadTransmits                    : 0
DadRetransmitTime(ms)           : 1000
RouterDiscovery                 : Disabled
ManagedAddressConfiguration     : Disabled
OtherStatefulConfiguration      : Disabled
WeakHostSend                    : Disabled
WeakHostReceive                 : Disabled
IgnoreDefaultRoutes             : Disabled
AdvertisedRouterLifetime        : 00:30:00
AdvertiseDefaultRoute           : Disabled
CurrentHopLimit                 : 0
ForceArpNdWolPattern            : Disabled
DirectedMacWolPattern           : Disabled
EcnMarking                      : AppDecide
Dhcp                            : Disabled
ConnectionState                 : Connected
PolicyStore                     : ActiveStore

InterfaceIndex                  : 49
InterfaceAlias                  : wg_zoredache
CompartmentId                   : 1
AddressFamily                   : IPv4
Forwarding                      : Disabled
ClampMss                        : Disabled
Advertising                     : Disabled
NlMtu(Bytes)                    : 1420
AutomaticMetric                 : Enabled
InterfaceMetric                 : 5
NeighborDiscoverySupported      : Yes
NeighborUnreachabilityDetection : Enabled
BaseReachableTime(ms)           : 30000
ReachableTime(ms)               : 39500
RetransmitTime(ms)              : 1000
DadTransmits                    : 0
DadRetransmitTime(ms)           : 1000
RouterDiscovery                 : Disabled
ManagedAddressConfiguration     : Disabled
OtherStatefulConfiguration      : Disabled
WeakHostSend                    : Disabled
WeakHostReceive                 : Disabled
IgnoreDefaultRoutes             : Disabled
AdvertisedRouterLifetime        : 00:30:00
AdvertiseDefaultRoute           : Disabled
CurrentHopLimit                 : 0
ForceArpNdWolPattern            : Disabled
DirectedMacWolPattern           : Disabled
EcnMarking                      : AppDecide
Dhcp                            : Disabled
ConnectionState                 : Connected
PolicyStore                     : ActiveStore

What I really want is the IPv4 to be completely disabled, so like I would get if a command like this was run

PS C:\ProgramData\Wireguard> Disable-NetAdapterBinding -ifAlias wg_zoredache -ComponentID ms_tcpip

And my interface would look like this

PS C:\ProgramData\Wireguard> Get-NetIPAddress -ifAlias wg_zoredache

IPAddress         : 2001:db8:0:0:24ae:ebff:fef0:97e6
InterfaceIndex    : 49
InterfaceAlias    : wg_zoredache
AddressFamily     : IPv6
Type              : Unicast
PrefixLength      : 128
PrefixOrigin      : Manual
SuffixOrigin      : Manual
AddressState      : Preferred
ValidLifetime     : Infinite ([TimeSpan]::MaxValue)
PreferredLifetime : Infinite ([TimeSpan]::MaxValue)
SkipAsSource      : False
PolicyStore       : ActiveStore

PS C:\ProgramData\Wireguard> Get-NetIPInterface wg_zoredache | Format-List

InterfaceIndex                  : 49
InterfaceAlias                  : wg_zoredache
CompartmentId                   : 1
AddressFamily                   : IPv6
Forwarding                      : Disabled
ClampMss                        : Disabled
Advertising                     : Disabled
NlMtu(Bytes)                    : 1420
AutomaticMetric                 : Enabled
InterfaceMetric                 : 5
NeighborDiscoverySupported      : Yes
NeighborUnreachabilityDetection : Enabled
BaseReachableTime(ms)           : 30000
ReachableTime(ms)               : 38000
RetransmitTime(ms)              : 1000
DadTransmits                    : 0
DadRetransmitTime(ms)           : 1000
RouterDiscovery                 : Disabled
ManagedAddressConfiguration     : Disabled
OtherStatefulConfiguration      : Disabled
WeakHostSend                    : Disabled
WeakHostReceive                 : Disabled
IgnoreDefaultRoutes             : Disabled
AdvertisedRouterLifetime        : 00:30:00
AdvertiseDefaultRoute           : Disabled
CurrentHopLimit                 : 0
ForceArpNdWolPattern            : Disabled
DirectedMacWolPattern           : Disabled
EcnMarking                      : AppDecide
Dhcp                            : Disabled
ConnectionState                 : Connected
PolicyStore                     : ActiveStore
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment