On Demand nic on containers

Hello
I have set up a container with 2 nic (namely eth0, eth1) bridged to 2 different interfaces.
nic eth0 is the main communication interface for the container.
nic eth1 is an on-demand interface, which should be disabled on boot up and enable using command ip link set eth1 up.

However, I couldn’t set the interface eth1 to be disabled on container boot up. Any ideas how can I configure it to achieve this goal?

Tried:
echo “iface eth1 inet manual” >> /etc/network/interfaces on the container and it’s not working.

which linux distro are you using? and which version?

Host OS: Fedora Workstation 30

ok how about conteiner? which distro and version?

Because /erc/network/interfaces will only work with debian as conteiner or ubuntu ( <=16/xenial). Ubuntu 18 uses netplan and if you like to use /etc/network/interfaces youĺl have to install ifupdown and remove /etc/netplan/01.xxx
Hope it helps 80)

My container uses Ubuntu 19.04
Removed netplan.io package and installed ifupdown

eth1 still not disabled on container startup

could you:

  1. copy /etc/network/interfaces
  2. copy systemctl status -l networking
  3. verify which network is running ( NetworkManager, netplan or networking) ?

It uses systemd-networkd to manage the interface to manage the network interfaces on the container.
ps. I have reconfigure my container back to its default image which does not come with NetworkManager.

I managed to solve it without installing additional packages. Yeah!
On my Ubuntu 19.04 container which uses netplan and network-d,

#!/bin/bash
# Deploy this file to /etc/networkd-dispatcher/routable.d/ and set executable i.e. chmod +x ${0}
case “$IFACE” in
eth1)
if [ ! -f /tmp/networkd.eth1.disabled.startup ]; then
dhclient -r eth1
ip link set eth1 down
touch /tmp/networkd.eth1.disabled.startup
fi
;;
*)
;;
esac

Save the file in /etc/networkd-dispatcher/routable.d/networkd.down.interface and chmod +x it. It should disable eth1 on every powerup, reboot.

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