When a subnet is associated with a NAT gateway, and the CVM in the subnet has a public network IP address (or an EIP), the CVM accesses the Internet through the NAT gateway by default because the priority of the exact match route is higher than that of the public network IP. However, you can set a routing policy to allow the CVM to access the Internet through its public network IP.
Directions
- Ensure that a routing policy that points to the NAT gateway exists so that CVMs in the subnet that have no public network IP can still access the Internet through the NAT gateway. Cloud servers within the subnets associated with this route table that do not have public IP addresses can still access the Internet via the NAT Gateway and will not be affected.
- Add a new routing policy with the Next Hop Type as Public Network IP of Cloud Virtual Machine and enter the Destination.
- Destination: Enter the specific public network IP range or default route to be accessed by the service (0.0.0.0/130618222416261120, where default route indicates that if the destination is not in the routing table, all data packets will use this default route).
- Next hop type: public IP of the cloud server.
Note:
- This routing policy, when configured with routing rules that have the same destination as the original ones pointing to the NAT Gateway or CVM, will always match this route preferentially.
- This routing policy will affect all subnets associated with this route table (please confirm the impact of this operation). Specifically, cloud servers within these subnets that have public IP addresses (or elastic IPs) will access the Internet via their public IPs instead of through the NAT Gateway.
- Cloud servers within the subnets associated with this route table that do not have public IP addresses can still access the Internet via the NAT Gateway and will not be affected.