You just use a wildcard dns record, and then the webserver uses the host header to determine which subdomain was used (for webservers at least).