Gentoo Archives: gentoo-user

From: "Canek Peláez Valdés" <caneko@×××××.com>
To: Jonathan Callen <jcallen@g.o>
Cc: gentoo-user@l.g.o
Subject: [gentoo-user] Re: Systemd and static network
Date: Fri, 26 Jul 2013 02:13:24
Message-Id: CADPrc81FhSqmtPFy1+98zZbHYyje200xAjeyMi6+h6GX91igTg@mail.gmail.com
1 On Thu, Jul 25, 2013 at 8:50 PM, Jonathan Callen <jcallen@g.o> wrote:
2 > On 07/25/2013 11:42 AM, Canek Peláez Valdés wrote:
3 >> On Thu, Jul 25, 2013 at 5:46 AM, Michael Hampicke <mh@××××.biz>
4 >> wrote:
5 >>> What do you use - and what are the benefits of your method?
6 >>
7 >> I use the following unit in one of my servers:
8 >>
9 >> # -------------------------------------------------------------------------------------------
10 >> [Unit]
11 >> Description=Static network service
12 >> After=local-fs.target
13 >> Documentation=man:ifconfig(8)
14 >> Documentation=man:route(8)
15 >>
16 >> [Service]
17 >> Type=oneshot
18 >> RemainAfterExit=yes
19 >> ExecStart=/bin/ifconfig <DEVICE> <IP> broadcast <BCAST> netmask
20 > <NETMASK> up
21 >> ExecStart=/bin/route add default gw <GW> <DEVICE>
22 >> #
23 > -------------------------------------------------------------------------------------------
24 >>
25 >
26 > I would recommend replacing those two commands with:
27 >
28 > ExecStart=/bin/ip addr add <IP>/<CIDR> dev <DEVICE>
29 > ExecStart=/bin/ip route add default via <GW> dev <DEVICE>
30 >
31 > This uses the newer iproute2 infrastructure, which is supposed to
32 > replace the deprecated net-tools package (last official release was in
33 > 2001).
34 >
35 > Note also that this uses the CIDR notation for IP addresses. If you
36 > were previously using "ifconfig eth0 192.168.1.5 broadcast
37 > 192.168.1.255 netmask 255.255.255.0", you can simply say "ip addr add
38 > 192.168.1.5/24 dev eth0" which calculates both netmask and broadcast
39 > from the "/24" (which means the upper 24 bits are used).
40
41 Thanks for the heads up.
42
43 Regards.
44 --
45 Canek Peláez Valdés
46 Posgrado en Ciencia e Ingeniería de la Computación
47 Universidad Nacional Autónoma de México