Hello,

Thanks for your swift reply and really helpful information!

Dennis Filder writes:
> X-Debbugs-CC: Roman Fiedler <roman.fied...@unparalleled.eu>, Michael Tokarev 
> <m...@tls.msk.ru>
>
> As stated in the documentation, bridge-utils recently added support
> for the "bridge_hw" directive which allows you define a MAC address
> for a bridge interface.  Changing your stanza to just this should
> already work:
>
>     iface virtbr0 inet static
>       address 192.168.1.1
>       netmask 255.255.255.0
>       bridge_hw 86:aa:aa:aa:aa:aa

Weird, using the configuration from above will result in:

$ ifup virtbr0
Cannot find device "virtbr0"
ifup: failed to bring up virtbr0

Modifying above stanza to this ...

iface virtbr0 inet static
  address 192.168.1.1
  netmask 255.255.255.0
  pre-up brctl addbr virtbr0
  post-down brctl delbr virtbr0
  bridge_hw 86:aa:aa:aa:aa:aa

... will make "ifup virtbr0" succeed, but the MAC is not set
to the expected value:

$ ifup virtbr0
$ ip link show virtbr0
9: virtbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state 
DOWN mode DEFAULT group default qlen 1000
    link/ether 42:dc:6a:57:58:bd brd ff:ff:ff:ff:ff:ff

> If you also use systemd, then systemd-udevd may cause trouble because
> in its default configuration it will assign a randomly generated MAC
> address to the bridge device which might cause a race.

I don't know if relevant to this case but the MAC assigned
(42:dc:6a:57:58:bd) is not random, it is the same one every time
the bridge is created.

> I haven't tried this, but putting this udev rule into
> /etc/udev/rules.d/95-bridge.rules should prevent systemd-udevd from
> touching any bridge interfaces at all:
>
>    ACTION=="add", SUBSYSTEM=="net", DEVTYPE=="bridge", ENV{TAGS}-="systemd"

As "systemd-udevd" is active ...

# ps aux | grep udev
root         207  0.0  0.9  21892  4808 ?        Ss   08:33   0:00 
/lib/systemd/systemd-udevd

... I just stopped it completely using ...

$ systemctl stop systemd-udevd-kernel.socket
$ systemctl stop systemd-udevd-control.socket
$ systemctl stop systemd-udevd.service       

... to avoid any interference. With

iface virtbr0 inet static
  address 192.168.1.1
  netmask 255.255.255.0
  pre-up brctl addbr virtbr0
  post-down brctl delbr virtbr0
  bridge_hw 86:aa:aa:aa:aa:aa

this will still not work even with udev disabled:

$ ifup virtbr0; ip link show virtbr0
13: virtbr0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state 
UNKNOWN mode DEFAULT group default qlen 1000
    link/ether 8a:ad:e6:c7:ab:76 brd ff:ff:ff:ff:ff:ff

But without "systemd-udevd" my initial configuration will work
also in the virtual machine:

iface virtbr0 inet static
  address 192.168.1.1
  netmask 255.255.255.0
  pre-up brctl addbr virtbr0
  pre-up ip link set virtbr0 address 86:aa:aa:aa:aa:aa
  pre-up ip link set virtbr0 up
  post-down ip link set virtbr0 down
  post-down brctl delbr virtbr0

$ ifup virtbr0; ip link show virtbr0
12: virtbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state 
DOWN mode DEFAULT group default qlen 1000
    link/ether 86:aa:aa:aa:aa:aa brd ff:ff:ff:ff:ff:ff

> Alternatively placing the file 80-bridge-utils.link from #991416
> (message #17)[0] into /lib/systemd/network/ should work as well.

I also reactivated "systemd-udevd":

$ systemctl start systemd-udevd-kernel.socket
$ systemctl start systemd-udevd-control.socket
$ systemctl start systemd-udevd.service

And then tried to use the link, but I am not sure, if it is active
without rebooting as "reload" does not seem to be the right command
for it.

# systemctl reload /lib/systemd/network/80-bridgeutils.link
Failed to reload lib-systemd-network-80\x2dbridgeutils.link.mount: Unit 
lib-systemd-network-80\x2dbridgeutils.link.mount not found.

Without rebooting (which at the moment would be annoying for
the test machine), the "hw_address" does still not work:

iface virtbr0 inet static
  address 192.168.1.1
  netmask 255.255.255.0
  pre-up brctl addbr virtbr0
  post-down brctl delbr virtbr0
  bridge_hw 86:aa:aa:aa:aa:aa

but now the MAC seems truely random each time the bridge is created:

$ ifup virtbr0; ip link show virtbr0
17: virtbr0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state 
UNKNOWN mode DEFAULT group default qlen 1000
    link/ether 3e:6b:bc:8a:b0:68 brd ff:ff:ff:ff:ff:ff
...
    link/ether 82:da:00:1c:98:ab brd ff:ff:ff:ff:ff:ff
...

Instead the config

iface virtbr0 inet static
  address 192.168.1.1
  netmask 255.255.255.0
  pre-up brctl addbr virtbr0
  pre-up ip link set virtbr0 address 86:aa:aa:aa:aa:aa
  pre-up ip link set virtbr0 up
  post-down ip link set virtbr0 down
  post-down brctl delbr virtbr0

now works without any specific udev rules and systemd services running
normally.

Reply via email to