iproute2配置电信网通(策略路由)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
我的博客已迁移到xdoujiang.com请去那边和我交流 cat ip.sh
#!/bin/bash #-------------------------------------------------- #Author:jimmygong #Email:[email protected] #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命令 |
本文转自 xdoujiang 51CTO博客,原文链接:http://blog.51cto.com/7938217/1675792,如需转载请自行联系原作者