Skip to content

MAC address display #2

Description

@dpreid

The displayed MAC address is different each time a portal device is power cycled. It looks like an appropriate MAC address however it is random and not correct (i.e. not the same fixed MAC address shown by ip addr for eth0).

The problem and solution are described here: https://runebook.dev/en/docs/python/library/uuid/uuid.getnode

It seems that the behaviour of uuid.getnode() is that it will return a random MAC address if it cannot access the true hardware one.

Instead the 'getmac' package (https://pypi.org/project/getmac/) can be used to return the correct hardware MAC address each time.

Solution:

  1. Update the install_portal.sh script to include installation of getmac
python -m pip install getmac

If a portal is already installed and this update is required, then run the install_portal.sh script.

  1. Update the portal-main.py script to use getmac:
    a. Add the appropriate import:
from getmac import get_mac_address as gma

b. Modify the get_mac() function:

def get_mac():
    return f'{gma()}'

Where gma() returns the MAC address in the desired string format without any reformatting required.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions