Multiple macvlan nic's for container?

I created 2 profiles and attached to container, unfortunately secondary
IP for eth1 can’t be reached from internet
what am i doing wrong?

lxc profile show macvlan
config: {}
description: ""
    nictype: macvlan
    parent: enp0s31f6
    type: nic
name: macvlan
- /1.0/containers/mail7

lxc profile show macvlan2
config: {}
description: ""
    nictype: macvlan
    parent: enp0s31f6
    type: nic
name: macvlan2
- /1.0/containers/mail7

container /etc/netplan/10-lxc.yaml

  version: 2
    eth0: {dhcp4: true}
    eth1: {dhcp4: true}

Unless I am misreading your config, you have two NICs attached to your container but BOTH are connected to the same physical interface (nic parent: enp0s31f6). Why? Are you expecting a different IP on the secondary NIC?

well yes and yes - I cant assign more than one macvlan virtual nic to container?
2 IPs are assigned properly from DHCP but only one is visible from internet (random)

Yes, you can assign multiple NICs to a container, but normally they are for separate networks. In your case, you have two NICs connected to the same network getting DHCP addresses for the same network. I am curious how you expect this to work? Normally, you can have a single NIC with multiple IPs, but I have not seen an instance where multiple NICs have same IP Address networks.

How would this work on a non-LXD server?

well I need multiple virtual interfaces with one NIC with multiple MAC address
but i dont know how to do it in lxd/netplane config

there is no special magick for that, I have already seen a (not very clean) network where many PC had a classic network card and a wifi card enabled, both configured with DHCP, and these 2 cards had of course different addresses on the same network.
Now these PC where only clients, obviously, and they accessed the network normally through their default route. From what happened it seems clear that the OS of these computers was always picking the faster link, that is, the Ethernet card. But when people disconnected the Ethernet they could access the network just as well through the Wifi, so the software was redirecting the default route dynamically.

When you have a server, it’s a different thing to have 2 interfaces on the same network.
It can happen but in this case you may have to struggle with some not very standard routing.

When a packet comes in on the default route card, no problem. In the other case, when no special routing is done the reply packet will come out on the default route card. I tried the setup and netplan (i think that the culprit is netplan) is creating 2 default routes :-(. Ugh. Ping works for me., but I did not try a TCP connection, it may very well be a blocker in this case (since ping is connection-less possibly the route problem is probably irrelevant)
So I’m 99% sure it’s not a LXD specific problem.

so short story is
macvlan container cant have multiple IP adressess?

well, it’s possible, I checked myself, it works, the 2 interfaces get 2 IP addresses.
However to actually use these 2 addresses may be not so obvious to configure. Again it’s not a LXD problem, it would be the same on a standard PC with 2 PCI network cards connected to the same switch. It’s a setup used by routers with several Internet connections, for redundancy, so it can work, you can probably find tutorials be searching a bit on the Internet.
But I have never been myself beyond knowing that it exists. The real life use of this feature is network redondancy and I never had the use case.

I Agree
Is there a way to assign 2 MACs to 1 virtual container interface?
Something like eth0:0, eth0:1 which provides on real ethernet NICs to setup virtual interfaces

Err, with 2 macvlan each one has its own MAC address.
With classical IP address creation like eth0:0, eth0:1, eth0:2, … all these IP addresses use the unique MAC address of the physical card.
There is ongoing work for adding ipvlan capability to lxd, it’s nearer to the eth0:0 trick, but it’s not here yet.
Ipvlan would not change much to the problem anyway.

thx I see your point
well then I am in shithole :frowning:
I cant figure out howto configure bridge lxd netplan for multiple NICs - so then I must somehow return to networks interfaces for Ubuntu 18.04

maybe there is a simpler way to achieve your goal. Don’t think in a box they say (easier said than done of course)

Yep, I understand all that. In this case, most end-user stations have some sort of dynamic routing update (weighted metric of some sort) to identify the primary NIC to hold the default gateway. In my own use cases, I normally have a single nic with multiple virtual IPS (VIPs, etc). I don’t use two different NICs to host IPs in the same subnet.

My question to the OP was how his current server is setup to handle this dynamic GW issue (outside LXD). Depending on how his network is setup, he can use weighted metrics for both NICs but might run into issues if he is using NAT.

Here is a good tutorial on using multiple default routes: