You need to use DNS to have a domain name point to your server. You don't need to host your own DNS server though if you don't want to. The easiest alternative is to find a company like GoDaddy or Dotster, register a domain with them. In order for it to redirect to your site you have to give Dotster or Godaddy or whomever (called the registrar) your nameservers. The nameservers are DNS servers which take queries on a domain name, like
www.yahoo.com and return an IP, like 172.56.23.10.
The process then is the following, for having
www.mydomain.com point to your server.
- find out your server's IP
- register
www.mydomain.com with a registrar
- set up the nameservers which will contain a DNS entry translating
www.mydomain.com into your IP
- go to the registrar's page and set the name servers to be the ones you set up above
- wait up to 24 hours for DNS records throughout the internet to update
Obviously the tricky part involves the nameservers. but there's a really easy solution. For example, you can use
http://www.zoneedit.com
ZoneEdit will freely host your DNS entries in their nameservers, so you don't have to set up your own. Basically just create an account with them, they'll guide you through the process, it's simple. I've used them before with perfect service and uptime.
In order to host subdomains, like blog.mydomain.com you also use DNS. You create a DNS entry called an "Alias". You can do this in ZoneEdit as well, very quickly. It has a form where you type in the subdomain and the IP address (which again should be the same as your server's) which creates the Alias record. Obviously then you'll have
www.mydomain.com and blog.domain.com point to the same IP, thus the same server, hence the same page. Well, not necessarily. In web servers like IIS and Apache you use Host Headers to "route" this content. Basically when you create a website, under IIS for example, it allows you to specify a Host Header, such as blog.mydomain.com. Then you set that site's root folder to be the one where your blog is, and you're all set.