Score:0

How to set the main network interface to mode macvlan on ubuntu server?

in flag

how does one put the main ethernet interface on Ubuntu server into macvlan mode automatically (i.e. for every boot and not just on the command line)?

Background and reason:

If someone wants virtual containers such as LXD or docker to appear on the network like physical machines, there is two options:

a) create a virtual bridge device and put all virtual machines and the host itself into that bridge. Works, but is said to be slow and have unnecessary overhead for keeping the bridge alive, such as timeouts, dynamic mac tables and so on.

b) use macvlan interfaces, which work like a bridge, but much faster and simpler, since the do not need all that overhead of maintaining a network bridge. Works, except for a particular problem:

The problem is, that the host itself cannot communicate with the guest, although LXD and docker put the macvlan devices into "bridge" mode, which is explicetely designed to allow communication between all virtual interfaces on the same physical interface.

Unfortunetaly, there is no good documentation on macvlan, even docs.kernel.org covers only ipvlan.

However, I found hints that the commication between host and guest in a macvlan type network with mode bridge only works if the host's interface is in macvlan mode as well.

Unfortunately, Ubuntu Server heavily relies on netplan, which does not seem to support macvlan.

I therefore have two questions:

1.) Can the physical device (like eth0 or enp4s0) itself be put into macvlan mode, or is this possible only for virtual devices?

2.) In either case: What is the recommended and Ubuntu-compliant way to configure Ubuntu server such that the host gets an (either physical or virtual) macvlan network device to be able to communicate with its guests in macvlan mode?

And yes, I've seen the former question MACVLAN Bridge in netplan and bug https://bugs.launchpad.net/netplan/+bug/1664847 but this is from 2019 and applies to 18.04, so probably not valid anymore since it recommends to use ifup/ifdown. On the other hand, there is some rough workaround using networkd-dispatcher and scripting.

But is there a clean way?

regards

user535733 avatar
cn flag
"*[Bridge] is said to be slow and have unnecessary overhead for keeping the bridge alive*..." You have been misled: Bridges are fast, simple, reliable, and easy to administer...and easy to setup in netplan
user535733 avatar
cn flag
The bug report you linked to clearly shows that macvlan is still not implemented in netplan, so the 2019 answer is still accurate.
karel avatar
sa flag
Does this answer your question? [MACVLAN Bridge in netplan](https://askubuntu.com/questions/1121165/macvlan-bridge-in-netplan)
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.