V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
gearfox
V2EX  ›  宽带症候群

Linux 多线接入路由器设置求教

  •  
  •   gearfox · 2020-02-24 14:57:13 +08:00 · 1020 次点击
    这是一个创建于 1528 天前的主题,其中的信息可能已经有所发展或是发生改变。
    想用 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


    还有个问题,请问如何匹配电信、联通、移动的路由表,实现内网访问某运营商,走特定线路呢?
    谢谢大家了。
    gearfox
        1
    gearfox  
    OP
       2020-02-24 20:36:05 +08:00
    再求一次
    JackMa888
        2
    JackMa888  
       2020-02-27 16:11:16 +08:00
    route add -net 192.168.1.0 netmask 255.255.255.0 gw 192.168.1.254 eth0
    route add -net 22.22.22.22 netmask 255.255.255.0 ge 22.22.22.1 eth1
    route add default gw 22.22.22.1 eth1
    指定网关即可!
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1021 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 23:41 · PVG 07:41 · LAX 16:41 · JFK 19:41
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.