OK so I figured out that I was supposed to go to
Terminal/file/New Command to type in Camelot's code -
which I did, got the password prompt, wrote it, it
accepted it and came back with this: (the IP and name
below, I've changed for this post only)
"12.12.121.271 www.mycertainname.com">>/etc/hosts
[Process completed]
Hmm. That looks a little odd to me. First off, did you include the "
sudo echo" part at the beginning from Camelot's post? I'm also a little curious about the "[
process completed]" part. Usually, I come straight back to the prompt.
But when I now go to type in my staging site's name
in the browser, I get another web site which has the
same name, still can't access this site of mine.
I don't give my staging sites the same names, so I'm not sure how that would work if it had the same name as another site. For example, if I have a domain called "
mydomain.com," the real web server would be "
www.mydomain.com" and my staging server would be
something like "
staging.mydomain.com." That way, if I want to look at the real site, I type in one address. I type in the other if I want the staging server. You can't (easily) have the same text address (www.mydomain.com) resolve to different IP addresses. That requires some special DNS tricks that are beyond the abilities of the
/etc/hosts file.
At this point, re-run this Terminal command and post the results:
<pre class="command">cat /etc/hosts</pre>Also, I can't figure out how to do this from the Network Utility, but you can check and see where your Mac is getting its lookup information by using another Terminal program called
lookupd. You can also use it to flush the DNS cache, in case that's what's causing it to go to the other site. To flush the cache, type this in the Terminal at the prompt:
<pre class="command">sudo lookupd -flushcache</pre>You should just get the prompt back when it's done. There's no feedback.
To check where your Mac is getting its lookups, you use lookupd in an interactive mode. First, you type:
<pre class="command">lookupd -d</pre>At the prompt in the Terminal window. Then you'll get a few lines of text and a ">" prompt. Type "
hostWithName", then a space and your host's name, so it looks like this:
<pre class="command">> hostWithName: www.apple.com</pre>When you hit the enter key, it'll do the lookup and give you a few lines information:
<pre class="command">Dictionary: "DNS: host www.apple.com.akadns.net"
lookup_DNSdomain: apple.com.akadns.net
lookup_DNSserver: 208.67.222.222
lookup_DNS_time_tolive: 58
lookup_DNStimestamp: 1167796142
lookupagent: DNSAgent
lookup_infosystem: DNS
interface: 4
ip_address: 17.112.152.32
name: www.apple.com.akadns.net www.apple.com
+ Category: host
+ Time to live: 43200
+ Age: 0 (expires in 43200 seconds)
+ Negative: No
+ Cache hits: 0
+ Retain count: 4</pre>Notice how it mentions DNS servers in several places, including "
DNSAgent". That meant it used the DNS server at 208.67.222.222 to find the address for www.apple.com. Now, if I try it with a staging server (hosted on my iMac in this case), see what happens:
<pre class="command">> hostWithName: test.mydomain.com
Dictionary: "FF: host test.mydomain.com"
lookupagent: FFAgent
lookupvalidation: /etc/hosts 2 1166756640
ip_address: 127.0.0.1
name: test.mydomain.com
+ Category: host
+ Time to live: 43200
+ Age: 0 (expires in 43200 seconds)
+ Negative: No
+ Cache hits: 0
+ Retain count: 3</pre>Now, see how it says it looked it up using the
FFAgent (Flat File), and even says it got it from
/etc/hosts? If you're seeing anything except for
FFAgent, then it's not looking in
/etc/hosts for the info. There are ways to change the lookup order
lookupd uses, but I'm pretty certain it was already set to use the flat files before DNS way before Panther.
To quit the lookupd program, just type "
quit" at the prompt.
charlie