OPNsense Forum

English Forums => General Discussion => Topic started by: skydiablo on June 18, 2020, 09:15:01 AM

Title: Dynamic Interface handling
Post by: skydiablo on June 18, 2020, 09:15:01 AM
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 (https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=195692#c2) i created scripts and wanted to rename the interfaces with devd (https://www.freebsd.org/cgi/man.cgi?query=devd.conf) 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