Dynamic Interface handling

Started by skydiablo, June 18, 2020, 09:15:01 AM

Previous topic - Next topic
moin,
i'm running an opnsense in a VM. every now and then i want to add new interfaces. the new interface is recognized after the reboot of the VM, but unfortunately it messes up the device names (vtnet1,vtnet2,vtnet3,...) given by the network driver, or puts them in a new order. this of course shatters all configs and makes the opnsense unusable.
on the basis of this statement i created scripts and wanted to rename the interfaces with devd according to the MAC. unfortunately nothing happens after a reboot, so my fix is not executed. what am i doing wrong?

/etc/fix-if-name.sh

#!/bin/sh
dev=$1
mac=$(ifconfig $dev | grep ether | awk '{print $2;}')
name=$(grep ^$mac /etc/ifmap | awk '{print $2;}')
if [ -n $name ]; then
    logger Rename interface $dev to $name
    ifconfig $dev name $name
fi


/etc/ifmap

fa:16:3e:04:XX:XX MGMT
fa:16:3e:f2:XX:XX EXT50
fa:16:3e:6f:XX:XX DEPLOY


/etc/devd/fix-if-name.conf

# notify 0 {
attach 0 {
        match "system"          "IFNET";
        match "type"            "ATTACH";
        media-type              "ethernet";
        action "/etc/fix-if-name.sh $device-name";
};


greez & thx,
volker