Good Morning, I am trying to find a way to have both MacVlan and the default bridge ip on one container so that it could be accessed from other hosts on the network but also be able to talk to private facing containers. Could anyone shine some light and let me know how to accomplish this.
You can create a LXD profile with two entries about networking (macvlan, and bridged), then create a container using that profile.
Here is how to do that:
When you get a shell in mycontainer, you will notice that eth1 did not get an IP address automatically. It’s up to you to make the configuration to get the IP address automatically. The manual way, anyway, is sudo dhclient eth1.
PERFECT!!! i have been using that same config over and over thinking i was doing something wrong as it was not getting an ip but looks like i was just missing that last command within the container. (sudo dhclient eth1)
The default container image for Ubuntu has instructions to automatically ask for an IP address for the eth0 network interface only.
You can see this configuration (for a Ubuntu 18.04 container) in the following netplan configuration file at /etc/netplan/50-cloud-init.yaml. Here are the contents:
ubuntu@macbridge:~$ cat /etc/netplan/50-cloud-init.yaml
# This file is generated from information provided by
# the datasource. Changes to it will not persist across an instance.
# To disable cloud-init's network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
version: 2
ethernets:
eth0:
dhcp4: true
ubuntu@macbridge:~$
You can manually add in there an entry for eth1 as well and then restart the container. Both network interfaces should get automatically an IP address.