Chinaunix
标题:
双线脚本
[打印本页]
作者:
ajiangg
时间:
2007-10-28 17:55
标题:
双线脚本
前言:现在的网站肯定都要考虑电信和网通的双线问题。有钱的就直接租一个双线机房BGP双线融合,没钱的就只有自己利用路由来做双线。以下是我用的双线脚本。
#/bin/sh
############################
##
##
## Time : 2007-8-11
## File: router.sh
##
############################
CNC_IP1="60.28.241.136"
CNC_NET="60.28.241.0"
CNC_WAY="60.28.241.218"
TELECOM_IP1="192.168.20.97"
TELECOM_NET="192.168.20.0"
TELECOM_WAY="192.168.20.1"
#load module
/sbin/depmod -a
/sbin/modprobe ip_tables
/sbin/modprobe ip_conntrack
/sbin/modprobe iptable_filter
/sbin/modprobe iptable_nat
/sbin/modprobe ipt_limit
/sbin/modprobe ipt_state
/sbin/modprobe ip_conntrack_ftp
#open forward ..ip....
/bin/echo "1" >/proc/sys/net/ipv4/ip_forward
#set forward rule
/sbin/iptables -t nat -A POSTROUTING -o eth0 -s 221.238.22.0/24 -j MASQUERADE
/sbin/iptables -t nat -A POSTROUTING -o eth1 -s 60.28.241.0/24 -j MASQUERADE
#ip rule .......
/sbin/ip rule add from $CNC_IP1/32 table wangtong1 pref 10
/sbin/ip rule add from $TELECOM_IP1/32 table dianxin1 pref 30
echo "ip roule add is finished"
/sbin/ip rule add to $CNC_NET/24 table main pref 3
/sbin/ip rule add to $TELECOM_NET/27 table main pref 4
#set route.........
/sbin/ip route add from $CNC_IP1/32 via $CNC_WAY table wangtong1
/sbin/ip route add from $TELECOM_IP1/32 via $TELECOM_WAY table dianxin1
#........
/sbin/ip route add default equalize nexthop via $CNC_WAY dev eth1 nexthop via $TELECOM_WAY dev eth0
#....
/sbin/ip route flush cache
###########################################
#vi /etc/iproute2/rt_tables
##1 inr.ruhep
#10 wangtong1
#30 dianxin1
#
############################################
本文来自ChinaUnix博客,如果查看原文请点:
http://blog.chinaunix.net/u/26011/showart_409481.html
欢迎光临 Chinaunix (http://bbs.chinaunix.net/)
Powered by Discuz! X3.2