无法通过网络连接到 Azure Linux 虚拟机解决方案

网友投稿 327 2022-09-28

无法通过网络连接到 Azure Linux 虚拟机解决方案

​本文将介绍网络错误阻止连接到 Azure Linux 虚拟机的问题。

问题现象

Azure Linux 虚拟机上的主接口 (VM) eth0。 如果未配置 eth0,则不能通过网络连接访问 VM,即使其他工具指示 VM 已启动。

出现问题时,安全命令行管理 (SSH) 具有正确权限的连接可能会开始连接到 VM。 但是,由于网络问题,它最终无法访问 VM。

网络错误通常记录在串行控制台日志中。 具体而言,您可能会看到以下错误。

串行控制台日志中的错误

CentOS Linux 分发错误

错误 1Bringing up interface eth0:Device eth0 does not seem to be present, delaying initialization.[FAILED]

错误 2Bringing up loopback interface: [ OK ]Bringing up interface eth0: Device eth0 has different MAC address than expected, ignoring.[FAILED]

错误 3YYYY/MM/DD HH:MM:SS Discovered Windows Azure endpoint: ###.##.###.##/usr/sbin/waagent:2275: DeprecationWarning: BaseException.message has been deprecated as of Python 2.6Error('socket IOError ' + e.message + ' args: ' + repr(e.args))YYYY/MM/DD HH:MM:SS ERROR:socket IOError args: (113, 'No route to host')YYYY/MM/DD HH:MM:SS ERROR:socket IOError args: (113, 'No route to host')Failed services in runlevel 3:network错误 4

login: YYYY/MM/DD HH:MM:SS ERROR:timed outYYYY/MM/DD HH:MM:SS ERROR:Traceback (most recent call last):YYYY/MM/DD HH:MM:SS ERROR: File "/usr/sbin/waagent", line 3395, in DoDhcpWorkYYYY/MM/DD HH:MM:SS ERROR: receiveBuffer = sock.recv(1024)YYYY/MM/DD HH:MM:SS ERROR:timeout: timed outYYYY/MM/DD HH:MM:SS ERROR:YYYY/MM/DD HH:MM:SS DoDhcpWork: Setting socket.timeout=10, entering recvYYYY/MM/DD HH:MM:SS ERROR:timed outYYYY/MM/DD HH:MM:SS ERROR:Traceback (most recent call last):YYYY/MM/DD HH:MM:SS ERROR: File "/usr/sbin/waagent", line 3395, in DoDhcpWorkYYYY/MM/DD HH:MM:SS ERROR: receiveBuffer = sock.recv(1024)YYYY/MM/DD HH:MM:SS ERROR:timeout: timed outCustomer changed the IP from DHCP to FIXED

​SUSE Linux 分发错误

Setting up (localfs) network interfaces: lo lo IP address: 127.0.0.1/8 IP address: 127.0.0.2/8 done eth4 No configuration found for eth4unused Waiting for mandatory devices: eth0 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 eth0 No interface found

​Ubuntu

错误 1cloud-init-nonet waiting 120 seconds for a network device.cloud-init-nonet gave up waiting for a network device.ci-info: lo : 1 127.0.0.1 255.0.0.0 .ci-info: eth1 : 0 . . 00:0d:3a:10:6a:53route_info failedWaiting for network configuration...Waiting up to 60 more seconds for network configuration...Booting system without full network configuration...错误 2ci-info: | eth0 | False | . | . | 00:0d:3a:21:f9:ad |ci-info: +--------+-------+-----------+-----------+-------------------+ci-info: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!Route info failed!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

i=eth0x=0ifdown eth0

ifdown: interface eth0 not configured

ifup eth0

Missing required variable: addressMissing required configuration variables for interface eth0/inet.Failed to bring up eth0.

exit 0x\

解决方案

对于 CentOS

从 下的 ifcfg-eth0 文件中删除 HWADDR 指令 /etc/sysconfig/network-script 。

对于 SUSE Linux

在 下删除包含 eth0 或 eth1 条目的文件 /etc/udev/rules.d 。

对于 Ubuntu

错误 1

此错误指示配置了 aneth1 接口而不是 eth0。 如果 VM 上的操作系统未安装 udev 的一些更新,则可能会发生这种情况。 在这种情况下 ,udev 错误地保存了以前的网络接口。 当调整 VM 大小或移动 VM 时,它将收到一个不同的 MAC 地址,该地址将分配给 eth1。

若要解决此问题,请将操作系统磁盘附加到另一个正在运行的 VM,然后删除 下的 udev 规则文件 /etc/udev/rules.d/70-persistent-net.rules 。若要在将来避免此问题,我们建议在 VM 上更新 udev 程序包。 例如,运行以下命令:

sudo apt-get update

sudo apt-get install udev

错误 2

若要解决此问题,请将 /etc/network/interfaces.d/eth0.cfg 文件重置为默认值,并请求 Azure DHCP 获取 IP 地址。 然后,删除文件夹中 /var/lib/dhcp 包含缓存 DHCP 设置的文件。 以下是默认 eth0.cfg 文件的示例:

#The primary network interface

auto eth0iface eth0 inet dhcp

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:无法使用 SSH 连接Azure Linux 虚拟机
下一篇:微服务间调用Retrofit在Spring Cloud Alibaba中的使用
相关文章

 发表评论

暂时没有评论,来抢沙发吧~