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 11:35:42
Message-Id: a0da705d0bb63ddde7af14b4e7d47ec1@hadt.biz
In Reply to: Re: [gentoo-user] Systemd and static network by "Stefan G. Weichinger"
1 Am 2013-07-26 11:26, schrieb Stefan G. Weichinger:
2 > Am 25.07.2013 17:42, schrieb Canek Peláez Valdés:
3 >
4 >>> What do you use - and what are the benefits of your method?
5 >>
6 >> I use the following unit in one of my servers:
7 >>
8 >> #
9 >> -------------------------------------------------------------------------------------------
10 >> [Unit]
11 >
12 >
13 > My current version, using "ip" :
14 >
15 > # cat network.service
16 > [Unit]
17 > Description=Network Connectivity
18 >
19 > [Service]
20 > Type=oneshot
21 > RemainAfterExit=yes
22 >
23 > EnvironmentFile=/etc/conf.d/network_systemd
24 > ExecStart=/bin/ip link set dev ${interface} up
25 > ExecStart=/bin/ip addr add ${address}/${netmask} broadcast ${broadcast}
26 > dev ${interface}
27 > ExecStart=/bin/ip route add default via ${gateway}
28 >
29 > ExecStop=/bin/ip addr flush dev ${interface}
30 > ExecStop=/bin/ip link set dev ${interface} down
31 >
32 > [Install]
33 > WantedBy=network.target
34 >
35 > ----- so that unitfile does not have to be touched again and you only
36 > edit /etc/conf.d/network_systemd ->
37 >
38 > # cat /etc/conf.d/network_systemd
39 > PATH=/sbin:/usr/sbin
40 > interface=p4p1
41 > address=192.x.y.z
42 > netmask=255.255.255.0
43 > broadcast=192.x.y.zz
44 > gateway=192.x.y.zzz
45 >
46 > -----
47 >
48 > I have a second unitfile with a more complicated setup for bridging
49 > (with KVM).
50 >
51 > Stefan
52
53 Good idea, I already had forgotten that you could parse variables from
54 another file in a systemd unit.