1.在/etc/init.d/创建你的脚本

cd /etc/init.d/
sudo vim add_static_route_to_34_52.sh

2.在脚本中按如下模板填写

注意### BEGIN INIT INFO和### END INIT INFO之间的都要写,后面有机会研究下为什么。

后面接的就是我的命令,增加一条默认路由

#!/bin/bash
### BEGIN INIT INFO
# Provides:          tuzixini
# Required-Start:    $local_fs $network
# Required-Stop:     $local_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: self define auto start
# Description:       self define auto start
### END INIT INFO
sudo route add -host 172.xx.xx.xx gw 172.xx.xx.254

3.修改文件属性 

sudo chmod 775 add_static_route_to_34_52.sh 

4.添加到rc脚本里

sudo update-rc.d add_static_route_to_34_52.sh defaults 90

5.reboot以查看是否生效 

ps:从rc脚本里移除

sudo update-rc.d -f add_static_route_to_34_52.sh remove

参考:https://blog.csdn.net/tuzixini/article/details/95616333

https://blog.csdn.net/edsoki/article/details/107430687

 

相关文章:

  • 2021-06-21
  • 2021-11-21
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-05
  • 2021-07-15
  • 2021-04-24
猜你喜欢
  • 2022-12-23
  • 2021-11-12
  • 2021-05-22
  • 2022-12-23
  • 2021-12-19
  • 2021-11-20
  • 2021-09-26
相关资源
相似解决方案