是否可以将两个不同的默认网关添加到android中两个不同网卡的路由表中?

发布于 2024-12-01 01:28:28 字数 162 浏览 5 评论 0原文

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

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

感谢您的帮助。

By default, the packets of default connection will use eth0 to go out/in.
The default gateway in the routing table is eth0's gw ip.

When another interface said eth1 is up, I want to add another default gateway for eth1.
Is that possible in android?
Since I cannot add another default gateway for eth1 because there already exists eth0's.

Thanks for your help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

是伱的 2024-12-08 01:28:28

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

想象一下:

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 网络。

A default gateway is only one, it's the default. You can have several interfaces each one with a different gateway, but only one default (your system cannot choose).

Imagine this:

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

You should have at least 3 routes (usually automatic):

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.

So you see, you don't need more than one default gateway. What you might want is a gateway for a specific route. Imagine that you have the network 192.168.2.0 that can only be reached by using gateway at 192.168.1.1. With the above configuration, your machine would try to use the default gateway 192.168.0.1. You could use something like:

route add -net 192.168.2.0 netmask 255.255.255.0 gw 192.168.1.1

This way you'll have a 2 gateways, but only 1 is the default. This second one is only used for 192.168.2.0 network.

烟织青萝梦 2024-12-08 01:28:28

它可以在 Windows 10 计算机中使用,第二个作为软件界面处理并用于后备。我希望 Android 也有这个功能,但每次我的电缆坏掉才能更改为 ADSL 时,我都必须手动更改它。

It is posible in a Windows 10 machine, the second is handled as a software interface and is used for fallback. I expected android to have this feature too but instead I have to change it manually every time my cable dies to change to ADSL.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文