ether_gen_addr(9)

ether_gen_addr9

Generate an arbitrary mac address for use

Usage

#include <sys/types.h>

#include <sys/socket.h>

#include <net/if.h>

#include <net/if_var.h>

#include <net/ethernet.h>

void

ether_gen_addr(struct ifnet *ifp, struct ether_addr *hwaddr);

Overview

The ether_gen_addr() function generates an arbitrary MAC address for use by an ethernet interface that does not have an assigned address.

By default, ether_gen_addr attempts to generate a stable MAC address using the hostid of the jail that the ifp is being added to. During early boot, the hostid may not be set on machines that haven't yet populated /etc/hostid, or on machines that do not use loader(8).

ether_gen_addr can fail to derive a MAC address due to memory allocation failure, or because the hostid has not been populated. In these cases, a locally-administered unicast MAC address will be randomly generated and returned via the hwaddr parameter.

If ether_gen_addr succeeds, then it will return a MAC address in the FreeBSD Foundation OUI, “58:9c:fc”, via the hwaddr parameter.

Releases

16 releases since FreeBSD 12.3-RELEASE; the text changed 1 time.

  1. 12.3–13.2
  2. 13.3–16.0

Authors

This manual page was written by Kyle Evans ⟨[email protected]⟩.

From base 16.0-CURRENT-20261027-61c70dc16a79 in FreeBSD 16.0-CURRENT (2026-10-27). Parsed by carta from the page's mdoc source.