Eth0 MAC address


#1

Hiya,

I’ve just found out that the legato module I have DOES NOT have a fixed MAC address associated with it. Every time it boots, another (apparently random) MAC address is generated - which requests another Ethernet Address from my DHCP server.

So each time I turn power cycle (or soft reset) the Hardware, I have to first log in with the serial console to discover the IP address before I can connect via SSH.

This is a pain … and possibly going to confuse people.

The Microchip/SMSC LAN9730 can talk to a eeprom containing the default MAC address - if this is not found it appears that the driver has to generate a valid MAC. It looks like the PCB hasn’t included this eeprom, so the Yocto driver is just inventing a ‘random’ MAC each time it starts.

A heads up for others using this.

ciao, Dave


#2

Hiya,

Here’s how to fix a MAC address in the Legato (until you flash the device with a new OS image).

[ol][li]Boot the Legato and login[/li]
[li]get the current ‘random’ MAC address for eth0 using ifconfig:

[code]root@swi-mdm9x15:~# ifconfig
eth0 Link encap:Ethernet HWaddr 26:16:4F:87:BA:6E
inet addr:192.168.42.164 Bcast:192.168.42.255 Mask:255.255.255.0
inet6 addr: fe80::2416:4fff:fe87:ba6e/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1150 errors:0 dropped:0 overruns:0 frame:0
TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:83824 (81.8 KiB) TX bytes:1188 (1.1 KiB)

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

usb0 Link encap:Ethernet HWaddr A6:1B:60:45:C5:0B
inet addr:192.168.1.2 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
[/code][/li]
[li]copy down the HWaddr value for eth0 (in this case it is 26:16:4F:87:BA:6E)[/li]
[li]change directory to /etc/network[/li]
[li]edit the file interfaces using vi[/li]
[li]scroll down to the entry for iface eth0 and add the line hwaddress ether 26:16:4F:87:BA:6E where the MAC address on the line is that noted in step 3 above. Note that the line starts with a TAB character. The section of the file should look like the following:

# Wired or wireless interfaces auto eth0 iface eth0 inet dhcp hwaddress ether 26:16:4F:87:BA:6E iface eth1 inet dhcp[/li]
[li]Save the file and exit from vi[/li]
[li]Reboot the Legato and check both the IP and MAC address using ifconfig - they should be the same as that you’ve just entered. [/li][/ol]

Now my DHCP server is going to issue the same IP address each time…

ciao, Dave


#3

Please note that from DS 3.1 + Legato 14.07 (viewtopic.php?f=177&t=8104), device discovery is enabled.
When configuring a new connection (or editing an existing one), it is possible to browse the alive devices on the network, that are publishing their IP address using the TCF protocol.


#4

Hiya,

Sounds good.

But … as the MAC address changes each reboot, the Legato will request a new IP address from the local DHCP server each reboot. After 256 reboots (Ok, could take some time, but not out of the realms of possibility) there is still the risk of exhausting (or reserving) all IP addresses in the DHCP server depending on how long the IP lease time is set to on the DHCP server.

At least it is probably a good idea to fix the hardware ethernet address as I’ve described before so that the DHCP server is not exhausted.

ciao, Dave