【问题标题】:Is that possible to add two different default gateways into the routing table for two different NICs in android?是否可以将两个不同的默认网关添加到 android 中两个不同 NIC 的路由表中?
【发布时间】:2011-08-23 02:55:29
【问题描述】:

默认情况下,默认连接的数据包将使用 eth0 出/入。 路由表中的默认网关是eth0的gw ip。

当另一个接口说 eth1 已启动时,我想为 eth1 添加另一个默认网关。 这在android中可能吗? 因为已经存在 eth0,所以我无法为 eth1 添加另一个默认网关。

感谢您的帮助。

【问题讨论】:

    标签: android routing iptables gateway nic


    【解决方案1】:

    默认网关只有一个,它是默认的。您可以有多个接口,每个接口都有不同的网关,但只有一个默认值(您的系统无法选择)。

    想象一下:

    eth0 - IP: 192.168.0.10/24 Gateway: 192.168.0.1
    eth1 - IP: 192.168.1.10/24
    

    您应该至少有 3 条路线(通常是自动的):

    To go to some IP on 192.168.0.0, go thru eth0.
    To go to some IP on 192.168.1.0, to thru eth1.
    To go to anywhere else, go thru 192.168.0.1.
    

    因此,您不需要多个默认网关。您可能想要的是特定路由的网关。假设您有网络192.168.2.0,只能通过使用192.168.1.1 的网关访问。通过上述配置,您的机器将尝试使用默认网关192.168.0.1。你可以使用类似的东西:

    route add -net 192.168.2.0 netmask 255.255.255.0 gw 192.168.1.1
    

    这样您将拥有 2 个网关,但默认只有 1 个。第二个仅用于 192.168.2.0 网络。

    【讨论】:

      【解决方案2】:

      它可以在 Windows 10 机器中使用,第二个作为软件接口处理并用于回退。我希望 android 也有这个功能,但每次我的电缆死掉以更改为 ADSL 时,我都必须手动更改它。

      【讨论】:

        猜你喜欢
        • 2019-11-20
        • 1970-01-01
        • 1970-01-01
        • 2016-11-27
        • 2018-10-20
        • 2022-01-20
        • 1970-01-01
        • 2019-09-13
        • 2015-06-08
        相关资源
        最近更新 更多