The interface MAC address can be set with the link.address option of an interface. If the option is not set, the interface's MAC address will be configured to a default value. For physical interfaces this is their permanent MAC address. For virtual interfaces ifstate derives a reproducible MAC address.
Reproducible MAC Addresses
The reproducible MAC addresses are based on the output of the SHAKE256 extendable-output function. The SHAKE256 input for an interface is build by concatenating the following values, depending on the configuration:
No implicit link.address setting will be enforced if:
- the interface does not support ethernet addressing (
ipip,sit,vti, …) or - the
mac_seedoption for the current netns is set tonull
Examples for a host with the machine-id of c5826ec0bb89fe5ca3af4e183d51e636:
- a VLAN subinterface
vl42in a netns with themac_seedset toha-service01will use the digest of the following string:SHAKE256("link\000\000ha-service01\000vl42")⇒ee:65:a3:17:74:99 - a VLAN subinterface
vl42in the root netns will use the digest of the following string:SHAKE256("link\000c5826ec0bb89fe5ca3af4e183d51e636\000\000vl42")⇒9e:12:25:18:4e:31 - a VLAN subinterface
vl42in the netnsfoowill use the digest of the following string:SHAKE256("link\000c5826ec0bb89fe5ca3af4e183d51e636\000foo\000vl42")⇒0a:13:9b:fc:bc:6d
Configurable MAC Address Defaults
For some interface kinds it is possible to change how IfState determines the default MAC address. This allows you to adopt IfState to your use cases and might help to get around with physical TCAM resource limits found in some switchdev hardware: