sudo nano /etc/rc.local
#!/bin/sh -e
rm /etc/resolv.conf
cat <<EOF >>/etc/resolv.conf
nameserver 76.76.19.19
nameserver 94.140.15.15
nameserver 9.9.9.11
EOF
exit 0
sudo chmod +x /etc/rc.local
sudo systemctl enable rc-local.service
sudo systemctl start rc-local.service
Error: The unit files have no installation config (WantedBy, RequiredBy, Also, Alias settings in the [Install] section, and DefaultInstance for template units).
Solution:
sudo nano /etc/systemd/system/rc-local.service
[Unit]
Description=/etc/rc.local Compatibility
Documentation=man:systemd-rc-local-generator(8)
ConditionFileIsExecutable=/etc/rc.local
After=network.target
[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
RemainAfterExit=yes
GuessMainPID=no
[Install]
WantedBy=multi-user.target
## 加入 Install 即可, Add Install
[Install]
WantedBy=multi-user.target