Why Can't My Linux ECS Obtain Metadata?
Symptom
The security group of the Linux ECS has been configured based on the prerequisites in Obtaining Metadata in the outbound direction, but the ECS still cannot obtain the metadata through the route with the destination of 169.254.169.254.
Root Cause
Run the following command on the Linux ECS configured with a static IP address:
# ip route| grep 169.254
The route with the destination of 169.254.169.254 does not exist, but the route with the destination of 169.254.0.0/16 exists.
After the network is restarted, the original route with the destination of 169.254.169.254 is changed to the route with the destination of 169.254.0.0/16 without a next hop, as shown in Figure 1. As a result, the Linux ECS cannot obtain metadata.
Solution
- Add the route with the destination of 169.254.169.254, and specify the next hop (gateway) and the output device (primary NIC of the Linux ECS). The following is an example:
# ip route add 169.254.169.254 via 192.168.1.1 dev eth0
192.168.1.1 is the gateway address of the subnet that the primary NIC resides, and eth0 is the primary NIC.
- Run the following command to verify that the metadata can be obtained:
Figure 2 Obtaining metadata
- Run the following command to create or modify the /etc/sysconfig/network-scripts/route-eth0 file to prevent the static route from being changed after network restart:
# vi /etc/sysconfig/network-scripts/route-eth0
Add the following content to the file:
In this example, the primary NIC is eth0 and gateway address is 192.168.1.1. Replace them based on site requirements.
# 169.254.169.254 via 192.168.1.1
How Do I View the Primary NIC?
- Log in to the management console.
- Click in the upper left corner and select your region and project.
- Under Compute, click Elastic Cloud Server.
- Click the name of the target ECS.
The page providing details about the ECS is displayed.
- Click the Summary tab to view details about the primary NIC.
Figure 3 Primary NIC details
How Do I View the Gateway Address?
- Log in to the management console.
- Click in the upper left corner and select your region and project.
- Under Compute, click Elastic Cloud Server.
- Click the name of the target ECS.
The page providing details about the ECS is displayed.
- Click the VPC name to go to the VPC list page.
Figure 4 VPC name
- Locate the row that contains the target VPC and click the number in the Subnets column to go to the subnet list page.
Figure 5 Number in the Subnets column
- Click the target subnet name to go to the subnet details page and view the gateway address.
Figure 6 Gateway address
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot