Пока идут выходные, решил поковырять systemd-nspawn. На данный момент не очень-то успешно.
Задача: отдельный статический ip для mageia в systemd-nspawn контейнере
Мои действия: Запустил systemd-networkd на хосте
systemctl start systemd-networkd
systemctl enable systemd-networkd
Подготовил файлы mageia для контейнера
mkdir -p /mnt/container
urpmi --root /mnt/container --use-distrib http://ftp.belnet.be/mageia/distrib/5/x86_64/ basesystem-minimal rpm-build urpmi nano --auto
Создал бридж на хосте
brctl addbr cont-br0
ip a a 192.168.1.8 dev cont-br0
и конфиги /etc/systemd/network/cont-br0.netdev
[NetDev]
Name=cont-br0
Kind=bridge
/etc/systemd/network/cont-br0.network
[Match]
Name=${CONTAINER_BRIDGE}
[Network]
DNS=192.168.1.1
Address=192.168.1.8
Gateway=192.168.1.1
Создал конфиг в контейнере /etc/systemd/network/veth.network
[Match]
Name=host0
[Network]
DNS=192.168.1.1
Address=192.168.1.3
Gateway=192.168.1.1
Создал systemd-юнит для запуска контейнера
[Unit]
Description=Run container
[Service]
ExecStart=/usr/bin/systemd-nspawn --machine=container --directory=/mnt/container --network-bridge=cont-br0 -b
Restart=always
[Install]
Also=dbus.service
В контейнере сделал
ln -sf /dev/null /etc/systemd/network/80-container-host0.network
systemctl start systemd-networkd
systemctl enable systemd-networkd
В результате в контейнере
[root@container ~]# systemctl status -l network
● network.service - LSB: Bring up/down networking
Loaded: loaded (/etc/rc.d/init.d/network)
Active: failed (Result: exit-code) since Sat 2016-01-02 23:01:21 MSK; 12min ago
Process: 229 ExecStart=/etc/rc.d/init.d/network start (code=exited, status=6)
Jan 02 23:01:21 mbfcontainer systemd[1]: network.service: control process exited, code=exited status=6
Jan 02 23:01:21 mbfcontainer systemd[1]: Failed to start LSB: Bring up/down networking.
Jan 02 23:01:21 mbfcontainer systemd[1]: Unit network.service entered failed state.
Jan 02 23:01:21 mbfcontainer systemd[1]: network.service failed.
Нужный конфиг в контейнере подцепился, нужный ip в ifconfig, но сеть по факту «лежит»
# ifconfig
host0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.3 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::345e:41ff:fe63:68d2 prefixlen 64 scopeid 0x20<link>
ether 36:5e:41:63:68:d2 txqueuelen 1000 (Ethernet)
RX packets 4 bytes 600 (600.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 24 bytes 1700 (1.6 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 0 (Local Loopback)
RX packets 11 bytes 1100 (1.0 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 11 bytes 1100 (1.0 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: host0@if20: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 36:5e:41:63:68:d2 brd ff:ff:ff:ff:ff:ff link-netnsid 0
inet 192.168.1.3/24 brd 192.168.1.255 scope global host0
valid_lft forever preferred_lft forever
inet6 fe80::345e:41ff:fe63:68d2/64 scope link
valid_lft forever preferred_lft forever
# networkctl status -a
● 1: lo
Link File: n/a
Network File: n/a
Type: loopback
State: carrier (unmanaged)
MTU: 65536
Address: 127.0.0.1
::1
● 2: host0
Link File: n/a
Network File: /etc/systemd/network/veth.network
Type: ether
State: routable (configured)
HW Address: 36:5e:41:63:68:d2
MTU: 1500
Address: 192.168.1.3
fe80::345e:41ff:fe63:68d2
DNS: 192.168.1.1
Подскажите, пожалуйста, в какую сторону нужно копать. Гугл ответа не дает.