Using any network interface whatsoever (solution?)
Darren Pilgrim
darren.pilgrim at bitfreak.org
Sun Apr 9 00:28:22 UTC 2006
Mike Meyer wrote:
> In <20060408224140.GA15366 at outcold.yadt.co.uk>, David Taylor <davidt at yadt.co.uk> typed:
>> That doesn't quite work, though. Unless you require everyone wanting
>> to distinguish between LAN and WAN interfaces uses different types
>> of hardware for each card, they'll still end up with xl0 and xl1
>> (or whatever), which is in no way better than eth0 and eth1,
>
> You're right - but at least you have the option of using different
> types of cards to get different names. I agree that this sucks, but
> it's better than nothing.
This is a script to rename interfaces based on the MAC address:
#!/bin/csh
set mac_list = "/etc/MACaddr_list"
foreach ifn ( `ifconfig -l link` )
set ifn_mac = "`ifconfig $ifn link | grep ether | cut -d ' ' -f 2`"
set ifn_name = "`grep $ifn_mac $mac_list | cut -d ' ' -f 2`"
ifconfig $ifn name $ifn_name
end
Where /etc/MACaddr_list contains entries of the format:
00:00:00:00:00:00 NameLengthMax15
If you add something to /etc/rc.d so that a sh-ified version of this script
runs after all interfaces have attached but before any numbering or cloning
takes place you can have lines like this in /etc/rc.conf:
ifconfig_PublicLAN="inet a.b.c.d/24"
That's far better than trying to remember what's on em0.
This is an off-the-top-of-my-head, 2-minute solution, largely untested due
to present lack of a victim machine. pf doesn't seem to have any issue, but
I haven't tested /etc/rc.d/netif, dhclient, wpa_supplicant, interface
cloning and other things people do to their network interfaces. An
rc-friendly version would probably make use of something like:
ifconfig_UsefulName_linkaddr="00:00:00:00:00:00"
in /etc/rc.conf rather than a seperate file, but this is just a proof of
concept.
Comments please!
More information about the freebsd-hackers
mailing list