[gull] récupérer l'adresse MAC sous Linux
Marc SCHAEFER
schaefer at alphanet.ch
Mon Oct 23 10:30:31 CEST 2006
On Mon, Oct 23, 2006 at 09:32:44AM +0200, Jean-Eric Cuendet (ML) wrote:
> Comment faire pour récupérer l'adresse MAC sous Linux?
> Y-a-t-il un outil? ifconfig? Ou une entrée dans /proc?
> Ce serait pour le kernel 2.6
Dans un cas j'ai eu une carte Ethernet dont l'EPROM/NVRAM/autre avait été
effacée.
J'utilise cette routine dans FAI, après avoir configuré la MAC address à
la main; pour maintenir dans GNU/Linux l'adresse à chaque boot.
if [ -f /tmp/macaddress_hack ]; then
IFCONFIG=/sbin/ifconfig
MACADDRESS=`$IFCONFIG | grep HWaddr | awk '{print $NF;}'`
awk < $target/etc/network/interfaces \
> $target/etc/network/interfaces.NEW \
-v HWADDR=$MACADDRESS \
'{ print; }
/^iface eth0 / { printf "hwaddress ether %s\n", HWADDR; }' \
&& mv -f $target/etc/network/interfaces.NEW \
$target/etc/network/interfaces
fi
--
Je lis les messages bien formatés. N'abusez pas du Cc:. Texte == efficace.
Citer n'est pas concaténer. Editez vos messages, ça gagne du temps.
Marc se met au blog `-o ro': http://www.alphanet.ch/schaefer_chronique.html
More information about the gull
mailing list