I'm trying to configure configure BIND for use on my local Debian machine, which I will use as a development and testing environment.
First of all, I'm using Debian 6.x [Squeeze] and BIND 9. BIND server was set up automatically during the installation of the Debian.
For the purpose of this question, let's say I want to create a domain called example.com that I will be able to access from the same machine on which BIND is running, and my local network.
Here is what I have done so far:
In /etc/bind named.conf.local (which is included in name.conf) I put the following:
zone "cms1.com" {
type master;
file "/etc/bind/db.example.com";
};
In /etc/bind/db.example.com I put the following:
$TTL 3600
@ IN SOA example.com. admin.example.com. (
2011101601 ; Serial
3600 ; Refresh 1h
60 ; Retry 1m
86400 ; Expire 1d
600 ) ; Negative Cache TTL 1h
;
@ IN NS localhost.
;
example.com. IN CNAME localhost.
example.com. IN A 127.0.0.1
Notice that I am setting the nameserver as localhost. I don't know if this is right or wrong.
Then I added the appropriate virtual host directives to Apache and restarted BIND using the command /etc/init.d/bind9 restart.
However, when I ping or browse to example.com I access the example.com on the internet, and not the one on my machine.
What am I doing wrong?
To take AlexD's advice, I added nameserver 127.0.0.1 before all other directives in /etc/resolv.conf shown here:
# Generated by NetworkManager
nameserver 127.0.0.1
domain cm.flowja.com
search cm.flowja.com
nameserver 65.183.0.76
nameserver 65.183.0.86
The other directives were automatically generated by Debian.
Here is the response after I edited resolve.conf and restarted BIND.
; <<>> DiG 9.7.3 <<>> example.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: SERVFAIL, id: 60115
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;example.com. IN A
;; Query time: 3 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Sun Oct 16 16:06:29 2011
;; MSG SIZE rcvd: 29
Now it seems to that adding the nameserver 127.0.0.1 directive to resolv.conf actually caused example.com to resolve to my BIND server, but something is still going wrong.
Ideas?