Koozali.org: home of the SME Server

Legacy Forums => Experienced User Forum => Topic started by: nigeltodd on July 11, 2004, 11:38:28 AM

Title: Ethernet HWAddress
Post by: nigeltodd on July 11, 2004, 11:38:28 AM
Is there a way to return the ethernet hardware(MAC) address for an interface in such a form that it can be sued in the review configuration portion of the console?
Title: Ethernet HWAddress
Post by: genzil on July 12, 2004, 12:37:07 PM
USE AT YOUR OWN RISK, MAKE BACKUPS

Run the following from the command line:
Code: [Select]
echo "HWaddr_eth0=ifconfig eth0 | grep HWaddr | cut -d" " -f11" >> /home/e-smith/configuration

Add the following lines into /sbin/e-smith/console at line number 3031:
Code: [Select]
   $settings .= sprintf BODY_FORMAT, "HWaddr eth0",
                $conf{'HWaddr_eth0'};


This will add a line that on my box does this:
Ethernet settings
 Ethernet driver 1             : 8139too
 Ethernet driver 2             : 8139too
 HWaddr eth0                   : 00:00:1C:D0:02:CD

To add for another network card just change all eth0 to eth1 in the above text.

What this does is to add a line to the configuration file the holds the MAC address, and then read back when you use the review panel.

Please be aware that this is a hack, the MAC address isn't updated, you'll need to do that yourself by deleting the line from the config file and rerunning the first command.
Title: Ethernet MAC Address
Post by: nigeltodd on July 12, 2004, 01:36:54 PM
Thank you - works like a charm! just need to now get it into the configuratino file permanently!
Title: Ethernet HWAddress
Post by: genzil on July 12, 2004, 02:32:22 PM
To get it there on startup you can insert the following into /etc/rc.sysinit (I suggest at the end):
Code: [Select]
/bin/cp -f /home/e-smith/configuration /home/e-smith/configuration.orig; /bin/grep -v "HWaddr" /home/e-smith/configuration.orig > /home/e-smith/configuration; /bin/echo "HWaddr_eth0=/sbin/ifconfig eth0 | /bin/grep HWaddr | /bin/cut -d" " -f11" >> /home/e-smith/configuration; /bin/echo "HWaddr_eth1=/sbin/ifconfig eth1 | /bin/grep HWaddr | /bin/cut -d" " -f11" >> /home/e-smith/configuration


You can put it all on one line or seperate onto several using the ; to mark the end of a line.

That will get rid of any previous MAC addresses stored in the config file and replace it with the new ones.  Please note that I have done this for both eth0 and eth1, you may not want to in which case remove all the text from the last ; (/bin/echo "HWaddr_eth1... ...e-smith/configuration)

The one thing I'm not sure about is if the config file is updated by another process which will wipe the MAC address stuff.  Someone else will have to answer this, if you do find the answer to this please let me know.
Title: Ethernet HWAddress
Post by: NickR on July 12, 2004, 04:59:22 PM
Quote from: "genzil"
The one thing I'm not sure about is if the config file is updated by another process which will wipe the MAC address stuff.  Someone else will have to answer this, if you do find the answer to this please let me know.


AIUI, any changes made to the mysql configuration database will re-write this file.
Title: Ethernet HWAddress
Post by: genzil on July 12, 2004, 05:27:48 PM
Quote from: "NickR"
AIUI, any changes made to the mysql configuration database will re-write this file.


Thanks, that could be a problem.