【问题标题】:linux route specific machine traffic throw specific output interface [closed]linux路由特定机器流量抛出特定输出接口[关闭]
【发布时间】:2023-03-21 01:50:01
【问题描述】:

我有一台 linux 机器,我将其用作具有多个接口和多个 Internet 连接的路由器 说 eth0--isp1

eth1--isp2

eth2--isp3

网关是eth0 throw isp1

和 eth3--local1 10.0.0.x

eth4--local2 192.168.1.x

我需要 local1 ip 192.168.1.10 去抛出 isp3, eth2

谢谢

【问题讨论】:

    标签: linux ubuntu routing routes iptables


    【解决方案1】:

    您需要为此使用策略路由。您创建一个新的路由表并在源 IP 为 192.168.1.10 时使用它。

    ip route add ... table $TABLENUM                  # your usual routes, for the new table
    ...
    ip route add default via $ISP3 table $TABLENUM    # gateway for the new table
    ip rule add from 192.168.1.10/32 lookup $TABLENUM # use the new table for this IP
    ip rule add to 192.168.1.10/32 lookup $TABLENUM   # make it symmetric, for clarity
    

    【讨论】:

    • 确实如此,但您首先需要通过编辑文件 /etc/iproute2/rt_tables 来创建表
    【解决方案2】:

    试试route add 192.168.1.0 netmask 255.255.255.0 dev eth4--local,假设这些是本地连接的网络。如果没有,您还需要指定一个网关机器来路由数据包。老实说,您的问题格式不正确(并且可能属于服务器故障)。如果您已经在这些网络上拥有地址,则这些路由应该已经存在。否则,您的问题可能比您想象的要复杂。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-11-30
      • 1970-01-01
      • 2015-04-06
      • 1970-01-01
      • 2021-12-19
      • 1970-01-01
      • 2022-07-09
      • 2018-05-04
      相关资源
      最近更新 更多