Em mới tập tành cài đặt BIND trên Linux, có cài đặt bind-devel, bind-chroot, bind, caching-nameserver bằng rpm
Em cấu hình như thía này
Trích:
[root@mail2 ~]# hostname
mail2.home.local
|
Trích:
[root@centos ~]# vi /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 centos.linux.local centos localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
192.168.1.100 mail2.home.local mail2
|
Code:
[root@mail2 ~]# cp /var/named/chroot/etc/named.caching-nameserver.conf /var/named/chroot/etc/named.conf
[root@mail2 ~]# chgrp named /var/named/chroot/etc/named.conf
[root@mail2 ~]# vi /var/named/chroot/etc/named.conf
Trích:
options {
directory "/var/named";
/*
* If there is a firewall between you and nameservers you want
* to talk to, you might need to uncomment the query-source
* directive below. Previous versions of BIND always asked
* questions using port 53, but BIND 8.1 uses an unprivileged
* port by default.
*/
// query-source address * port 53;
//The DNS server's internal use only
allow-query{
127.0.0.1;
192.168.1.0/24;
};
// The DNS server cache server to be used as the only internal
allow-recursion{
127.0.0.1;
192.168.1.0/24;
};
//The DNS server is inside the zone where only data transfer
allow-transfer{
127.0.0.1;
192.168.1.0/24;
};
//If the environment is connected via a router's IP address Routers
forwarders{
192.168.1.1;
};
};
//
// a caching only nameserver config
//
controls {
inet 127.0.0.1 allow { localhost; } keys { rndckey; };
};
logging {
category lame-servers { null; }; // /var/log/messages "lame server resolving…" not to log
};
include "/etc/rndc.key";
zone "home.lan" IN { //Database positive zone declared off
type master;
file "home.lan.db";
allow-update { none; };
};
zone "1.168.192.in-addr.arpa" IN { //Zone database reverse declaration
type master;
file "1.168.192.in-addr.arpa.db";
allow-update { none; };
};
|
Trích:
[root@mail2 ~]# vi /var/named/chroot/var/named/home.lan.db
$TTL 86400
@ IN SOA home.lan. root.home.lan.(
2005120201 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
IN NS home.lan.
IN MX 10 mail2.home.lan.
@ IN A 192.168.1.200
www IN A 192.168.1.100
ftp IN A 192.168.1.100
mail IN A 192.168.1.100
|
Trích:
[root@mail2 ~]# vi /var/named/chroot/var/named/1.168.192.in-addr.arpa.db
$TTL 86400
@ IN SOA home.lan. root.home.lan.(
2004031901 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
IN NS home.lan.
2 IN PTR home.lan. //Wide lowest IP address (192.168.1.2) and the domain name
|
[root@mail2 ~]# dig @a.root-servers.net . ns > /var/named/chroot/var/named/named.ca
Trích:
[root@mail2 ~]# vi /etc/cron.monthly/named.root_update
#!/bin/sh
new=`mktemp`
errors=`mktemp`
dig @a.root-servers.net . ns > $new 2> $errors
if [ $? -eq 0 ]; then
sort_new=`mktemp`
sort_old=`mktemp`
diff_out=`mktemp`
sort $new > $sort_new
sort /var/named/chroot/var/named/named.ca > $sort_old
diff --ignore-matching-lines=^\; $sort_new $sort_old > $diff_out
if [ $? -ne 0 ]; then
(
echo '-------------------- old named.root --------------------'
cat /var/named/chroot/var/named/named.ca
echo
echo '-------------------- new named.root --------------------'
cat $new
echo '---------------------- difference ----------------------'
cat $diff_out
) | mail -s 'named.root updated' root
cp -f $new /var/named/chroot/var/named/named.ca
chown named. /var/named/chroot/var/named/named.ca
chmod 644 /var/named/chroot/var/named/named.ca
/etc/rc.d/init.d/named restart > /dev/null
fi
rm -f $sort_new $sort_old $diff_out
else
cat $errors | mail -s 'named.root update check error' root
fi
rm -f $new $errors
|
[root@mail2 ~]# chmod 700 /etc/cron.monthly/named.root_update
[root@mail2 ~]# /etc/rc.d/init.d/named start
Starting named: [ OK ]
[root@mail2 ~]# chkconfig named on
[root@mail2 ~]# chkconfig --list named
named 0:off 1:off 2:on 3:on 4:on 5:on 6:off
Code:
[root@mail2 ~]# echo "nameserver 127.0.0.1" > /etc/resolv.conf
[root@mail2 ~]# echo "nameserver 192.168.1.100" >> /etc/resolv.conf
IP 192.168.1.100 là IP của máy tính
Sau đó em gõ mail2.home.lan trên trình duyệt thì không thể truy cập web trên LAN được dù Apache start rồi :(.