AllInfo
Main: Info Blog Temp Mail


unix 2013-07-14 10-42-25

Arch: Using a static IP address

Create the file /etc/systemd/system/network.service using your editor of choice. This example uses a static IP address and wpa_supplicant.
/etc/systemd/system/network.service
[Unit]
Description=Wireless Static IP Connectivity
Wants=network.target
Before=network.target
BindsTo=sys-subsystem-net-devices-net0.device
After=sys-subsystem-net-devices-net0.device

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/ip link set dev net0 up
ExecStart=/usr/bin/wpa_supplicant -B -i net0 -c /etc/wpa_supplicant.conf # Remove this for wired connections
ExecStart=/usr/bin/ip addr add 192.168.0.10/24 dev net0
ExecStart=/usr/bin/ip route add default via 192.168.0.1

ExecStop=/usr/bin/ip addr flush dev net0
ExecStop=/usr/bin/ip link set dev net0 down

[Install]
WantedBy=multi-user.target
Do not forget to enable it!
# systemctl enable network
To test, reboot or make sure all other network daemons are stopped and then run as root
# systemctl start network

18.191.157.186 / 2024-04-28_16-47-17 UTC.