How does CloudStack assign public IPs to VMs? Is the public IP directly configured inside the VM?

Not necessarily.

In many CloudStack network configurations, the VM has a private address while CloudStack networking handles the relationship between the private VM IP and the public IP.

For example:


Internet
   ↓
Public IP
   ↓
CloudStack Network / Virtual Router
   ↓
Private VM IP
   ↓
VM

Depending on the configuration, CloudStack can provide services such as NAT, port forwarding and firewall rules.

So when troubleshooting public connectivity, don’t only inspect the VM’s network interface.