[lfs-dev] Use systemd to configure network interfaces
bruce.dubbs at gmail.com
Mon Apr 14 19:42:53 PDT 2014
Bruce Dubbs wrote:
> Sebastian Plotz wrote:
>> Am 14.04.2014 21:52, schrieb Bruce Dubbs:
>>> I've thought about it, but my experience with systemd is limited. Do
>>> you have specific instructions I can test with LFS? -- Bruce
>> Ok, I'll try to give a starting point.
>> 1.) First of all we need to create a .link file (for example
>> 15-eth0.link) in /usr/lib/systemd/network:
>> This assignes the name eth0 to the interface with the MAC address
>> 12:34:56:78:9a:bc. The file name is important: if there would be a
>> second file (for example 10-eth1.link) with "Name=eth1"instead of
>> "Name=eth0" the interface would get the name eth1.
> Interesting. Do you know what happens if there is a udev rule that
> creates eth0? Is this .link file needed? I can test that so it's
> somewhat of a rhetorical question.
>> 2.) The second step would be to create .network files (for example
>> 10-eth0-static.network) in /usr/lib/systemd/network. These files are
>> read by systemd-networkd. This service is started by default in
>> (http://www.phoronix.com/scan.php?page=news_item&px=MTYxMTI). Otherwise
>> the service can be enabled with
>> systemctl start systemd-networkd
>> I took the example configuration from the LFS book:
>> This configuration assigns the ip address and the gateway to the
>> interface eth0. It is also possible to use DHCP and other things (see
>> I hope this helps a bit. I'm open to discuss further details.
> If I understand correctly, systemd has built in dhcp too. E.g.
> I'll experiment a little, but probably not until Wednesday.
I had a few minutes and did some experimenting. I did:
cat > /etc/systemd/network/10-eth0-static.network << EOF
and disabled ifupdown with 'systemctl disable ifupdown at eth0'
(Actually I did this in chroot. There was a warning about not being
able to read /proc/cmdline, but that didn't matter)
On reboot, eth0 came up. The .link file was not needed because I have
/etc/udev/rules.d/70-persistent-net.rules to rename the connection.
Right now on a base LFS system I have the following non-kernel processes
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 21:00 ? 00:00:01 /sbin/init
root 86 1 0 21:00 ? 00:00:00 /lib/systemd/systemd-journald
root 93 1 0 21:00 ? 00:00:00 /lib/systemd/systemd-udevd
root 176 1 0 21:00 ? 00:00:00 /lib/systemd/systemd-logind
message+ 178 1 0 21:00 ? 00:00:00 /usr/bin/dbus-daemon
root 179 1 0 21:00 ? 00:00:00 /lib/systemd/systemd-networkd
root 188 1 0 21:00 tty1 00:00:00 -bash
bdubbs 17053 188 0 21:11 tty1 00:00:00 -su
root 26169 1 0 21:20 ? 00:00:00 /usr/sbin/sshd -D
More information about the lfs-dev