How to change duplicate MAC Address

  • I have two S905 boxes: a Nexbox A95 and a MXQ-Pro. Both are working fine with kszaq Version 7.0.2.008 (generic 1G 100M device tree). Today I used the Kodi Backup tool and copied my settings (addons, addon data, database, playlist, thumbnails, config data) from the A95 to MXQ box. It worked, but is did too much: it copied also the hostname (no problem, easy to change) and the MAC address (big problem, because I’ve no idea how to change) so I've now two boxes with the same MAC.

    Can anybody help and tell me how I can change the MAC address in librelelec? I’ve already tried some commands on ssh level, but they all change the MAC only until the next reboot.


  • I have two S905 boxes: a Nexbox A95 and a MXQ-Pro. Both are working fine with kszaq Version 7.0.2.008 (generic 1G 100M device tree). Today I used the Kodi Backup tool and copied my settings (addons, addon data, database, playlist, thumbnails, config data) from the A95 to MXQ box. It worked, but is did too much: it copied also the hostname (no problem, easy to change) and the MAC address (big problem, because I’ve no idea how to change) so I've now two boxes with the same MAC.

    Can anybody help and tell me how I can change the MAC address in librelelec? I’ve already tried some commands on ssh level, but they all change the MAC only until the next reboot.

    Try this.
    Go to storage/.config directory
    If you have a file named autostart.sh edit it. If not, create it.
    Insert in autostart.sh the next line:
    ifconfig eth0 hw ether <NEW MAC ADDRESS HERE>
    example: ifconfig eth0 hw ether 00:A3:FF:02:0E:05
    Save and restart.
    I hope this solve your problem.

  • Thank you, this was a good hint. :)

    I had to expand it a little bit, because libreelec has already started the eth0 in the moment, when the autostart.sh is executed. In tihs case I had to shutdown the eth0 firstly.

    A 2nd probelm was that kodi doen't realise the notwork connection an statup with the changed MAC and so it didn't show the video library (I use an external mysql). The sleep command was the solution for this. Kodi starts with old MAC (shows my library) and after 30s the MAC changes automatically. The '&' in the script is important; it makes running it in the backround and Kodi can start.

    Here is the working autostart.sh :

    (
    sleep 30;
    ifconfig eth0 down;
    ifconfig eth0 hw ether C4:2F:AD:10:78:33;
    ifconfig eth0 up
    ) &

    Edited once, last by ippon (October 27, 2016 at 12:44 PM).

  • One of my two boxes was a bit unstable and I found, that it was because of this MAC solution. Meanwhile, I found a sulution that work much better:

    1) Login to the shell

    2) cd /storage/.config/system.d

    3) create a new file. The filename is : [email protected]

    [Unit]
    Description=MAC Address Change %I
    Wants=network-pre.target
    Before=network-pre.target
    BindsTo=sys-subsystem-net-devices-%i.device
    After=sys-subsystem-net-devices-%i.device

    [Service]
    Type=oneshot
    ExecStart=/sbin/ip link set dev %i address C4:2F:AD:10:78:33
    ExecStart=/sbin/ip link set dev %i up

    [Install]
    WantedBy=multi-user.target

    4) type the following command on the shell : systemctl enable [email protected]
    You should see the following Message:
    Created symlink from /storage/.config/system.d/multi-user.target.wants/[email protected] to /storage/.config/system.d/[email protected].

    5) remove any other MAC-Spoofing script (e.g. /storage/.config/autostart.sh). It is not longer needed.

    Form now on, the box comes up with the new MAC address.


    P.S.: The script should also work with the wireless LAN. The only change you need is in step 4: systemctl enable [email protected]

  • Another option. Create file '99-mac-address.rules' in 'udev.rules.d' subfolder under 'configfiles' folder. Use the following format within rules file. Label your mac's as you like.

    SUBSYSTEM=="net", KERNEL=="wlan0", RUN+="/sbin/ip link set dev %k address D8:FC:93:6F:29:01"
    SUBSYSTEM=="net", KERNEL=="eth0", RUN+="/sbin/ip link set dev %k address D8:FC:93:6F:29:02"


  • Another option. Create file '99-mac-address.rules' in 'udev.rules.d' subfolder under 'configfiles' folder. Use the following format within rules file. Label your mac's as you like.

    SUBSYSTEM=="net", KERNEL=="wlan0", RUN+="/sbin/ip link set dev %k address D8:FC:93:6F:29:01"
    SUBSYSTEM=="net", KERNEL=="eth0", RUN+="/sbin/ip link set dev %k address D8:FC:93:6F:29:02"

    Does the file need to be called '99-Mac-address.rules' with the speech marks or does it just get called 99-Mac-address.rules?

    Cheers

  • This is works to you when the devices work together on same network ?

    In simple terms if you have two devices on the same network with the same MAC then they will both be unreliable or may not even work at all.

    The fixes above are various ways to change the MAC address of a box so to remove this clash. It should only be done as a last resort and after you are sure this is really the issue.

  • DEPRECATED Current versions of LE will identify this problem and set a MAC based on the serial of the device. If you have already applied this fix you do not need to do any further changes as this will be automatically catered for as well.

    Posting here for later migration to the wiki.

    Tested with a Khadas VIM s905x on LE 8.1.3 but will likely be relevant to many other platforms.

    All? VIM (1) running "Vim_Marshmallow_Root_170303.7z" share a common MAC address 00:15:18:01:81:31.

    This causes serious network issues if you operate more than one VIM on the same LAN.

    Khadas if you read this then this needs fixed.

    None of the methods listed in this thread work however there is an easier way.

    This is intentionally written long hand as it is important no mistakes are made and given how low level it is mistakes are entirely possible. A mistake with a MAC address will break all network connectivity and all the headaches that come with it.

    Procedure:

    SSH to the box

    Confirm current MAC

    # ip link

    1: lo: mtu 4096 qdisc noqueue

    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

    2: eth0:
    mtu 1500 qdisc fq_codel qlen 1000

    link/ether 00:15:18:01:81:31 brd ff:ff:ff:ff:ff:ff

    3: wlan0:
    mtu 1500 qdisc noop qlen 1000

    link/ether cc:b8:a8:19:96:86 brd ff:ff:ff:ff:ff:ff

    Confirm the origin of this MAC address is

    fw_printenv | grep ethaddr

    ethaddr=00:15:18:01:81:31


    Stop here if this does not match.

    Generate and take a note of a new random MAC address

    # dbus-uuidgen | cut -c1-12 | sed -e 's/../:&/2g' -e 's/^://' | tr [:lower:] [:upper:]

    18:C0:1B:66:29:93

    Update the system to use this MAC

    #fw_setenv ethaddr 18:C0:1B:66:29:93

    Confirm it took:

    fw_printenv | grep ethaddr

    ethaddr=18:C0:1B:66:29:93

    Reboot. Any static DHCP leases will change since the MAC has changed.

    This procedure will survive auto updates.

  • @Xe Sorry for bumping an older post, but I'm in need of your help.

    When I run the command above, it shows that there is bad CRC:

    fw_printenv | grep ethaddr

    Warning: Bad CRC, using default environment

    Both of my boxes running LibreELEC-S8X2.arm-8.2.2-S82 (by Demetris) seem to be impacted. Is this easy to fix?

    Thanks!

  • I am not sure but this may not work for that hardware

    Can you try

    fw_printenv | paste

    and see if it returns the same error

    Thanks - it returns a similar error, but seems to have tripped the pastebin function:

    # fw_printenv | paste

    Warning: Bad CRC, using default environment

    SXfH

    PS - here is a dmesg paste: eEGd - I've noted the fw_printenv paste indicates an armv8 CPU, but my S802 is armv7, which agrees with the dmesg. Is there a way to correct the u-boot environment somehow? (I'm assuming that is what is incorrect)

    Edited once, last by ShermanTenor: Added dmesg - and identified cpu type mismatch (November 29, 2017 at 6:31 PM).

  • Have a look at the command fw_setenv

    Thanks, Tim_Taylor. The advice above said not to use fw_setenv if the fw_printenv didn't show a valid result, I've got a CRC error, and I think it may point to a larger issue.

    Also - the permissions on the file /etc/fw_env.config are set to 0664. I get an error when I try to modify the file with nano, and chmod says:

    chmod: /etc/fw_env.config: Read-only file system


    My Libreelec is on a SD card (not NAND) if that is material?