At a DNS technical level, sure you can have:
*.example.com. IN CNAME example.com.
Although a better configuration would be:
@ IN SOA ( ... )
IN A n.n.n.n ; put your server IP here
www IN A n.n.n.n ; and here
* IN CNAME www
That will ensure that people doing a lookup for the
MX records of
foo.example.com don't get an unexpected answer.
However if your web server isn't set up to expect the wildcarded host names that people start using to point at, they'll just get error pages.
For that to work you need something like:
and that has to be in the main config, not in a
Alternatively, if the intent is that all wildcard subdomains end up at the same site, use an HTTP-level redirect such that all URLs end up with the client redirected to a preferred canonical URL (e.g. either
www or the one without any prefix)