# vi /etc/sysconfig/network-scripts/route-eth1
gateway0=218.57.200.1
netmask0=255.255.255.0
address0=218.57.200.242
# vi /etc/sysconfig/networking/profiles/default/resolv.conf
nameserver 202.102.152.3
nameserver 202.102.128.68
三、配置路由表
# vi /etc/iproute2/rt_tables,增加网通和电信两个路由表
252 cnc
251 tel
设置网通的路由表
# ip route add 218.57.200.0/24 via 218.57.200.242 dev eth0 table cnc
# ip route add 127.0.0.0/8 dev lo table cnc
# ip route add default via 218.57.200.1 dev eth0 table cnc
设置电信的路由表
ip route add 222.173.254.0/24 via 222.173.254.21 dev eth1 table tel
ip route add 127.0.0.0/8 dev lo table tel
ip route add default via 222.173.254.17 dev eth1 table tel
制定策略,让222.173.254.21的回应数据包走电信的路由表路由,218.57.200.242的回应数据包走网通的路由表路由
ip rule add from 222.173.254.21 table tel
ip rule add from 218.57.200.242 table cnc
增加出口路由策略,客户端是网通的走网通线路,其余走电信线路。
ip rule add to 121.16.0.0/13 table cnc
ip rule add to 121.24.0.0/14 table cnc
ip rule add to 121.28.0.0/15 table cnc
ip rule add to 121.30.0.0/16 table cnc
ip rule add to 121.31.0.0/16 table cnc
其余省略...
刷新路由表
ip route flush cache
四、配置dns
在服务器上配置自己的dns解析,将域名服务器商处的域名解析指向服务器。
这样,来自网通的查询,将反馈网站网通的ip,其余反馈电信的ip。
配置named.conf
view "cnc" {
match-clients {121.16.0.0/13;121.24.0.0/14;121.28.0.0/15;121.30.0.0/16;121.31.0.0/16;121.47.0.0/16;121.76.0.0/16;121.77.0.0/16;122.192.0.0/14;122.198.192.0/18;123.199.128.0/20;124.108.40.0/21;124.128.0.0/13;124.160.0.0/16;124.161.0.0/16;124.162.0.0/16;124.163.0.0/16;其余省略...;}
recursion yes;
zone "zhyh.org" {
type master;
file "/var/named/zhyh.org.cnc";
};
};
view "other" {
match-clients { any; };
recursion no;
zone "zhyh.org" {
type master;
file "/var/named/zhyh.org";
};
};
配置zhyh.org.cnc,对应网通ip
$ttl 86400
@ in soa zhyh.org. root (
2006111800 ; serial
28800 ; refresh
14400 ; retry
3600000 ; expire
86400 ) ; minimum
in ns zhyh.org.
in a 218.57.200.242
in mx 10 mail
www in a 218.57.200.242
ns1 in a 218.57.200.242
ns in a 222.173.254.21
mail in a 218.57.200.242
1 in ptr localhost.
配置zhyh.org,对应电信ip
$ttl 86400
@ in soa zhyh.org. root (
2006111800 ; serial
28800 ; refresh
14400 ; retry
3600000 ; expire
86400 ) ; minimum
in ns zhyh.org.
in a 222.173.254.21
in mx 10 mail
www in a 222.173.254.21
ns in a 222.173.254.21
ns1 in a 218.57.200.242
mail in a 222.173.254.21
1 in ptr localhost.
配置222.173.254.zone、218.57.200.zone做反向解析;
$ttl 86400
@ in soa zhyh.org. root.zhyh.org. (
2006111813
3600
7200
3600000
86400 )
in ns localhost.
242 in ptr www.zhyh.org.
242 in ptr ns1.zhyh.org.
242 in ptr mail.zhyh.org.
五、配置apache,做好虚拟主机设置
# vi /usr/local/apache/conf/httpd.conf
namevirtualhost 218.57.200.242:80
namevirtualhost 222.173.254.21:80