[systemd-devel] Satitic IP in container

Tom Gundersen teg at jklm.no
Sat Mar 1 05:04:03 PST 2014


On Sat, Mar 1, 2014 at 9:18 AM, arnaud gaboury <arnaud.gaboury at gmail.com> wrote:
> I set up successful a Arch container managed by systemd-nspsawn.
>
> I have an issue setting an IP for the container.
>
> My host is Arch, running custom Kernel 3.13.5-1 (userspace is set) and
> systemd-git (lats updated yesterday evening).
> dhcpcd.service is disabled and network is started with these profiles:
> *************
> Description="Bridge connection to container"
> Interface=br0
> Connection=bridge
> BindsToInterfaces=()
> IP=no
> SkipNoCarrier=yes
> *********************
> NB : I tried with IP=static Adress='192.168.1.94/24' but nothing changes
> ****************
> Description='hortensia static ethernet connection'
> Interface=enp7s0
> Connection=ethernet
> After=(bridge-hortensia)
> IP=static
> Address=('192.168.1.87/24')
> Gateway='192.168.1.254'
> DNS=('212.147.10.180' '212.147.10.162')
> *********************
>
> Any other profiles will break the network on host and/or container
>
> Somme command ouptuts:
>
> gabx at hortensia ➤➤ ~ % ip addr
> 2: enp7s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state
> UP group default qlen 1000
>     link/ether 14:da:e9:b5:7a:88 brd ff:ff:ff:ff:ff:ff
>     inet 192.168.1.87/24 brd 192.168.1.255 scope global enp7s0
>        valid_lft forever preferred_lft forever
> 3: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state
> UNKNOWN group default
>     link/ether 66:c3:60:92:5f:2c brd ff:ff:ff:ff:ff:ff
> *********
> gabx at hortensia ➤➤ /etc/netctl % ip route
> default via 192.168.1.254 dev enp7s0
> 192.168.1.0/24 dev enp7s0  proto kernel  scope link  src 192.168.1.87
> ***************
>
> Now I enabled systemd-network with these two files:
> 70-dahlia.netdev
> *************
> [Match]
> Host=77f348a2b3fb429b85a5de751ea9175a  <<< /etc/machie id in conatiner
> Virtualization=systemd-nspawn
>
> [NetDev]
> Name=br0
> Kind=bridge
>
> 80-dahlia.network
> *****************
> [Match]
> Virtualization=container
> MACAddress=fa:2c:eb:75:bd:a4  <<< container MAC address

You mean the MAC address of the 'host0' device? This will not be
stable between reboots of the container, so I guess this won't work
(you can verify with "ip link"). I suggest simply matching on the name
instead: "Name=host0". I'll put on our TODO to set persistent MAC
addresses for these devices (assuming we can figure out a stable way
to generate them).

To get some more details, you could try starting networkd manually
(inside the container) in debug mode. It should then print whenever a
matching .network file is found for a given device:

# SYSTEMD_LOG_LEVEL=debug /lib/systemd/systemd-networkd

> [Network]
> DHCP=no
> DNS=192.168.1.254
>
> [Address]
> Address=192.168.1.94/24
>
> [Route]
> Gateway=192.168.1.254
> *********************************
>
> I start the container this way :
> # systemd-nspawn --machine=dahlia -bD /dahlia
>
> Container network is up, but no IP assigned, as returned by ip addr
>
> # systemd-nspawn --machine=dahlia --network-veth --network-bridge=br0  -bD
> /dahlia    >>>> no network inside container
> # systemd-nspawn --machine=dahlia --network-bridge=br0 -bD /dahlia  >>>no
> network inside container
>
> I certainly miss something, but do not know what.
>
> Thank you for help/hints.


More information about the systemd-devel mailing list