You are not logged in.

#1 2013-08-03 12:20:31

devrandom
Member
Registered: 2013-08-03
Posts: 1

Autostart of network-service fails, but manual start works fine

I followed a guide to set up a network connection. The steps were to create a network config (/etc/config.d/network)

interface=eth0
address=192.168.1.2
netmask=24
broadcast=192.168.1.255
gateway=192.168.1.1

then a service description (/etc/systemd/system/network.service)

[Unit]
Description=Network startup
Wants=network.target
Before=network.target

[Service]
Type=oneshot
RemainAfterExit=yes
EnvironmentFile=/etc/conf.d/network
ExecStart=/sbin/ip link set dev ${interface} up
ExecStart=/sbin/ip addr add ${address}/${netmask} broadcast ${broadcast} dev ${interface}
ExecStart=/sbin/ip route add default via ${gateway}
ExecStop=/sbin/ip addr flush dev ${interface}
ExecStop=/sbin/ip link set dev ${interface} down

[Install]
WantedBy=multi-user.target

and then enable the service using systemctl enable network.

After the rebooting calling systemctl states the service as failed. If I start it manually using systemctl start network everything works fine.

How do I get it to work with autostart? Thanks in advance.

Last edited by devrandom (2013-08-03 12:22:55)

Offline

#2 2013-08-03 16:59:20

henk
Member
From: Weert, Netherlands
Registered: 2013-01-01
Posts: 330

Re: Autostart of network-service fails, but manual start works fine

With 'a guide' I presume you referred to this guide
The guide states

To set static IP on enp3s0 interface you will need to create /etc/conf.d/network@enp3s0 config file and run:
# systemctl enable network@enp3s0.service

where enp3s0 has to be changed into your own interface name.

Note that the EnvironmentFile has to change to /etc/conf.d/network@<interface>.

Offline

Board footer

Powered by FluxBB