opnsense / core

OPNsense GUI, API and systems backend
https://opnsense.org/
BSD 2-Clause "Simplified" License
3.07k stars 700 forks source link

Enable choosing the interface identifier on interface creation #7522

Open bimbar opened 2 weeks ago

bimbar commented 2 weeks ago

Important notices

Before you add a new report, we ask you kindly to acknowledge the following:

Is your feature request related to a problem? Please describe.

There are two scenarios:

Describe the solution you like

On creating an interface, make it possible to either choose the interface id outright, or choose the number X in optX.

Describe alternatives you considered

Creating interfaces in the right order is possible, but especially in the case of non-contiguous numbering, which can happen if an interface is deleted later, this is not very convenient.

Additional context

Discussed it with franco: https://forum.opnsense.org/index.php?topic=40985.0;topicseen

AdSchellevis commented 4 days ago

I think the easiest option would be to add an optional field in Interfaces: Assignments which accepts lan,wan, optXXX and when not provided pick the first free one in the same order.

Which requires changes in

https://github.com/opnsense/core/blob/df7adc41c2f1c61a466be2b66c390dea206f5252/src/www/interfaces_assign.php#L118-L125

and a validation (check pattern and not used) around here:

https://github.com/opnsense/core/blob/df7adc41c2f1c61a466be2b66c390dea206f5252/src/www/interfaces_assign.php#L113

Plus side would be that when you drop wan and recreate without optional argument, it would also recreate wan (which is currently not supported).