有一个新的Azure Linux VM(Ubuntu 22.04 LTS x64),具有以下两个网络接口卡(NIC):
eth0
Mac Address: 00:22:48:8f:ba:bf
Private IPV4 Address: 10.0.0.4
Public IPV4 Address: 20.25.226.73
Private IPV6 Address: abc:abc:abc:abc::6
Public IPV6 Address: 2a01:111:f100:1000::9d37:d42b
eth1
Mac Address: 00:22:48:8f:64:21
Private IPV4 Address: 10.0.0.14
Public IPV4 Address: 172.183.16.91
Private IPV6 Address: abc:abc:abc:abc::16
Public IPV6 Address: 2603:1030:603::324
字符串
两个NIC都使用vnet子网10.0.0.0/24和abc:abc:abc:abc::/64,并且都使用允许22/80/443/3389/ICMP端口的防火墙入站规则。
根据在Azure Linux虚拟机(https://learn.microsoft.com/en-us/troubleshoot/azure/virtual-machines/linux-vm-multiple-virtual-network-interfaces-configuration?tabs=1subnet%2Cubuntu)中配置多个网络接口,我设置了以下/etc/netplan/50-cloud-init.yaml文件:
network:
ethernets:
eth0:
dhcp4: true
dhcp4-overrides: &id001
route-metric: 100
dhcp6: true
dhcp6-overrides: *id001
match:
driver: hv_netvsc
macaddress: 00:22:48:8f:ba:bf
set-name: eth0
routes:
- to: 10.0.0.0/24
via: 10.0.0.1
metric: 100
table: 200
- to: 0.0.0.0/0
via: 10.0.0.1
table: 200
routing-policy:
- from: 10.0.0.4/32
table: 200
- to: 10.0.0.4/32
table: 200
eth1:
dhcp4: true
dhcp4-overrides: &id002
route-metric: 200
dhcp6: true
dhcp6-overrides: *id002
match:
driver: hv_netvsc
macaddress: 00:22:48:8f:64:21
set-name: eth1
routes:
- to: 10.0.0.0/24
via: 10.0.0.1
metric: 200
table: 201
- to: 0.0.0.0/0
via: 10.0.0.1
table: 201
routing-policy:
- from: 10.0.0.14/32
table: 201
- to: 10.0.0.14/32
table: 201
version: 2
型
在应用上面的yaml文件之后,两个IPV4地址上的一切都运行良好,例如相互ping并将网站链接到它们。
对于公共IPV6地址,事情很复杂。正如《What is IPv6 for Azure Virtual Network》中的限制部分所述(https://learn.microsoft.com/en-us/azure/virtual-network/ip-services/ipv6-overview):“ICMPv 6 is not currently supported in Network Security Groups.”我们不能使用“ping 6”命令,但需要使用其他方法来测试公共IPV6地址的可用性。其中一种方法是使用“telnet-6\f25 ipv6.telnetmyip.com-6”命令。
1.我们用eth0信息登录SSH shell(类似于Xshell)(先登录public IPV4,然后尝试public IPV6),输入“telnet -6 ipv6.telnetmyip.com”,它都响应:
Trying 2600:1f16:227:6200::100...
Connected to ipv6.telnetmyip.com.
The escape character is '^]'.
{
"comment": "## Your IP Address is 2a01:111:f100:1000::9d37:d42b (51152) ##",
"family": "ipv6",
"ip": "2a01:111:f100:1000::9d37:d42b",
"port": "51152",
"protocol": "telnet",
"version": "v1.3.0",
"website": "https://github.com/packetsar/checkmyip",
"sponsor": "Sponsored by ConvergeOne, https://www.convergeone.com/"
}
Connection closed by foreign host.
型
很好,系统在公共IPV6地址eth0下运行良好。这意味着我不需要修改YAML文件中的任何eth0。
1.我们使用eth 1 public IPV4登录到SSH shell(类似于Xshell),并输入“telnet -6 ipv6.telnetmyip.com”,它会响应:
Trying 2600:1f16:227:6200::100...
Connected to ipv6.telnetmyip.com.
The escape character is '^]'.
{
"comment": "## Your IP Address is 2a01:111:f100:1000::9d37:d42b (55926) ##",
"family": "ipv6",
"ip": "2a01:111:f100:1000::9d37:d42b",
"port": "55926",
"protocol": "telnet",
"version": "v1.3.0",
"website": "https://github.com/packetsar/checkmyip",
"sponsor": "Sponsored by ConvergeOne, https://www.convergeone.com/"
}
Connection closed by foreign host.
型
糟糕!它不识别eth 1的公共IPV6地址,而是使用eth0的公共IPV6地址
那么,如何编辑YAML文件以使eth 1的公共IPV6地址可用?
(我试着把问题交给ChatGPT 4和Claude 2,但他们的答案都不起作用。
1条答案
按热度按时间62lalag41#
经过多次尝试,我想我已经找到了解决办法。下面是修改后的YAML文件:
字符串
正如我前面所评论的,“telnetmyip.com”将始终使用eth0,无论是在IPV4还是IPV6上。因此,我更改为将域名链接到eth0和eth 1上的IPV4和IPV6地址,例如“eth0ipv4.example.com”,“eth0ipv6.example.com”,“eth1ipv4.example.com”和“eth1ipv6.example.com”。此外,我在Windows客户端机器上使用PsPing方法(https://learn.microsoft.com/en-us/sysinternals/downloads/psping)来测试此Ubuntu Server(22.04 LTS)。
现在让我们看看结果。
1.在IPV4上PsPing eth0
型
2.在IPV6上PsPing eth0
型
3.在IPV4上PsPing eth 1
型
4.在IPV6上PsPing eth 1
型
现在一切都很好!