Skip to content

Conversation

@Buhnug
Copy link

@Buhnug Buhnug commented Mar 1, 2025

Explanation

  1. check_mac_conflict Function:

    • Checks if the last three octets of the given MAC address match the last three octets of any existing NICs' MAC addresses.
    • Returns 0 if a conflict is found, and 1 if no conflict is found.
  2. macrand Function:

    • Generates a new MAC address with the first three octets from the oui_file and the last three octets randomly.
    • Uses a while true loop to keep generating new MAC addresses until check_mac_conflict returns 1 (indicating no conflict).
    • Once a non-conflicting MAC address is found, it is applied to the network interface.
  3. phmacrand Function:

    • Similar to the macrand function but for phone interfaces, it generates a new MAC address with the first three octets from the phoui_file and the last three octets randomly.
    • Uses a while true loop to keep generating new MAC addresses until check_mac_conflict returns 1 (indicating no conflict).
    • Once a non-conflicting MAC address is found, it is applied to the network interface.

This ensures that the script keeps generating MAC addresses until it finds one that does not conflict with the last three octets of any existing NICs, effectively "blacklisting" existing NICs' MAC address segments to prevent duplication.

This is key when generating random MAC Adresses as to not leak the real NIC of the permaddress as this what other projects do. NetworkManager does not currently do this but wipri doesn't rely on NetworkManager.

Buhnug added 2 commits March 1, 2025 00:10
Check NIC/Blacklist NIC
@Buhnug Buhnug marked this pull request as draft March 1, 2025 00:34
@Buhnug
Copy link
Author

Buhnug commented Mar 1, 2025

Please review and test the PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant