禁用傻逼 systemd-resolved
vi /etc/systemd/resolved.conf : 设置 DNSStubListener=no
[Resolve]
DNSStubListener=no
修改后需要 reboot 生效。
# 原来的 resolv.conf 是 systemd-resolved 创建的符号链接,删掉重建
rm /etc/resolv.conf
vi /etc/resolv.conf
chattr +i /etc/resolv.conf
/etc/resolv.conf 直接配置 DNS 服务器即可:
nameserver 8.8.8.8
systemd.unit
/etc/systemd/system/*
/run/systemd/system/*
/usr/lib/systemd/system/*
service 的文件名格式:(命令末尾的 .service 省略)
- XXX.service : systemctl status XXX
- XXX@.service : 实例化 service. systemctl status XXX@1
例如,openvpn 包自带的 /usr/lib/systemd/system/openvpn@.service :
[Unit]
Description=OpenVPN Robust And Highly Flexible Tunneling Application On %I
After=network.target
[Service]
Type=notify
PrivateTmp=true
ExecStart=/usr/sbin/openvpn --cd /etc/openvpn/ --config %i.conf
[Install]
WantedBy=multi-user.target
service.unit 里面的可用参数:
- %i : instance name, the string between the "@" character and the suffix of the unit name
创建 /etc/openvpn/client.test.conf 配置文件,然后启用 openvpn service:
# 引用 service.unit 时末尾的 ".service" 可以省略
systemctl status openvpn@client.test.service
systemctl start openvpn@client.test.service
systemctl enable openvpn@client.test.service
修改 unit 文件后,可能需要重新加载使修改生效
systemctl daemon-reload
systemctl
# 清空 systemctl 里显示的所有 failed 项目
systemctl reset-failed
systemctl list-unit-files