I have created a virtual machine on Google Cloud, It was working fine until my account was disabled due to billing, after I re-enabled billing, My computing engine instance is became unreachable, Somehow I can access the instance via the serial port but I noticed that there is no internet access inside my virtual machine as well as it is unreachable using public IP address. Whenever I try to install any package or simply ping another domain or ip it says the destination is unreachable.
below are some logs from my VM instance for reference,
OSConfigAgent[38687]: 2024-10-27T09:10:02.0971Z OSConfigAgent Critical main.go:112: Error parsing metadata, agent cannot start: network error when requesting metadata, make sure your instance has an active network and can reach the metadata server: Get "http://169.254.169.254/computeMetadata/v1/?recursive=true&alt=json&wait_for_change=true&last_etag=0&timeout_sec=60": dial tcp 169.254.149.234:80: connect: network is unreachable
The issue with your Google Cloud VM instance likely stems from the network configuration resetting or being disabled when billing was interrupted. Here are steps to troubleshoot and restore network access to your instance:
1. Check Network Interface and Route Configuration
Access the VM via the serial console, and check if your network interface is configured correctly. Run the following commands:
ip a
ip r
Make sure your primary network interface (eth0 or equivalent) has an IP address assigned.
Ensure that there is a default route set up, pointing to the gateway IP. For Google Cloud VMs, the default gateway is typically 10.128.0.1 (or another IP if you are using a custom VPC).
If either the interface or the route is missing, Google Cloud’s DHCP might not be working correctly on your instance.
2. Restart the DHCP Client
If the interface exists but lacks an IP address, restarting the DHCP client may restore connectivity. Run:
sudo dhclient -r && sudo dhclient
Check ip a again to confirm if an IP address is assigned.
3. Verify Firewall Rules and Network Tags
Go to your Google Cloud Console:
Navigate to VPC network > Firewall to ensure firewall rules allow ingress for SSH and any other necessary protocols.
If your instance uses network tags, confirm that firewall rules associated with those tags allow SSH (port 22) and ICMP (for ping).
4. Ensure External IP Address is Assigned
Go to the Compute Engine > VM instances page in Google Cloud Console:
Check if the instance has an External IP address assigned. If not, you may need to assign one manually.
If an IP address is assigned but unreachable, try releasing and then reassigning the external IP.
5. Verify Network Configuration on Google Cloud
Sometimes network interfaces or routing get disrupted after billing issues:
Go to VPC network > Routes in the Google Cloud Console and verify that your instance’s network has the default internet gateway route (typically 0.0.0.0/0).
Ensure the subnet associated with the VM has proper internet access permissions.
6. Restart the Instance
Once you’ve checked network configurations and firewall rules, restart your instance via the Compute Engine console.
7. Review OS Configuration Agent Logs
The logs show issues with the OS configuration agent not being able to reach the metadata server. To investigate further:
From the serial console, disable and then re-enable the OS Config Agent to see if it reinitializes network access:
sudo systemctl restart google-osconfig-agent
After following these steps, if the VM is still unreachable via public IP, you may need to contact Google Cloud Support to ensure that all network configurations were correctly restored post-billing reinstatement.