[arch-general] systemd network configuration

C Anthony Risinger anthony at xtfx.me
Thu Jul 26 01:58:09 EDT 2012


On Thu, Jul 26, 2012 at 12:18 AM, David Benfell
<benfell at parts-unknown.org> wrote:
>
> [Install]
> Alias=sys-subsystem-net-devices-lan0.device.wants/u.net.static at
> lan0.service
>
> I see that %I is supposed to stand for eth0; how do I connect this
> with eth0?

i modified it for you here: http://dpaste.com/775539/plain/

==================================
# network interfaces bindings

[Unit]
Description=Static Interface [%I]
StopWhenUnneeded=true
Wants=network.target
Before=network.target
BindTo=sys-subsystem-net-devices-%i.device
After=sys-subsystem-net-devices-%i.device
After=basic.target

[Service]
Type=oneshot
TimeoutSec=0
Restart=always
RestartSec=30
RemainAfterExit=yes
ExecStart=-/usr/sbin/ip addr add 10.50.250.1/24 dev %I
ExecStart=/usr/sbin/ip link set %I up

[Install]
Alias=sys-subsystem-net-devices-eth0.device.wants/net.static at eth0.service
==================================

... then:

# wget -O /etc/systemd/system/net.static at .service
http://dpaste.com/775539/plain/
<<< modify the ExecStart as appropriate! >>>
# systemctl daemon-reload
# systemctl enable net.static at eth0.service

[maybe, first time only]
# systemctl start net.static at eth0.service

... and now whatever you put in the ExecStart(s) will execute every
time the device appears.

-- 

C Anthony


More information about the arch-general mailing list