免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 4356 | 回复: 7
打印 上一主题 下一主题

[网络管理] 请问ipaddr , ip rule , ip route 这类命令怎么让它开机生效呢 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2012-03-01 12:22 |只看该作者 |倒序浏览
用ip addr  , ip route , ip rule 等命令配置了 网卡IP地址 以及 策略路由
但是发现重启后就不见了
目前我只能把配置写在rc.local里
想请问有什么其他的方法可以保存这些配置,使他们一直存在吗



论坛徽章:
381
CU十二周年纪念徽章
日期:2014-01-04 22:46:58CU大牛徽章
日期:2013-03-13 15:32:35CU大牛徽章
日期:2013-03-13 15:38:15CU大牛徽章
日期:2013-03-13 15:38:52CU大牛徽章
日期:2013-03-14 14:08:55CU大牛徽章
日期:2013-04-17 11:17:19CU大牛徽章
日期:2013-04-17 11:17:32CU大牛徽章
日期:2013-04-17 11:17:37CU大牛徽章
日期:2013-04-17 11:17:42CU大牛徽章
日期:2013-04-17 11:17:47CU大牛徽章
日期:2013-04-17 11:17:52CU大牛徽章
日期:2013-04-17 11:17:56
2 [报告]
发表于 2012-03-01 17:25 |只看该作者
本帖最后由 chenyx 于 2012-03-01 17:26 编辑

楼主看看网卡的配置文件,策略路由不清楚,其他两个都可以在网卡的配置文件里面找到
不知道楼主的linux的版本是什么,redhat系列的在/etc/sysconfig/network-scripts目录里

论坛徽章:
0
3 [报告]
发表于 2012-03-02 11:52 |只看该作者
系统用的是 centos  在network-scripts里面写配置确实可以设置网卡IP等参数
但 路由表、 策略路由 之类的改动就没办法写在里面了

论坛徽章:
381
CU十二周年纪念徽章
日期:2014-01-04 22:46:58CU大牛徽章
日期:2013-03-13 15:32:35CU大牛徽章
日期:2013-03-13 15:38:15CU大牛徽章
日期:2013-03-13 15:38:52CU大牛徽章
日期:2013-03-14 14:08:55CU大牛徽章
日期:2013-04-17 11:17:19CU大牛徽章
日期:2013-04-17 11:17:32CU大牛徽章
日期:2013-04-17 11:17:37CU大牛徽章
日期:2013-04-17 11:17:42CU大牛徽章
日期:2013-04-17 11:17:47CU大牛徽章
日期:2013-04-17 11:17:52CU大牛徽章
日期:2013-04-17 11:17:56
4 [报告]
发表于 2012-03-02 12:19 |只看该作者
在/etc/sysconfig/network-scripts/route-ethN里面写,没有的话自己写一个.

论坛徽章:
0
5 [报告]
发表于 2012-03-02 13:51 |只看该作者
楼主应该google一下

论坛徽章:
0
6 [报告]
发表于 2012-03-04 12:10 |只看该作者
本帖最后由 icooci 于 2012-03-04 12:14 编辑
  1. Mandrake & Redhat have directories for pre-up and post-up scripts.
  2. You will have to decide how much to split the files so that the routing is still correct if you manually bring an interface down.  
  3. If that's not going to ever happen, add it to the runlevel startup scripts at an approprite position.

  4. Make sure any script that runs has the last line " ip route flush cache " or you'll get stale routing info making some interesting problems.
复制代码
Iproute doesn't have a functionality like this and propably won't ever have. Allthe ip * things are set by configuration scripts at the startup.

Currently this applies not only on `ip rule` but also the same behaviour you'll get with `ip routes`, etc. None of the added data are stored.

If you need to keep your configuration, you have to dig in the bootup scripts and set the values there.

Anyway, I will discuss this with other developers and maybe I'll add this to feature requests.

论坛徽章:
1
2015元宵节徽章
日期:2015-03-06 15:50:39
7 [报告]
发表于 2012-03-05 11:55 |只看该作者
路由表可以写在两个地方:
1、/etc/sysconfig/network-scripts/route-ethX
$destination_net/mask via $gw_ip

2、/etc/sysconfig/static-routes
any net $destination_net/mask gw $gw_ip

ip rules这个东西看来是没戏了。

论坛徽章:
0
8 [报告]
发表于 2012-03-05 12:43 |只看该作者
看来还是得用开机脚本  感谢楼上几位
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP