Skip to content

Instantly share code, notes, and snippets.

@kokizzu
Created July 22, 2014 21:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kokizzu/2e6e6838dfe360a73b5d to your computer and use it in GitHub Desktop.
Save kokizzu/2e6e6838dfe360a73b5d to your computer and use it in GitHub Desktop.
Systemd network service file
[Unit]
Description=Network connectivity (%i)
Wants=network.target
Before=network.target
BindsTo=sys-subsystem-net-devices-%i.device
After=sys-subsystem-net-devices-%i.device
[Service]
Type=oneshot
RemainAfterExit=yes
EnvironmentFile=/etc/conf.d/network@%i
ExecStart=/usr/bin/ip link set dev %i up
ExecStart=/usr/bin/ip addr add ${address}/${netmask} broadcast ${broadcast} dev %i
ExecStart=/usr/bin/sh -c 'test -z ${gateway} || /usr/bin/ip route add default via ${gateway}'
ExecStop=/usr/bin/ip addr flush dev %i
ExecStop=/usr/bin/ip route flush dev %i
ExecStop=/usr/bin/ip link set dev %i down
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment