# [SOLVED]why doesn't bridging assign mac addresses correctly?

## razamatan

i have a pretty stock conf.d/net

```

# This blank configuration will automatically use DHCP for any net.*

# scripts in /etc/init.d.  To create a more complete configuration,

# please review /etc/conf.d/net.example and save your configuration

# in /etc/conf.d/net (this file :]!).

#config_eth0="10.1.0.99/24"

#config_eth0="dhcp"

#dhcpcd_eth0="-O ntp_servers"

bridge_br0="eth0 tap0 tap1"

brctl_br0="setfd 0 sethello 0 stp off"

rc_need_br0="net.tap0 net.tap1"

config_br0="10.1.0.99/24"

routes_br0="default via 10.1.0.1"

dns_domain_br0="example.com"

dns_servers_br0="10.1.0.1"

dns_search_br0="example.com"

config_tap0="null"

tuntap_tap0="tap"

tunctl_tap0="-u me"

mac_tap0="00:00:00:00:01:00"

config_tap1="null"

tuntap_tap1="tap"

tunctl_tap1="-u me"

mac_tap1="00:00:00:00:01:01"

config_eth0="null"

```

but i end up w/ this ifconfig

```

br0       Link encap:Ethernet  HWaddr 00:00:00:00:01:00  

          inet addr:10.1.0.99  Bcast:10.1.0.255  Mask:255.255.255.0

          inet6 addr: fe80::200:ff:fe00:100/64 Scope:Link

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:487584 errors:0 dropped:463 overruns:0 frame:0

          TX packets:442556 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:0 

          RX bytes:188960068 (180.2 MiB)  TX bytes:420948649 (401.4 MiB)

eth0      Link encap:Ethernet  HWaddr bc:5f:f4:3b:97:f3  

          inet6 addr: fe80::be5f:f4ff:fe3b:97f3/64 Scope:Link

          UP BROADCAST RUNNING PROMISC MULTICAST  MTU:1500  Metric:1

          RX packets:39990746 errors:0 dropped:0 overruns:0 frame:0

          TX packets:16723989 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000 

          RX bytes:56738232789 (52.8 GiB)  TX bytes:3455104579 (3.2 GiB)

lo        Link encap:Local Loopback  

          inet addr:127.0.0.1  Mask:255.0.0.0

          inet6 addr: ::1/128 Scope:Host

          UP LOOPBACK RUNNING  MTU:16436  Metric:1

          RX packets:4364375 errors:0 dropped:0 overruns:0 frame:0

          TX packets:4364375 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:0 

          RX bytes:1223399867 (1.1 GiB)  TX bytes:1223399867 (1.1 GiB)

tap0      Link encap:Ethernet  HWaddr 00:00:00:00:01:00  

          inet6 addr: fe80::200:ff:fe00:100/64 Scope:Link

          UP BROADCAST RUNNING PROMISC MULTICAST  MTU:1500  Metric:1

          RX packets:21603 errors:0 dropped:0 overruns:0 frame:0

          TX packets:12398 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:500 

          RX bytes:9463952 (9.0 MiB)  TX bytes:12534014 (11.9 MiB)

tap1      Link encap:Ethernet  HWaddr 96:3b:32:d0:e1:9d  

          inet6 addr: fe80::943b:32ff:fed0:e19d/64 Scope:Link

          UP BROADCAST RUNNING PROMISC MULTICAST  MTU:1500  Metric:1

          RX packets:297612 errors:0 dropped:0 overruns:0 frame:0

          TX packets:308407 errors:0 dropped:1 overruns:0 carrier:0

          collisions:0 txqueuelen:500 

          RX bytes:13713605 (13.0 MiB)  TX bytes:434156747 (414.0 MiB)

```

based on my net config, shouldn't my taps get 01:00 and 01:01 while my bridge stays w/ some random mac address?

the 2 extra taps work though....

----------

## Ant P.

The bridge inherits the MAC address of the first interface assigned to it. It's done that way so connections don't immediately get dropped, but if you really have a good reason for it to have a random MAC you could always assign a dummy interface with a random address first.

----------

## Mad Merlin

 *Ant P. wrote:*   

> The bridge inherits the MAC address of the first interface assigned to it. It's done that way so connections don't immediately get dropped, but if you really have a good reason for it to have a random MAC you could always assign a dummy interface with a random address first.

 

Actually the bridge takes on the lowest MAC address of the interfaces in it. As you can imagine, this means that the bridge MAC address can change over time (and if you have STP enabled, will cause network breaks to the host while the forward delay timer is ticking).

One approach is to use the randomly generated tap MAC addresses, but replace the high order octet pair with FE (and if you're pedantic, like me, make sure that you didn't just cause a MAC address collision), that way your bridge will always keep your physical interfaces' MAC address, unless you're unlucky enough to have a real interface with MAC address starting with FE (but I have yet to see one of these in the wild).

----------

## razamatan

hmm.. i just tried rebooting /w the mac_tapN stuff set, and it didn't work (things hung when sshd started up).  removing them fixed things, and it appears things get randomly assigned anyway.  ultimately, this was trying to get bridging to multiple vms to work, and it seems that the macaddr i set for the virts doesn't have to agree with the what's specified for the taps anyway.

solved.  thanks all.

----------

## razamatan

for posterity, the final setup for me to get a stable br0 mac address is to bind it to the physical nic's mac.

----------

