Gentoo Archives: gentoo-user

From: Michael Hampicke <mh@××××.biz>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] Systemd and static network
Date: Fri, 26 Jul 2013 04:46:24
Message-Id: 51F1FF10.8010406@hadt.biz
In Reply to: Re: [gentoo-user] Systemd and static network by "Canek Peláez Valdés"
1 Am 25.07.2013 17:42, schrieb Canek Peláez Valdés:
2 > On Thu, Jul 25, 2013 at 5:46 AM, Michael Hampicke <mh@××××.biz> wrote:
3 >> Howdy folks,
4 >>
5 >> currently I am migrating some servers to systemd, and I am wondering
6 >> what's the best way to set up static networking. Until now, I always
7 >> used dhcp + networkmanager (workstations, laptops).
8 >>
9 >> Some suggested creating your own network unit and manually start
10 >> ifconfig/route or ip via ExecStart, some suggested Arch's netctl which
11 >> seems to support static addresses and brings a systemd unit file.
12 >>
13 >> At the moment, following the KISS principle, I tend to a customized unit
14 >> file.
15 >>
16 >> What do you use - and what are the benefits of your method?
17 >
18 > I use the following unit in one of my servers:
19 >
20 > # -------------------------------------------------------------------------------------------
21 > [Unit]
22 > Description=Static network service
23 > After=local-fs.target
24 > Documentation=man:ifconfig(8)
25 > Documentation=man:route(8)
26 >
27 > [Service]
28 > Type=oneshot
29 > RemainAfterExit=yes
30 > ExecStart=/bin/ifconfig <DEVICE> <IP> broadcast <BCAST> netmask <NETMASK> up
31 > ExecStart=/bin/route add default gw <GW> <DEVICE>
32 > # -------------------------------------------------------------------------------------------
33 >
34 > Obviously, change the necessary parameters.
35 >
36 > The benefit is that it doesn't get any more simple, I believe. If DHCP
37 > is available and I don't want to use NetworkManager, I use the
38 > following unit:
39 >
40 > # -------------------------------------------------------------------------------------------
41 > [Unit]
42 > Description=DHCP on %I
43 > After=basic.target
44 >
45 > [Service]
46 > ExecStartPre=/bin/ifconfig %I up
47 > ExecStart=/sbin/dhcpcd -B %I
48 >
49 > [Install]
50 > WantedBy=multi-user.target
51 > # -------------------------------------------------------------------------------------------
52 >
53 > You can then enable the unit with:
54 >
55 > systemctl enable dhcpcd@×××.service
56 >
57 > where DEV is enp0s0, or whatever funny name udev gives to your network
58 > card. I think I got the unit from Arch, or maybe I wrote; I honestly
59 > don't remember.
60 >
61 > Regards.
62 >
63
64 Tanks. I will give netctl a try in a VM. For now, on real machines, I am
65 going with the unit you suggested.

Attachments

File name MIME type
signature.asc application/pgp-signature

Replies

Subject Author
Re: [gentoo-user] Systemd and static network Keith Dart <keith@×××××××××.biz>