关于Redhat下静态路由添加的几种方法
来源:互联网 发布:mac上app store打不开 编辑:程序博客网 时间:2024/05/28 15:37
在网络上,常见有三种办法:
1、将路由添加命令写入 /etc/rc.local 文件中,如:
[root@mu01 ~]# cat /etc/rc.local
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.
touch /var/lock/subsys/local
route add -net 192.168.3.0/24 gw 192.168.3.254
2、将静态路由添加的命令写入profile文件中,如:
[root@mu01 ~]# cat /etc/profile
# /etc/profile
route add -net 192.168.3.0/24 gw 192.168.3.254
3、新建/etc/sysconfig/static-routes文件,修改此配置文件,如:
[root@mu01 ~]# cat /etc/sysconfig/static-routes
any net 192.168.3.0/24 gw 192.168.3.254
其中前两种方法,也许配置后重启操作系统也可以生效,但在操作系统运行时重启网络服务,静态路由就会丢失,为什么第三种方法添加的静态路由即使重启网络服务也不会丢失:
[root@mu01 ~]# cat /etc/init.d/network
***
# Add non interface-specific static-routes.
if [ -f /etc/sysconfig/static-routes ]; then
grep "^any" /etc/sysconfig/static-routes | while read ignore args ; do
/sbin/route add -$args
done
fi
if [ -f /etc/sysconfig/static-routes ]; then
grep "^any" /etc/sysconfig/static-routes | while read ignore args ; do
/sbin/route add -$args
done
fi
***
检查配置文件得知,脚本会检测static-routes文件是否存在,存在的情况下会添加到系统中,所以修改静态路由应使用第三种方法。
0 0
- 关于Redhat下静态路由添加的几种方法
- Linux服务器之Redhat添加静态路由的几种方式
- 关于添加WINDOWS静态路由的方法
- Linux下添加静态路由的方法
- 添加URL路由的几种方法
- Centos5.5 下的永久添加静态路由方法
- redhat双网关静态路由的问题解决方法
- 关于linux的添加永久静态路由的static-routes方法
- windows下添加静态路由
- windows下添加静态路由
- linux下(Ubuntu、centos)添加永久静态路由的方法
- linux下(Ubuntu、centos)添加永久静态路由的方法
- Linux RedHat下添加自启动脚本的几种方式
- 向OS X添加静态路由的方法
- CentOS6 Linux系统添加永久静态路由的方法
- suse 11 Linux 静态路由的添加方法
- 静态路由表的添加
- 查看路由信息的几种方法
- PAT - 1059. C语言竞赛(20)
- skyline测试页面
- JavaSpring使用Quartz任务调度定时器
- Java 多线程之 Runnable VS Thread 及其资源共享问题
- HDU 5894 hannnnah_j’s Biologica(lucas定理求组合数+乘法逆元)——2016 ACM/ICPC Asia Regional Shenyang Online
- 关于Redhat下静态路由添加的几种方法
- 大型网站架构模式
- java之static用法
- 广播 有序和无序的区别 本地和全局的区别
- 第4周项目5-循环双链表应用
- 使用doxygen生成文档
- Java 图片转二进制及生成图片
- 中断占用CPU的时间分析
- The MySQL 8.0.0 Milestone Release is available