Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I wished to run example.com on my local test server (Win XP). For this I was able to setup BIND and configured zones for example.com. The local DNS server and local Apache web server both work well. However when I try example.com on browser it takes me to the original example.com not to the local version.

So what am I missing here? Why can't example.com point to the local version in Apache.

zone record for example.com

$TTL 3h
example.com. IN SOA ns1.example.com. ns2.example.com. (
                          1        ; Serial
                          3h       ; Refresh after 3 hours
                          1h       ; Retry after 1 hour
                          1w       ; Expire after 1 week
                          1h )     ; Negative caching TTL of 1 hour

;
; Name servers
;
example.com.  IN NS  ns1.example.com.

;
; Addresses for the canonical names
;
localhost      IN A     127.0.0.1
ns1            IN A     192.168.1.2
  1. ISC BIND service is running.
  2. Apache is running.
  3. Dig @192.168.1.2 example.com - shows expected results.
  4. Changed my primary DNS to 192.168.1.2
  5. Not using any proxy. Everything works from the same box. Browser, DNS and Apache.

What to do to make local example.com work?

Update: I tried - nslookup example.com got the following response -

;; Got recursion not available from 192.168.1.2, trying next server
Server:         4.2.2.2
Address:        4.2.2.2#53

Non-authoritative answer:
Name:   example.com
Address: 208.77.188.166

For nslookup 192.168.1.2 I got -

;; Got recursion not available from 192.168.1.2, trying next server
;; Got recursion not available from 192.168.1.2, trying next server
Server:         4.2.2.2
Address:        4.2.2.2#53

** server can't find 2.1.168.192.in-addr.arpa.: NXDOMAIN

For Dig example.com, I got -

; <<>> DiG 9.6.1 <<>> example.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 494
;; flags: qr aa rd; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0
;; WARNING: recursion requested but not available

;; QUESTION SECTION:
;example.com.                   IN      A

;; AUTHORITY SECTION:
example.com.            3600    IN      SOA     ns1.example.com. ns2.example.com. 1 10800 3600 604800 3600

;; Query time: 15 msec
;; SERVER: 192.168.1.2#53(192.168.1.2)
;; WHEN: Sat Jul 04 17:05:05 2009
;; MSG SIZE  rcvd: 73
share|improve this question
    
Typo in the SOA, the second parameter, ns2.example.com in your case, should be a mailbox, for instance hostmaster.example.com. –  bortzmeyer Jul 6 '09 at 7:59

4 Answers 4

up vote 2 down vote accepted

is it possible that your web browser uses some proxy rather then direct internet connection?

probably not - but still worth asking.

what does your windows nslookup say when you fire it up on computer where you use web browser? does it say that 192.168.1.2 is one and only dns server? what happens when you type example.com as query ?

[edit: i'm blind.. this one should fix the problem] add

@ IN A 91.206.245.2
www IN A 91.206.245.2

to your bind zone file, change serial number and reload bind.

share|improve this answer
    
Connects directly to internet. I tried this - nslookup example.com, got the following response - ;; Got recursion not available from 192.168.1.2, trying next server Server: 4.2.2.2 Address: 4.2.2.2#53 Non-authoritative answer: Name: example.com Address: 208.77.188.166 –  Arpit Tambi Jul 4 '09 at 11:00
    
ok - temporarily kick out 4.2.2.2 from your list of dns'es [ if your bind is not accepting recursive queries you'll loose internet access ], then try again nslookup and see if your bind answers nicely. –  pQd Jul 4 '09 at 11:19
    
I removed 4.2.2.2, so now just have one primary DNS 192.168.1.2 in TCP/IP settings. The internet still works and now nslookup is showing a very different address in place of 4.2.2.2 (from Internet modem I guess) –  Arpit Tambi Jul 4 '09 at 11:31
    
I have added Dig example.com response above, if that helps. –  Arpit Tambi Jul 4 '09 at 11:36
    
yes - but your client computer still uses 4.2.2.2 - for time of the test remove 4.2.2.2 from list of dns servers and point only to your 192.168.1.2 as resolver. –  pQd Jul 4 '09 at 11:54

The DNS server you just installed and configured (BIND) is an authoritative name server. That's fine but you cannot use it as a recursive name server, which is what you did when you "Changed my primary DNS to 192.168.1.2". Hence, nslookup's screams "Got recursion not available from 192.168.1.2, trying next server".

An authoritative name server is... authoritative for some domains (here, example.com) but is not a general-purpose resolving server. For that, you need a recursive name server.

Two solutions:

  1. Make your BIND name server recursive for your local machine. (Basically, it means adding a recursion yes; in a view, or being sure that your BIND listens only on local IP addresses.) Note that it is bad practice to have a name server being both recursive and authoritative but, for a personal machine used only for tests, it is not a big deal.

  2. Tell the regular recursive that it must forwards requests for example.com for your machine. I cannot say more, it depends who manages it, what software it runs, etc.

share|improve this answer

I agree with pQd, you may also run a tool such as wireshark to see where it goes wrong.

share|improve this answer
    
assuming all happens on the same box [ that is apache, dns server and browser run on 192.168.1.2 ] wireshark will not be helpful. under windows - afaik - you cannot sniff on loopback. –  pQd Jul 4 '09 at 10:16
    
He would be able to be sure that no request goes to a proxy and that no dns request goes outside. –  radius Jul 4 '09 at 10:31
    
I ran wireshark but was not much helpful as I'm directly connected to the internet. –  Arpit Tambi Jul 4 '09 at 11:40
    
Running Wireshark for a simple configuration problem is immensely overkill. dig is enough. –  bortzmeyer Jul 6 '09 at 8:00
1  
Yep I agree, but when I posted there were not so many info in the question and we were even sure it was a dns problem. Anyway I'm a network guy and network guys (or me at least) love wireshark to troubleshot things running and server on which they can't connect ;) –  radius Jul 6 '09 at 8:33

If you are using proxy server then for a while disable proxy server and choose connect to internet directly and open example.com. (Do not open www.example.com)

If things work fine with direct connection to Internet option. Then re-enable proxy server and put do not use proxy for

127.0.0.1;localhost;.example.com;

in firefox or put bypass proxy for

127.0.0.1,localhost,*.example.com

in Internet Explorer.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.