Theo de Raadt said on Sun, 20 Nov 2022 19:35:22 -0700

>Steve Litt <sl...@troubleshooters.com> wrote:
>
>> Vitaliy Makkoveev said on Mon, 21 Nov 2022 03:48:21 +0300
>>   
>> >> On 20 Nov 2022, at 18:06, Odd Martin Baanrud <mar...@lb7ye.net>
>> >> wrote:
>> >> 
>> >> Hello,
>> >> 
>> >> I have a Raspberry Pi 4 with 2 USB NIC’s attached.
>> >> One via USB3 (ure0), and the other via USB2 (ure1).
>> >> Since they are connected to different USB interfaces, I thaught
>> >> they would get configured the same way on reboot. But that’s not
>> >> the case. They became swapped on reboot.
>> >> Is there a way to “lock” the configuration I want?
>> >> So the USB3 NIC always become ure0, and the USB2 ure1.
>> >> 
>> >> Regards, Martin
>> >>     
>> >
>> >You could parse ifconfig(8) output to determine which names network
>> >interfaces received. But unfortunately, you can’t rename
>> >interfaces.  
>> 
>> During your parsing you could assign each one to an environment
>> variable such that, for instance, $lan contains the network card name
>> of the LAN one, and $wan contains the network name of the one going
>> to the Internet. Unfortunately, this would probably mean changing a
>> lot of existing shellscripts, but it's doable.  
>
>But that is not the problem.
>
>hostname.* installs addresses on an interface, based upon the name of
>that interface.
>
>So it is too late for what you suggest.
>
>Unless the suggestion is have each hostname.* do a !command to a
>script which does the assigning.  That is pretty crazy.
>
>pf.conf is not the problem either, because that can be entirely
>written using egress and groups.
>
>
>
>There is a problem with device attachment -> naming a device at that
>moment -> using that name in netstart.. but I am not sure how we could
>solve this without creating bigger problems for everyone else in the
>other non-hot-plug configurations, which is the majority of users with
>>1 network device.  

I wasn't implying that a shellscript be supplied by the OpenBSD
distribution. I was suggesting that simple shellscript, written by the
user, run in early boot, could be used to assign the proper network
names environment variables and then re-set any hostname stuff.

Something like the following:

netdevprefix="eth"
lanprefix="192.168.0"

# I'm not very knowledgeable about ifconfig,
#  but you know what I mean
for i in `ifconfig whatever`; do
  if test `ifconfig whatever2` | grep $lanprefix; then
    lan=i
  else
    wan=i

reset_hostname_everywhere $lan $wan

Obviously the preceding is missing a lot, wrong, and won't work as is,
but it could be made to work fairly easily, and then the Vitaliy
Makkoveev could use that shellscript, while most people won't have to,
and the OpenBSD distribution won't need to make any changes. Later,
when the distribution does implement something based on MAC addresses
or some other solution, Vitaliy could stop using the shellscript.

SteveT

Steve Litt 
Autumn 2022 featured book: Thriving in Tough Times
http://www.troubleshooters.com/bookstore/thrive.htm

Reply via email to