PfSense Multiple USB Network

I currently have a backup WAN installed from a USB modem in stick mode. I scripted the startup, APN and such. It has worked for years without problem. It is assigned a Uex interface. I added a second USB modem for a mail server. Upon bootup, the interfaces interchange and are not functional. The Ue0 should be Ue1 for example. The next boot there may be no problem. How can I script a startup to ensure the USB device matches the assigned interface? I assume it must be that the first device for Ue0 must boot and register the APN before the second device can. Since NIC cards boot in order it is not normally a problem. The USB issue has baffled me. I appreciate any pointers!

Though I don’t recommend doing any of this… you could probably run a command to pull the MAC for device in question and then change the interface name with the ifconfig command.

I haven’t tested this, but something like this

#!/bin/sh

# MAC addresses of the USB modems
mac1="00:11:22:33:44:55"
mac2="66:77:88:99:aa:bb"

# Expected interface names
expected_interface1="ue0"
expected_interface2="ue1"

# Check if interface names match the expected interface names based on MAC addresses
interface1=$(ifconfig | awk -v mac=$mac1 '$0 ~ mac {print $1}')
interface2=$(ifconfig | awk -v mac=$mac2 '$0 ~ mac {print $1}')

# Update interface names if they don't match the expected interface names
if [ "$interface1" != "$expected_interface1" ]; then
  ifconfig $interface1 name $expected_interface1
  echo "Interface $interface1 renamed to $expected_interface1."
fi

if [ "$interface2" != "$expected_interface2" ]; then
  ifconfig $interface2 name $expected_interface2
  echo "Interface $interface2 renamed to $expected_interface2."
fi

What a brilliant solution! Thank you! I will implement this in the next few days and post a reply.