Accessing your website before DNS propagates


#1

Many people want to access their newly hosted website at dreamhost either before changing the DNS records to point at dreamhost, or before the DNS records have been fully propagated through the net. The end result is that they want to access their domain “foobar.com” before “foobar.com” points at the correct IP address.

Well, you can do this sometimes by editing the hosts file on your system. Steps for windows if your domain was called “foobar.com”.

  1. get the IP address of your domain at dreamhost.

C:>nslookup
Default Server: merry.christmas
Address: 192.168.0.254

[quote]lserver ns2.dreamhost.com
[/quote]

Default Server: ns2.dreamhost.com
Address: 66.201.54.66

[quote]foobar.com
[/quote]

Server: ns2.dreamhost.com
Address: 66.201.54.66

Name: foobar.com
Address: 66.33.209.28

[quote]exit
[/quote]

C:>

The returned IP address for your domain “foobar.com” at dreamhost is “66.33.209.28”.

Note that the nameservers at dreamhost seem to be pretty flaky and often return errors. If ns2 doesn’t work, try again and again or change the lserver to ns1 or ns3.

  1. open the hosts file to edit it. On Windows XP this is found by default at: c:\windows\system32\drivers\etc\hosts

Open it in notepad and then add the following lines to the end of the file…
<yourdomain.com>
<www.yourdomain.com>

e.g. for the previous domain example it would be:

66.33.209.28 foobar.com
66.33.209.28 www.foobar.com

Save and close the file. You should then be able to access the new site hosted at dreamhost using the domain name “foobar.com”.

Note that this will prevent you from accessing the current “foobar.com” at the current host. You will need to comment out or delete those lines from the hosts file to see it again.

Note that you should also delete those lines once it is available via the normal DNS system, otherwise Murphy’s Law ensures that something will happen which will make you wish that you did.

Also note that if your site never actually references it’s own domain name (i.e. there are no links to foobar.com, just to relative paths like / or /pr0n) then you may be able to add the entries in the hosts with a madeup name and access both sites simultaneously. e.g.

66.33.209.28 foobar-new.com
66.33.209.28 www.foobar-new.com

I’m not making any guarantees that this will actually work for you, although it does for me.

B


#2

It’s a great tips.

I used it when i wanted to make/test a website in real conditions (path, sql access…) without changing dns.

Then, when everything was ready, i just changed dns, and everyone saw the new website.

DNS propagation take in practice usually less than 1 hour.

Get [color=#CC0000]$97[/color] Off with promo code [color=#6600CC]97DREAM[/color] :cool:


#3

That seems awfully complicated. Much easier to create a subdomain of foobar.dreamhosters.com that mirrors foobar.com. That way you can include absolute links when you need to that point to http://foobar.dreamhosters.com.


#4

And those links don’t work when you stop using foobar.dreamhosters.com whereas with the hosts file it works for both server side domain lookup (as dreamhost servers use their own DNS for your domain) and with client-side lookup because you have overridden the domain. It’s all good.