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