vi /etc/systemd/system/rc-local.service 系统开机运行rc.local

[Unit]
Description=/etc/rc.local Compatibility
ConditionPathExists=/etc/rc.local

[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
StandardOutput=tty
RemainAfterExit=yes
SysVStartPriority=99

[Install]
WantedBy=multi-user.target (复制粘贴配置文件中)

vi /etc/rc.local 改写开机启动权限

!/bin/bash
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel. 6 # Make sure that the script will “exit 0” on success or any other 7 # value on error.
#
# In order to enable or disable this script just change the execution 10 # bits.
#
# By default this script does nothing. 13
sleep 10
ip ro add default via 网关 table 1
ip ru add from IP table 1
exit 0 (复制粘贴配置文件中)

chmod +x /etc/rc.local 执行修改的权限

systemctl enable rc-local 设置下次开机启动rc-local

systemctl start rc-local.service 启动rc-local的服务

systemctl status rc-local.service 查看rc-local的服务状态