Ubuntu – How to redirect subdomains without specify the domain

dnsUbuntu

Is there a way to redirect all my subdomains without specify the domain, I mean for example:

when I write www it should resolve to www.mydomain.com or if I write ftp it should redirect to ftp.mydomain.com

I know I could write wildcards in the hosts file but I'm not sure how to write something where the wildcard take the subdomain and concatenate it with mydomain.com

Best Answer

If www.mydomain.com already has correct dns info, you only have to add mydomain.com as a DNS search domain. See here for information on how to do it on Ubuntu.