In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article to share with you is about how to do instance network card, Xiaobian think quite practical, so share to everyone to learn, I hope you can read this article after some harvest, not much to say, follow Xiaobian to see it.
How is the instance network card configured and pulled up? This is a critical step in understanding and using cloud-init well. Let's start with the simplest basic scenario: cloud-init is not installed in the mirror.
At this time, when instance starts, whether the network card can be pulled up depends entirely on luck! Yeah, it's luck.
Because the configuration of the network card in this case is dead, it depends entirely on the original configuration of/etc/network/interfaces in the image. For example, the configuration in the original image is:
auto eth0
iface eth0 inet dhcp
instance A network card can only be pulled up if all of the following conditions are met:
There's just one card.
It just so happens that the network card is called eth0
Subnet has DHCP enabled.
Failure will occur if any of the following conditions occur:
There are other network cards, such as eth2, or
The network card is not called eth0, such as ens3, or
no DHCP
The network configuration of different instances varies greatly. The method of writing dead in image is almost invalid. It can only be written dynamically by cloud-init. Next, we analyze the solution of cloud-init in detail.
dhcp
Consider first the case where subnet has DHCP service.
The image we use is ubuntu cloud image, already preinstalled cloud-init, download address is http://cloud-images.ubuntu.com/, domestic image mirrors.ustc.edu.cn/ubuntu-cloud-images/
After successful deployment, login instance, ip a shows that the network card ens3 has been configured correctly.
The following is an analysis of how this IP is configured.
As discussed in the previous section, cloud-init is the local phase of network configuration. The execution of cloud-init is documented in detail in/var/log/cloud-init.log. Let's look for related operations.
Here you can see that cloud-init does the following:
① Scan all the network cards in instance (here is ens3)
② Obtain the configuration information of the network card. Because there is no config drive, you cannot know the detailed configuration information of the network card. You can only use the default fallback configuration, that is, dhcp configuration.
③ Write the configuration information to/etc/network/interfaces.d/50-cloud-init.cfg, the content is:
In this way, the network card is pulled up in dhcp mode, which is just connected to the dhcp service of subnet, and the IP, gateway and other information are matched.
A few notes:
Every NIC on instance is scanned by cloud-init.
If there is no config drive, the fallback configuration will be adopted, and the first (and only) NIC scanned will be configured to dhcp mode. Note: This is the default behavior of cloud-init, and it has nothing to do with whether DHCP is enabled on the subnet corresponding to this NIC.
cloud-init generates a network card configuration file based on the instance operating system type. For example, if the operating system is centos, the configuration will be written to the/etc/sysconfig/network-scripts directory.
The above is how to do the instance network card, Xiaobian believes that some knowledge points may be what we will see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.