-
Notifications
You must be signed in to change notification settings - Fork 2
6 Set unique MAC for ethernet
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
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
chmod +x /usr/bin/macchanger
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
systemctl enable macfix.service
You can also get the serial number with the following command:
Kitra710C:
cat /sys/firmware/devicetree/base/serial-number
Kitra530:
cat /proc/cpuinfo