gpt4 book ai didi

azure - 使用 Azure 中的第二个(或多个)NIC 访问互联网

转载 作者:行者123 更新时间:2023-12-02 06:16:01 24 4
gpt4 key购买 nike

我在 Azure 中有一个虚拟机,带有 Ubuntu 19.04 和 4 个网卡,每个网卡都附加了一个公共(public) IP,作为示例,这是第二个网卡:

enter image description here

如您所见,它的公共(public) IP 为 191.234.186.19。

我的目标是能够从具有不同 IP 地址的每个 NIC 访问互联网,但在虚拟机内部我只能使用第一个网络 eth0 访问它。

查看#route -n我得到以下输出:

Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 10.0.0.1 0.0.0.0 UG 100 0 0 eth0
10.0.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
10.0.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth2
10.0.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth3
10.0.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
168.63.129.16 10.0.0.1 255.255.255.255 UGH 100 0 0 eth0
169.254.169.254 10.0.0.1 255.255.255.255 UGH 100 0 0 eth0

我尝试使用以下命令为其他网卡添加路由:

sudo ip route add default via 10.0.0.1 dev eth1 metric 101
sudo ip route add default via 10.0.0.1 dev eth2 metric 102
sudo ip route add default via 10.0.0.1 dev eth3 metric 103

但我仍然无法使用这些网卡连接到互联网,只能使用 eth0

我错过了什么吗?我是否需要更改/配置其他任何内容才能使其正常工作?

为了完整起见,我使用此命令来测试连接:

curl --interface eth1 api.ipify.org?format=json -w "\n"

我的虚拟机与本文中的虚拟机相同:article

最佳答案

我怀疑你可能需要1) 为第二个、第三个和第四个接口(interface)定义新的路由表,2)将默认路由添加到这些表中3) 并定义规则以确保返回数据包始终路由回原始数据包发送的同一接口(interface)。

这里有一些示例供您引用(例如 thisthis )。

我只想指出几点,在针对您的具体情况进行设置时可能会有所帮助: iproute允许您维护多个路由表。要指示操作系统使用不同的路由表,您需要定义 rules在最简单的形式中,将强制使用与发起连接的接口(interface)相对应的路由表。

关于azure - 使用 Azure 中的第二个(或多个)NIC 访问互联网,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59112745/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com