From owner-freebsd-net@FreeBSD.ORG Fri Dec 5 19:39:02 2014 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 07498FC1 for ; Fri, 5 Dec 2014 19:39:02 +0000 (UTC) Received: from mailout-warwickshire.gigahost.dk (mailout-warwickshire.gigahost.dk [77.74.192.84]) by mx1.freebsd.org (Postfix) with ESMTP id C474BC57 for ; Fri, 5 Dec 2014 19:39:01 +0000 (UTC) Received: from mailout.gigahost.dk (mailout.gigahost.dk [89.186.169.112]) by mailout-warwickshire.gigahost.dk (Postfix) with ESMTP id 0DDEAF621BD; Fri, 5 Dec 2014 19:39:00 +0000 (UTC) Received: from smtp.gigahost.dk (smtp.gigahost.dk [89.186.169.107]) by mailout.gigahost.dk (Postfix) with ESMTP id D4E6625E102B; Fri, 5 Dec 2014 19:38:59 +0000 (UTC) Received: by smtp.gigahost.dk (Postfix, from userid 1000) id CA22446606D6; Fri, 5 Dec 2014 19:38:59 +0000 (UTC) X-Screener-Id: 2bfb0ba3b22e70c1e23704465ce0c16e022de43a Received: from easynote (80-71-133-54.u.parknet.dk [80.71.133.54]) by smtp.gigahost.dk (Postfix) with ESMTPSA id A89FE466063B; Fri, 5 Dec 2014 19:38:59 +0000 (UTC) Date: Fri, 5 Dec 2014 20:38:56 +0100 From: To: freebsd-net@freebsd.org Subject: Re: NICs devices switches "pshycial" place on each boot (SOLVED - FOR REAL) Message-ID: <20141205203856.10384916@easynote> X-Mailer: Claws Mail 3.11.1 (GTK+ 2.24.25; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Dec 2014 19:39:02 -0000 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