Arch Linux设置静态IP地址的问参考 Arch Linux Network 完成。本案例是在 Seagate GoFlex Home网络存储安装Arch Linux ARM实施记录。

编辑 /etc/conf.d/net-conf-eth0

address=192.168.1.92
netmask=24
broadcast=192.168.1.255
gateway=192.168.1.1

创建 /usr/local/bin/net-up.sh

#!/bin/bash
ip link set dev "$1" up
ip addr add ${address}/${netmask} broadcast ${broadcast} dev "$1"

[[ -z ${gateway} ]] || { 
  ip route add default via ${gateway}
}

创建 /usr/local/bin/net-down.sh

#!/bin/bash
ip addr flush dev "$1"
ip route flush dev "$1"
ip link set dev "$1" down

设置脚本可执行

chmod +x /usr/local/bin/net-{up,down}.sh

systemd 服务文件 /etc/systemd/system/network@.service 如下:

[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/net-conf-%i
ExecStart=/usr/local/bin/net-up.sh %i
ExecStop=/usr/local/bin/net-down.sh %i

[Install]
WantedBy=multi-user.target

激活 network@eth0

systemctl enable network@eth0

此时提示信息

Created symlink from /etc/systemd/system/multi-user.target.wants/network@eth0.service to /etc/systemd/system/network@.service.

其他

设置操作系统启动时启动ssh服务

systemctl enable sshd.service

提示信息

Created symlink from /etc/systemd/system/multi-user.target.wants/sshd.service to /usr/lib/systemd/system/sshd.service.

设置主机名

hostnamectl set-hostname myhostname

不过我有报错 Failed to create bus connection: No such file or directory 所以改为直接修改 /etc/hostname 配置文件