想用 centos 搭个软路由,不想使用现有的软路由程序,查了下需要策略路由来实现,配了下没有通,请大家看看
比如服务器 4 个网卡接口,虚拟机拓扑为:
内网 192.168.1.254 网关是自身 网卡 eth0
电信 22.22.22.22 网关 22.22.22.1 网卡 eth1
联通 33.33.33.33 网关 33.33.33.1 网卡 eth2
移动 44.44.44.44 网关 44.44.44.1 网卡 eth3
/etc/iproute2/rt_tables 设置
100 LAN
101 Telecom
102 Unicom
103 Mobile
#内网
这里内网如何写规则呢??
#电信线路
/etc/sysconfig/network-scripts/route-eth1
default via 22.22.22.1 src 22.22.22.22 dev eth1 table Telecom
/etc/sysconfig/network-scripts/rule-eth1
from 22.22.22.22 table Telecom
#联通线路
/etc/sysconfig/network-scripts/route-eth2
default via 33.33.33.1 src 33.33.33.33 dev eth2 table Unicom
/etc/sysconfig/network-scripts/rule-eth2
from 33.33.33.33 table Unicom
#移动线路
/etc/sysconfig/network-scripts/route-eth3
default via 44.44.44.1 src 44.44.44.44 dev eth3 table Mobile
/etc/sysconfig/network-scripts/rule-eth3
from 44.44.44.44 table Mobile
还有个问题,请问如何匹配电信、联通、移动的路由表,实现内网访问某运营商,走特定线路呢?
谢谢大家了。
比如服务器 4 个网卡接口,虚拟机拓扑为:
内网 192.168.1.254 网关是自身 网卡 eth0
电信 22.22.22.22 网关 22.22.22.1 网卡 eth1
联通 33.33.33.33 网关 33.33.33.1 网卡 eth2
移动 44.44.44.44 网关 44.44.44.1 网卡 eth3
/etc/iproute2/rt_tables 设置
100 LAN
101 Telecom
102 Unicom
103 Mobile
#内网
这里内网如何写规则呢??
#电信线路
/etc/sysconfig/network-scripts/route-eth1
default via 22.22.22.1 src 22.22.22.22 dev eth1 table Telecom
/etc/sysconfig/network-scripts/rule-eth1
from 22.22.22.22 table Telecom
#联通线路
/etc/sysconfig/network-scripts/route-eth2
default via 33.33.33.1 src 33.33.33.33 dev eth2 table Unicom
/etc/sysconfig/network-scripts/rule-eth2
from 33.33.33.33 table Unicom
#移动线路
/etc/sysconfig/network-scripts/route-eth3
default via 44.44.44.1 src 44.44.44.44 dev eth3 table Mobile
/etc/sysconfig/network-scripts/rule-eth3
from 44.44.44.44 table Mobile
还有个问题,请问如何匹配电信、联通、移动的路由表,实现内网访问某运营商,走特定线路呢?
谢谢大家了。