Skip to content

6 Set unique MAC for ethernet

Matteo Fumagalli edited this page Apr 11, 2018 · 1 revision

NOTE: This issue was fixed in v0.4 image version, so if you use the last image the MAC is already unique and derived from CPU serial number

By default MAC address is randomly generated during boot.

Artik generate a random fixed address during boot and stores is in a MMC section called factory-info.

We need to read from factory-info the fixed mac address and set it to the ethernet interface, if this mac does not exist we can create a new one at the first boot.

wget /~https://github.com/rushup/artik710-factory-info/releases/download/v1/factory-info -O /usr/bin/factory_info

You can also use the above tool to set custom purchased mac address.

More information HERE

Create script for changing MAC address

vi /usr/bin/macchanger

Copy the following:

#!/bin/sh

/usr/bin/factory_info gen_ethaddr_once

ifconfig eth0 hw ether $(/usr/bin/factory_info read ethaddr)

HWaddr=`ifconfig -a | grep eth0 | grep HWaddr | sed 's/.*HWaddr //'`
echo "ETH0_HWaddr: $HWaddr"

exit 0


Set permissions

chmod +x /usr/bin/macchanger

Create systemd service

vi /etc/systemd/system/macfix.service

Copy the following:

[Unit]
Description=macchanger on eth0
Wants=network-pre.target
Before=network-pre.target
BindsTo=sys-subsystem-net-devices-eth0.device
After=sys-subsystem-net-devices-eth0.device

[Service]
ExecStart=/usr/bin/macchanger
Type=oneshot

[Install]
WantedBy=multi-user.target

Enable service

systemctl enable macfix.service

More

You can also get the serial number with the following command:

Kitra710C:

cat /sys/firmware/devicetree/base/serial-number

Kitra530:

cat /proc/cpuinfo