公网网卡上加绑一个教育网ip以及策略路由
公司某个保密项目需要打通一条从教育网到网通、电信乃至于国外的更宽广、通畅的道路
于是就从教育网拉了根儿光纤到某个非教育网的机房
然后在这个机房的某些机器的公网交换机端口上同时配上了教育网和以前公网地址的vlan的trunk
按照以前的文章http://www.haw-haw.org/node/5
很容易就在公网网卡上配上了教育网和以前公网网段的ip地址
剩下就只是策略路由的事情了
而这个策略路由的需求比较简单
只是需要把从哪个设备来的包还从哪个设备上回过去就ok了
假设公网网卡设备是eth0
教育网和原来公网网段的vlan id分别是100和101
那么教育网和原来公网的网络设备就分别是eth0.100和eth0.101
教育网和原来公网的ip分别是a.b.c.d和e.f.g.h
default gw分别是a.b.c.254和e.f.g.254
然后,先添加2张路由表edu和other
(这里的优先级100和101跟上面的vlan id没有关系,可以随便取,只要不跟已有的重就行)
echo -e “100\tedu\n101\tother” >> /etc/iproute2/rt_tables
接着,配置好新加的两张路由表edu和other
ip route add a.b.c.0/24 dev eth0.100 src a.b.c.d table edu
ip route add default via a.b.c.254 table edu
ip route add e.f.g.0/24 dev eth0.101 src e.f.g.h table other
ip route add default via e.f.g.254 table other
最后,再配上路由选择的策略
ip rule add from a.b.c.d table edu
ip rule add from e.f.g.h table other
于是一切ok了
最后把这几条命令写入/etc/rc.d/rc.local里
(因为最后没有找到改哪个配置文件可以实现以上命令的功能,所以只有写道rc.local里了)
原创文章,转载请注明: 转载自嘻嘻哈哈的部落格(blog)
本文链接地址: 公网网卡上加绑一个教育网ip以及策略路由



近期评论