LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 862|回复: 3

如何在启动的时候调用脚本读取路由信息添加路由

[复制链接]
发表于 2008-3-17 11:44:20 | 显示全部楼层 |阅读模式
在嵌入式平台(arm+linux)执行添加路由命令后,执行ip route返回
192.168.4.0/24 via 192.168.1.100 dev eth0
192.168.4.0/24 via 192.168.0.200 dev eth1
192.168.3.0/24 dev eth1
192.168.2.0/24 dev eth1 src 192.168.2.200
192.168.1.0/24 dev eth0 src 192.168.1.100
192.168.1.0/24 dev eth1 src 192.168.1.200
192.168.0.0/24 dev eth1 src 192.168.0.200
default dev eth1

将返回结果保存为route.save文件,但是重新启动后路由信息都丢失了,所以我想在重新启动后,执行一个shell脚本来读取这个route.save文件,取出相应的字段,并添加相应的路由信息。

问题:
1.这个shell脚本如何编写呢?
2.有没有更好的办法来解决这个问题呢?
发表于 2008-3-17 12:22:48 | 显示全部楼层
在init.d中可以加入一个脚本来读取这个save文件,然后link这个脚本到2,3 runlevel中。如果本身已有网络启动的Hook脚本,最好就是整合到已有的机制中。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2008-3-17 14:53:55 | 显示全部楼层
那加入的这个脚本如何编写呢?
回复 支持 反对

使用道具 举报

发表于 2008-3-18 03:16:28 | 显示全部楼层
1. if the route config is static, then pre-make the file, store into /etc/ somewhere. the script can just parse it and configure the route according to lines in the file.
2. if the route is dynamic, I'd assume you will need to run something else to generate it and then feed into your script to configure.
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表