[systemd-devel] systemd-networkd and bonding config
Tom Gundersen
teg at jklm.no
Wed Mar 4 01:43:48 PST 2015
Hi Mikhail,
On Sat, Feb 28, 2015 at 1:26 PM, Mikhail Morfikov <mmorfikov at gmail.com> wrote:
> I've just finished migration from /etc/init.d/networking script to
> systemd-networkd solution, and I just wanted to ask a couple of things.
>
> First, I have two interfaces -- one wire (eth1) and one wifi (wlan0),
> and I want them to be bonded into one bond0 interface. I had that
> solution when I was using sysvinit, and, so far, I haven't played with
> the network settings. After some reading, I managed to set the exact
> same setup and it works, more or less.
>
> Here are the questions:
>
> 1. How to set a MAC address to the bond0 interface? So far, I created
> 05-bond0.link file:
>
> # cat /etc/systemd/network/05-bond0.link
> [Match]
> Driver=bonding
> Name=bond0
>
> [Link]
> MACAddress=3c:4a:92:00:4c:5b
>
> The MAC address is the MAC address of the eth1 interface. Is this the
> right way to do it?
You don't need to have a .link file for bonding devices. .link files
are a way to override the kernel defaults for network devices that we
don't create (i.e., wlan0/eth0 and typically other real hardware). For
virtual devices that we create we can just set the correct information
at creation time, which is done in .netdev files. But see below.
> 2. I noticed that the bonding information is bugged for some reason, I
> mean, when you check it under:
>
> # cat /proc/net/bonding/bond0
> Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)
>
> Bonding Mode: load balancing (round-robin)
> MII Status: up
> MII Polling Interval (ms): 0
> Up Delay (ms): 0
> Down Delay (ms): 0
>
> Slave Interface: wlan0
> MII Status: up
> Speed: Unknown
> Duplex: Unknown
> Link Failure Count: 0
> Permanent HW addr: c0:cb:38:01:f0:f5
> Slave queue ID: 0
>
> Slave Interface: eth1
> MII Status: up
> Speed: 10 Mbps
> Duplex: half
> Link Failure Count: 0
> Permanent HW addr: 3c:4a:92:00:4c:5b
> Slave queue ID: 0
>
> it gives you the proper interfaces, but Up/Down Delay are set to 0
> and "Link Failure Count" doesn't count anything. The "Bonding Mode" is
> also wrong.
>
> This is the bonding file for networkd :
>
> # cat 20-bond0.netdev
> [NetDev]
> Description=Bonding interface
> Name=bond0
> Kind=bond
> MACAddress=3c:4a:92:00:4c:5b
>
> [Bond]
> Mode=active-backup
> MIIMonitorSec=200
> UpDelaySec=1000
> DownDelaySec=1000
>
> Is the information bugged, or should I check some other file in order to
> see the bonding settings?
The logic here is that when we create a new bond we will create it
with these settings, but we will not change the settings of a
preexisting bond, as that may have been created by somebody else we
don't know about so we figure better leave it alone.
The confusing part here is that the kernel will create bond0 with
default settings, and we will then not touch that. Ideally there would
be a kernel config switch to make it not create default devices like
that, but for the moment I think the best solution is to simply call
your bond something else. So if you put bond1 everywhere instead
things should JustWork(TM).
> 3. I don't know why, but sometimes (at boot stage) I get the following
> error message:
>
> # journalctl -b -1 -u systemd-networkd
> -- Logs begin at Sun 2015-02-22 21:48:12 CET, end at Sat 2015-02-28 12:33:57 CET. --
> Feb 28 12:08:26 morfikownia systemd[1]: Starting Network Service...
> Feb 28 12:08:27 morfikownia systemd-networkd[1165]: bond0 : netdev ready
> Feb 28 12:08:27 morfikownia systemd-networkd[1165]: br_lxc : netdev ready
> Feb 28 12:08:27 morfikownia systemd-networkd[1165]: Enumeration completed
> Feb 28 12:08:27 morfikownia systemd[1]: Started Network Service.
> Feb 28 12:08:27 morfikownia systemd-networkd[1165]: ifb0 : lost carrier
> Feb 28 12:08:27 morfikownia systemd-networkd[1165]: ifb1 : lost carrier
> Feb 28 12:08:27 morfikownia systemd-networkd[1165]: ifb0 : gained carrier
> Feb 28 12:08:27 morfikownia systemd-networkd[1165]: ifb1 : gained carrier
> Feb 28 12:08:28 morfikownia systemd-networkd[1165]: bond0 : bond0 : could not bring up interface: Invalid argument
> Feb 28 12:08:28 morfikownia systemd-networkd[1165]: br_lxc : br_lxc : could not bring up interface: Invalid argument
> Feb 28 12:08:28 morfikownia systemd-networkd[1165]: br_lxc : link configured
> Feb 28 12:08:28 morfikownia systemd-networkd[1165]: wlan0 : wlan0 : could not join netdev: Operation not permitted
> Feb 28 12:08:28 morfikownia systemd-networkd[1165]: wlan0 : failed
> Feb 28 12:08:28 morfikownia systemd-networkd[1165]: eth1 : link configured
> Feb 28 12:08:28 morfikownia systemd-networkd[1165]: lo : link configured
> Feb 28 12:08:28 morfikownia systemd-networkd[1165]: bond0 : gained carrier
> Feb 28 12:08:34 morfikownia systemd-networkd[1165]: wlan0 : gained carrier
> Feb 28 12:11:02 morfikownia systemd-networkd[1165]: wlan0 : lost carrier
>
> But after the boot stage, when I restart the systemd-networkd
> service, everything works just fine.
>
> Feb 28 12:14:52 morfikownia systemd[1]: Starting Network Service...
> Feb 28 12:14:53 morfikownia systemd-networkd[1103]: bond0 : netdev ready
> Feb 28 12:14:53 morfikownia systemd-networkd[1103]: br_lxc : netdev ready
> Feb 28 12:14:53 morfikownia systemd-networkd[1103]: Enumeration completed
> Feb 28 12:14:53 morfikownia systemd-networkd[1103]: ifb0 : lost carrier
> Feb 28 12:14:53 morfikownia systemd-networkd[1103]: ifb1 : lost carrier
> Feb 28 12:14:53 morfikownia systemd-networkd[1103]: ifb0 : gained carrier
> Feb 28 12:14:53 morfikownia systemd[1]: Started Network Service.
> Feb 28 12:14:53 morfikownia systemd-networkd[1103]: ifb1 : gained carrier
> Feb 28 12:14:54 morfikownia systemd-networkd[1103]: bond0 : bond0 : could not bring up interface: Invalid argument
> Feb 28 12:14:54 morfikownia systemd-networkd[1103]: br_lxc : br_lxc : could not bring up interface: Invalid argument
> Feb 28 12:14:54 morfikownia systemd-networkd[1103]: br_lxc : link configured
> Feb 28 12:14:54 morfikownia systemd-networkd[1103]: wlan0 : link configured
> Feb 28 12:14:54 morfikownia systemd-networkd[1103]: bond0 : gained carrier
> Feb 28 12:14:54 morfikownia systemd-networkd[1103]: eth1 : link configured
> Feb 28 12:14:54 morfikownia systemd-networkd[1103]: lo : link configured
> Feb 28 12:14:57 morfikownia systemd-networkd[1103]: wlan0 : gained carrier
> Feb 28 12:14:58 morfikownia systemd-networkd[1103]: bond0 : DHCPv4 address 192.168.1.150/24 via 192.168.1.1
> Feb 28 12:14:58 morfikownia systemd-networkd[1103]: bond0 : link configured
>
> This problem occurs randomly -- sometimes the wlan interface fails,
> sometimes it doesn't. I don't know why this happens, but it
> always can be fixed by restarting the systemd-networkd service.
> I know wlan interfaces require wpasupplicant config, and I created
> the appropriate service file:
>
> # cat wpa_supplicant at .service
> [Unit]
> Description=WPA supplicant (%i)
> After=systemd-networkd.service
> Requires=systemd-networkd.service
> Before=network-online.target
> ConditionPathIsSymbolicLink=/sys/class/net/%i
>
> [Service]
> Type=simple
> ExecStartPre=/sbin/ip link set %i up
> ExecStart=/sbin/wpa_supplicant -s -i %i -b bond0 -D nl80211,wext -q -c /etc/wpa_supplicant/wpa_supplicant.conf -O /run/wpa_supplicant
> ExecStopPost=/sbin/ip addr flush %i
> ExecStopPost=/sbin/ip link set %i down
>
> [Install]
> WantedBy=multi-user.target
>
> I don't use any GUI apps like network-manager.
Hm, this I haven't seen. I'll have to take a closer look. Thanks for the report!
> 4. How to disable/enable an interface? When I was using the sysvinit
> networking script, I also had tools like ifup and ifdown . Do I have
> to create some service files that include several ip* commands, or is
> there a better way?
At the moment we only do static configuration, so we don't natively
support run-time configuration. We'll soon get the equivalent of
ifup/ifdown as part of networkctl, but for now we only support
applying your configuration files as specified at boot-time.
You can of course use ip(8) to manually bring links up/down: "ip link
set down wlan0" and networkd will cope with that just fine.
HTH,
Tom
More information about the systemd-devel
mailing list