Setting rfc3021 IP address via powershell

RJSocha 1 Reputation point
2020-07-25T20:47:22.56+00:00

Hi,

We are using RFC3021 compatible IP subnets (ie. /31 or /32). Hosts are directly connected to routers via L2 separation layer.

For example subnet: 192.168.1.2/31

GW: 192.168.1.2
HOST: 192.168.1.3
MASK: 255.255.255.254

Windows OS's do not suppport RFC3021 officialy. For example DHCP client dosen't work with the above subnet:

13635-nodhcp31.png

But setting this IP statically with changed subnet/prefix to 255.255.255.255 (/32) works from Windows Server 2008 to Windows Server 2019.
(I call this on-link setup - same as in Linux world).

Setting this example address via netsh - no problem:

13687-netsh31.png

Setting this same address via UI - with warning, but no other problems:

13732-winui-ip31.png

Result after hitting "Yes":

13659-winui-ip31-2.png

But setting this address via PowerShell (with prefix 31):

New-NetIPAddress -AddressFamily IPv4 -IPAddress 192.168.1.3 -PrefixLength 31 -DefaultGateway 192.168.1.2 -InterfaceAlias "Internet"
New-NetIPAddress : The parameter is incorrect.
At line:1 char:1

  • New-NetIPAddress -AddressFamily IPv4 -IPAddress 192.168.1.3 -PrefixLe ...
  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  • CategoryInfo : InvalidArgument: (MSFT_NetIPAddress:ROOT/StandardCimv2/MSFT_NetIPAddress) [New-NetIPAddress], CimException
  • FullyQualifiedErrorId : Windows System Error 87,New-NetIPAddress

or with prefix 32:

New-NetIPAddress -AddressFamily IPv4 -IPAddress 192.168.1.3 -PrefixLength 32 -DefaultGateway 192.168.1.2 -InterfaceAlias "Internet"
New-NetIPAddress : DefaultGateway 192.168.1.2 is not on the same network segment (subnet) that is defined by the IP address 192.168.1.3 and PrefixLength 32.
At line:1 char:1

  • New-NetIPAddress -AddressFamily IPv4 -IPAddress 192.168.1.3 -PrefixLe ...
  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  • CategoryInfo : InvalidArgument: (MSFT_NetIPAddress:ROOT/StandardCimv2/MSFT_NetIPAddress) [New-NetIPAddress], CimException
  • FullyQualifiedErrorId : Windows System Error 87,New-NetIPAddress

Both trigger above errors.

I tried to use "-ErrorAction" to "force" this configuration - but no success.

My question is: could this address be setup via powershell? Or is it not supported? (two other configuration interfaces work OK)

Best regards

Windows for business Windows Server User experience PowerShell
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Marco Shaw 11 Reputation points
    2020-07-26T16:59:10.207+00:00

    You could definitely file a bug, but that could take weeks/months to fix in the code. I'd recommend simply using netsh in your PowerShell script/code.

    2 people found this answer helpful.
    0 comments No comments

  2. Randall Falting 1 Reputation point
    2021-04-29T05:35:29.763+00:00

    It doesnt seem to matter what the prefix is, it seems that the default gateway is the cause. I still get:
    New-NetIPAddress : DefaultGateway 192.168.254.2 is not on the same network segment (subnet) that is defined by the IP address 5.5.5.5 and PrefixLength 24.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.