epair and MAC addresses

Hello

If I create a epair device on FreeBSD, it's possible to set my custom MAC address? And could I do that with the /etc/rc.conf?

best regards
Darko Hojnik
 
You can try setting the MAC address using the ifconfig(8) 'link' directive. If an epair device gets a random MAC address at boot-time no matter what you put in the ifconfig line in /etc/rc.conf (as happens with bridges), you may try an extra ifconfig line with 'alias0' appended, and put the separate link statement in there.
 
Hijacking this old thread for visibility because I just had a connectivity problem with custom MAC addresses on an epair used in a bridge for a jail and I couldn't find obvious documentation about my findings neither in epair(4) nor in ifconfig(8).

As we all know ifconfig epair0 create creates epair0a and epair0b with a locally administered MAC address (a MAC address where the second-least-significant bit of the MAC address is set to 1). This means that the first octet of the MAC address could start with 02 (binary representation: 0000 0010).

epair(4) creates MAC addresses for epair0a and epair0b that end in :0a and :0b, respectively. This seems to have relevance for epair(4)'s internal mechanism that maps the a-side of the epair to its b-side.

I restart my jails and create epairs and bridges dynamically (sort of) in my testing environment. So I was a little annoyed that external functionality that depends on a consistent MAC address didn't work anymore as each time an epair was (re-)created I got a new epair MAC address.

So what I did in my jail.conf was:
Code:
exec.created += "ifconfig epair0a ether 02:de:ad:be:ef:0a";
exec.created += "ifconfig epair0b ether 02:de:ad:be:ef:0b";

Now epair0b's new custom MAC address happily presents itself to external devices that depend on consistent MAC addresses while epair(4) is able to map epair0a to epair0b, not breaking the connectivity between the a-side and the b-side.

Note that ifconfig epair0[a|b] still shows a different hwaddr but the external network (check using arp) sees the custom MAC address as intended.

Also note from ifconfig(8):
Code:
ether   Synonymous with link (with some exceptions, see -l).
[...]
link    Default, if inet is not available.
lladdr  Synonymous with link.
 
Back
Top