OPNsense Forum

Archive => 21.1 Legacy Series => Topic started by: djrocksmith on July 10, 2021, 12:59:54 AM

Title: Can't set WAN interface subnet bit count to 31
Post by: djrocksmith on July 10, 2021, 12:59:54 AM
Hi all,

My first time setting this up, but I write software for a living so I'm reasonably ok with technical help.

I set my WAN (which goes to the internet provider) to a non DHCP setup, my ISP can't provide it for some reason.

I enter my IP address *.*.*.201

Then Enter the new Wan IPv4 subnet bit count to 31.  The subnet should be 255.255.255.254.

I get the error:-

"You cannot set network address to an interface"

Any ideas?

Cheers

Clinton
Title: Re: Can't set WAN interface subnet bit count to 31
Post by: Fright on July 10, 2021, 04:02:07 PM
hi
It seems that the setaddr.php script makes no exception for /31, /32 networks on address validation.
you can try to set /24 (or some) network on wizard and then change this settings in web-GUI
Title: Re: Can't set WAN interface subnet bit count to 31
Post by: djrocksmith on July 11, 2021, 02:42:24 AM
Thanks for that idea mate.

I actually edited the conf XML file and put the values in manually.

I also looked at the code on GitHub to see how it works and there is probably a pull request I could do to fix it.

Cheers
Title: Re: Can't set WAN interface subnet bit count to 31
Post by: franco on July 13, 2021, 11:58:21 AM
/31 has the problem that only two addresses exist and the first is the network address and the second one is the broadcast address. There is no room to fit a host address and both setport.sh and interfaces.php do validate this in the IPv4 case.

Circumventing this restriction is not great...


Cheers,
Franco
Title: Re: Can't set WAN interface subnet bit count to 31
Post by: fabian on July 13, 2021, 01:10:04 PM


Quote from: franco on July 13, 2021, 11:58:21 AM
/31 has the problem that only two addresses exist and the first is the network address and the second one is the broadcast address. There is no room to fit a host address and both setport.sh and interfaces.php do validate this in the IPv4 case.

That is not correct. 31 has two host addresses. The broadcast address is the other host address. Network is probably handled the same way. This special net ask is not supported by all operating systems.
Title: Re: Can't set WAN interface subnet bit count to 31
Post by: franco on July 13, 2021, 01:28:51 PM
> 31 has two host addresses. The broadcast address is the other host address.

Sorry, this is nonsense. It can't be both.

> This special net ask is not supported by all operating systems.

Which is, um, why it's not supported. I have difficulty grasping your answer as a whole.


Cheers,
Franco
Title: Re: Can't set WAN interface subnet bit count to 31
Post by: franco on July 13, 2021, 01:32:31 PM
If you want to split hairs on "usabe" hosts fine, but the point remains the same, i.e. https://www.calculator.net/ip-subnet-calculator.html at the bottom.
Title: Re: Can't set WAN interface subnet bit count to 31
Post by: Fright on July 13, 2021, 01:34:29 PM
@franco, sorry, but / 31 subnets are allowed and can be used to reduce address consumption (https://datatracker.ietf.org/doc/html/rfc3021 and https://www.cisco.com/c/en/us/td/docs/ios-xml/ios/ipaddr_ipv4/configuration/xe-3s/asr903/ipv4-xe-3s-asr903-book/config-ipv4-addr.html#GUID-A6AA4621-6662-4CC5-BE57-15CCD38C0FA2). and as far as I see interfaces.php is take it into account
https://github.com/opnsense/core/blob/11b5fe6e9cb1babd68f1b56e44767fc018df3acd/src/www/interfaces.php#L786
Title: Re: Can't set WAN interface subnet bit count to 31
Post by: franco on July 13, 2021, 01:38:42 PM
Okay, I missed the "if ($pconfig['subnet'] < 31) {" ... who wants to do the PR?


Cheers,
Franco
Title: Re: Can't set WAN interface subnet bit count to 31
Post by: Fright on July 13, 2021, 01:57:31 PM
https://github.com/opnsense/core/pull/5093
for future references
https://github.com/opnsense/core/commit/b1241aeb74ccf
Title: Re: Can't set WAN interface subnet bit count to 31
Post by: fabian on July 13, 2021, 08:46:32 PM
@franco: https://datatracker.ietf.org/doc/html/rfc3021 (https://datatracker.ietf.org/doc/html/rfc3021)
Directed Broadcast = Send it to the other node.
Title: Re: Can't set WAN interface subnet bit count to 31
Post by: franco on July 14, 2021, 08:07:26 AM
It's a PPP type tunnel setup and while it has some benefits on WAN side it's irrelevant for any LAN you're going to set up.


Cheers,
Franco