[systemd-devel] systemd-nspawn network ping

Kai Krakow hurikhan77 at gmail.com
Sun Feb 28 16:26:54 UTC 2016


Am Sun, 28 Feb 2016 23:41:22 +0800 (CST)
schrieb kennedy <kennedyhan at 163.com>:

> how to ping container to container each other in systemd-nspawn ?
> I've tried --network-veth option but it doesn't work enough.

You need to join all host-side veth interfaces into the same bridge.
Make two files for systemd-networkd:

# 99-bridge-cn.netdev
[NetDev]
Name=br-containers
Kind=bridge
[Match]
Name=br-containers

# 99-bridge-cn.network
[Network]
Address=10.0.0.1/24
DHCPServer=yes
IPForward=yes
IPMasquerade=yes

Then "systemctl --edit systemd-nspawn at .service" to contain the
following:

############
[Service]
ExecStart=
ExecStart=/usr/bin/systemd-nspawn --quiet --keep-unit --boot \
--link-journal=try-guest --private-network \
--network-bridge=br-containers --machine=%I
############

This will add all your container veth devices to the same bridge which
you configured in systemd-networkd. You should now be able to ping each
other.

You may need to adjust a few more settings for your needs. I'd
recommend to add nss-mymachines (see man page).


-- 
Regards,
Kai

Replies to list-only preferred.



More information about the systemd-devel mailing list