NICs devices switches "pshycial" place on each boot (SOLVED - FOR REAL)
knl at bitflop.com
knl at bitflop.com
Fri Dec 5 19:39:02 UTC 2014
This is what I got working correctly via the solution provided by
Warner Losh in Martins bug report about devd.
I had some problems getting PF to read its rule set due to it not having
all the cards ready before that. I solved that by simply having PF
flush and reload its rule set on each device renaming.
So..
# cat /usr/local/etc/mac-names-map.txt
00:24:9b:0d:e0:0c olan 192.168.1.1
00:24:9b:0e:23:8e clan 192.168.2.1
00:24:9b:0f:9d:3f plan 192.168.3.1
Remember to make fix-mac-name executable.
# cat /usr/local/sbin/fix-mac-name
#!/bin/sh
# Script to fix a custom device name for the USB->NIC adapters.
# This script is being invoked by devd using an attach event that
# catches the device name (ueX).
dev=$1
mac=$(ifconfig $dev | grep ether | awk '{print $2;}')
name=$(grep ^$mac /usr/local/etc/mac-names-map.txt | awk '{print $2;}')
IP=$(grep ^$mac /usr/local/etc/mac-names-map.txt | awk '{print $3;}')
if [ -n $name ]; then
ifconfig $dev name $name
ifconfig $name inet $IP netmask 255.255.255.0
# Make sure PF is started correctly again.
pfctl -F all -f /etc/pf.conf
fi
# cat /usr/local/etc/devd/devd.conf
notify 100 {
match "system" "IFNET";
match "type" "ATTACH";
action "/usr/local/sbin/fix-mac-name $subsystem";
};
That's it.
Cheers, Kim
More information about the freebsd-net
mailing list