iproute2配置电信网通(策略路由)
2015-07-17 21:30
435 查看
我的博客已迁移到xdoujiang.com请去那边和我交流 cat ip.sh #!/bin/bash #-------------------------------------------------- #Author:jimmygong #Email:jimmygong@taomee.com #FileName:ip.sh #Function: #Version:1.0 #Created:2015-07-17 #-------------------------------------------------- rttable=`cat /etc/iproute2/rt_tables|egrep "251|252"` if [[ $? -ne 0 ]] then echo '252 cnc' >> /etc/iproute2/rt_tables echo '251 ctc' >> /etc/iproute2/rt_tables fi ctcgw=1.1.1.1 cncgw=2.2.2.2 ctceth=eth0 cnceth=eth2 ctcip=`cat /etc/sysconfig/network-scripts/ifcfg-$ctceth|grep -i ^ipaddr|awk -F \= '{print $2}'` cncip=`cat /etc/sysconfig/network-scripts/ifcfg-$cnceth|grep -i ^ipaddr|awk -F \= '{print $2}'` ip route flush table ctc ip route add default via $ctcgw dev $ctceth src $ctcip table ctc ip rule add from $ctcip table ctc ip route flush table cnc ip route add default via $cncgw dev $cnceth src $cncip table cnc ip rule add from $cncip table cnc 一些说明 1、配置说明 表255 local(本地路由表) 表254 main(主路由表) 表253 default(默认路由表) 2、查看路由表内容 ip route list table ctc default via 1.1.1.1 dev eth0 src 111.111.111.111 ip route list table cnc default via 2.2.2.2 dev eth2 src 222.222.222.222 3、需要安装iproute包(也就是ip命令) yum -y install iproute 4、变量说明 ctcgw 表示电信网关 cncgw 表示网通网关 ctceth 使用eth0 接电信外网ip cnceth 使用eth2 接网通外网ip eth1 接的内网 5、ip命令
相关文章推荐
- 房产界已上市和IPO路上的难兄难弟:房天下与房多多
- 雷军是谁,他为什么而奋斗?小米上市和雷军的英雄主义
- IP网络路由技术
- 如何利用“IP地址欺骗”
- 新手看招:避免网络 IP 地址被非法修改
- 网络管理之IP地址篇
- ip地址基础知识
- 脚本之家因服务器资源紧张 换了ip并升级了带宽
- IP地址组成与类型
- 计算机名DNS网关IP(大家可以用来学习)
- Windows2003下批量添加和导出所有ip BAT脚本
- 一个能对访问者进行编号、记录访问次数、IP、时间的统计制作实例
- 用vbscript脚本实现返回 IP 配置数据的代码
- 用vbs针对一个 IP 地址范围运行脚本
- asp实现检查ip地址是否为内网或者私有ip地址的代码分享
- 根据IP跳转到用户所在城市的实现步骤
- vbs版IP地理位置查询小偷
- bat脚本显示本机IP地址的两种方法(内网ip)
- PHP判断IP并转跳到相应城市分站的方法