Host to Container connection with macvlan bridge

Greetings, has anybody been able to get the host to “talk” to a container when the container is using a macvlan bridge to obtain ip? I know this site shows how to do it the “old way” but has anyone been able to accomplish it with netplan (Ubuntu’s new and “improved” way of networking)? Thank you!

Hi!

It could be likely possible to do with networkd-dispatch scripts to implement those ifupdown pre-up commands.

I thought ifupdown was not able to be used if netplan is being used

netplan uses the NetworkManager renderer when in Ubuntu Desktop (i.e. let Network Manager create the interfaces) and the networkd renderer for the rest (server, cloud images like in LXD).

In the latter case, you can mix in the networkd-dispatcher package in order to run hooks.

Nice, I did not know that. Do you know of a good recourse where I could learn more about that (the latter)? I hate finding “solutions” without understanding why it is a solution.

Have a look at the netplan FAQ which talks about hooks,
https://netplan.io/faq#use-pre-up-post-up-etc-hook-scripts

Also, for an actual example on how these work, see https://fixingitpro.com/2018/12/28/displaying-ip-info-on-console-with-netplan/

1 Like

I am looking for this as well, trying to connect from the host to my containers without being forced to kill netplan and install ifupdown on the host.

Has anyone figured out how to create a macvlan bridge via netplan?

Edit: Well, here’s the nub-- you can’t! Gotta use ifupdown.

https://bugs.launchpad.net/netplan/+bug/1664847

Edit 2: OK, so the trick here is that netplan and ifupdown can coexist. So you just install ifupdown, edit /etc/network/interfaces to add the MACVLAN bridge, ifup the bridge, and boom everything works, you can ping from containers to host and vice-versa.

1 Like

Thank you, Mr Pribb! I will try it as soon as I get a chance! (btw, Dr Pepper may have the higher degree but I find you to be the superior drink)

1 Like

The netplan page suggests that when you install the ifupdown package, netplan is removed from the system.

On a running system, netplan can be removed by installing ifupdown and configuring /etc/network/interfaces manually as users have done before.

https://netplan.io/faq#use-pre-up-post-up-etc-hook-scripts

How were you able to get them to co-exist?

That confused me too, but they do coexist. It works fine.