How to retrieve the previous IP address for a web site

Moved your web site to a different server? Realized you forgot something after the DNS switched? Issue the following command from your computer's terminal to retrieve the previous IP address for site from the nameserver's cached A record entry:

 

Same nameservers?

dig some-domain.com A @ns1.current-nameserver.net

 

Different nameservers?

dig some-domain.com A @ns1.the-old-nameserver.net

 

The IP address will be in the "ANSWER SECTION"

 

;; ANSWER SECTION:
some-domain.com. 86400 IN A 11.222.33.444
 
(where 11.222.33.444 is the IP)
 
 
 
Then, you must edit your hosts file (in /etc/hosts) to point the domain to the old server. Add a line in it like this:
 
11.222.33.444     some-domain.com www.some-domain.com
 
(Please google "how to edit hosts file" if you are unfamiliar with this process.)
 
Now, you can log in to the old server with the following command:
 
ssh username@some-domain.com
 
Your browser will also point to the old site, although you may have to clear your local DNS cache first. (Please google "how to clear local DNS cache" if you are unfamiliar with this) Restarting your computer will also do the trick.
 
Please note that the nameserver's old "A" record entry will not be cached forever. If the site has moved quite some time ago, this solution may not work for you, and you will have to contact your previous hosting provider.