简体   繁体   English

Azure 的自定义映像 VM 上没有 Internet

[英]No Internet on Custom Image VM for Azure

I launched an Ubuntu 18.04 VM with Azure.我使用 Azure 启动了一个 Ubuntu 18.04 VM。 I installed a bunch of stuff that I need.我安装了一堆我需要的东西。 Then, I used the dashboard to create a custom image from this machine.然后,我使用仪表板从这台机器创建了一个自定义图像。 After that, I checked that the image was okay by launching some machines with that image.之后,我通过启动一些带有该图像的机器来检查图像是否正常。 Everything seemed to be working fine.一切似乎都运行良好。

Today, I launched a new instance with my custom image.今天,我用我的自定义镜像启动了一个新实例。 Then I tried to install a few things with apt-get install and I get the following error (eg for unzip):然后我尝试使用apt-get install一些东西,但出现以下错误(例如解压缩):

sudo: unable to resolve host ABCDEFG: Resource temporarily unavailable
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package unzip is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'unzip' has no installation candidate

This same thing happens for any package I try to install.我尝试安装的任何软件包都会发生同样的事情。 After testing some basic things with my repositories, I checked the internet connection with ping.在用我的存储库测试了一些基本的东西后,我用 ping 检查了互联网连接。 Eg ping www.google.com which is also not working.例如, ping www.google.com也不起作用。 I launched a vanilla Ubuntu 18.04 instance and I am not having these problems with that machine.我启动了一个 vanilla Ubuntu 18.04 实例,但那台机器没有这些问题。

I have also tried sudo reboot but no luck with that.我也试过sudo reboot但没有运气。 I did notice that when the system booted it shows the following error, also indicating that something is wrong with the internet:我确实注意到,当系统启动时,它显示以下错误,这也表明 Internet 出现了问题:

Failed to connect to https://changelogs.ubuntu.com/meta-release-lts. Check your Internet connection or proxy settings

Any help is greatly appreciated.任何帮助是极大的赞赏。

So, after some digging around, I found this answer to something similar: https://askubuntu.com/questions/1045278/ubuntu-server-18-04-temporary-failure-in-name-resolution . 因此,在深入研究之后,我找到了类似答案: https : //askubuntu.com/questions/1045278/ubuntu-server-18-04-temporary-failure-in-name-resolution

I used the following command and the internet started working again: 我使用了以下命令,互联网再次开始工作:

sudo ln -s ../run/systemd/resolve/stub-resolv.conf /etc/resolv.conf

This is a little different than the answer on askubuntu because this is on an Azure image. 这与askubuntu的答案有些不同,因为它在Azure映像上。 First, I noticed that my image was missing resolv.conf in /etc . 首先,我注意到我的映像在/etc丢失了resolv.conf Using ls -la /etc/resolv.conf on a different azure image, I saw that it was a symbolic link to ../run/systemd/resolve/stub-resolve.conf , so I created a link that matched this format on my machine and that fixed things. 在不同的蔚蓝图像上使用ls -la /etc/resolv.conf时,我看到它是到../run/systemd/resolve/stub-resolve.conf的符号链接,因此我创建了一个与该格式匹配的链接我的机器和固定的东西。

** EDIT ** It's worth noting that when you deprovision the VM to create the custom image, it does say: ** 编辑 **值得注意的是,当您取消配置VM以创建自定义映像时,它会说:

WARNING! 警告! The waagent service will be stopped. waagent服务将停止。

WARNING! 警告! Cached DHCP leases will be deleted. 缓存的DHCP租约将被删除。

WARNING! 警告! root password will be disabled. root密码将被禁用。 You will not be able to login as root. 您将无法以root用户身份登录。

WARNING! 警告! /etc/resolv.conf will be deleted. /etc/resolv.conf将被删除。

WARNING! 警告! xxxx account and entire home directory will be deleted. xxxx帐户和整个主目录将被删除。

When you create the custom image follow the step Deprovision the VM in the Azure VM, it will remove the file /etc/resolv.conf , so when you create a new Azure VM from the custom image, it cannot resolve the Domain name. 创建自定义映像时,请按照在Azure VM中取消配置VM的步骤进行操作,它将删除文件/etc/resolv.conf ,因此从自定义映像创建新的Azure VM时,它将无法解析域名。

Hope this will help you to understand it. 希望这会帮助您理解它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM