VnLamp

Go Back   VnLamp > Khu vực Training > LPI > DNS

Trả lời
 
LinkBack Ðiều Chỉnh Xếp Bài
Xin chỉ giúp cấu hình DNS, Apache chạy trong mạng LAN
Old
  (#1 (permalink))
 
Status: Offline
Posts: 20
Tham gia: Feb 2008
Junior Member
Default Xin chỉ giúp cấu hình DNS, Apache chạy trong mạng LAN - 17-02-2008, 18:17 17-02-2008

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 :(.
   
Trả Lời Với Trích Dẫn
Old
  (#2 (permalink))
 
Status: Offline
Posts: 459
Tham gia: Dec 2007
Administrator
 
patrick's Avatar
Default 17-02-2008, 19:17 17-02-2008

Hi Bạn,

Bạn cho mình hỏi bạn đang sử dụng OS là gì vậy?

  Send a message via Yahoo to patrick  
Trả Lời Với Trích Dẫn
Old
  (#3 (permalink))
 
Status: Offline
Posts: 20
Tham gia: Feb 2008
Junior Member
Default 17-02-2008, 19:17 17-02-2008

Em sử dụng OS Centos
   
Trả Lời Với Trích Dẫn
Old
  (#4 (permalink))
 
Status: Offline
Posts: 459
Tham gia: Dec 2007
Administrator
 
patrick's Avatar
Default 17-02-2008, 19:17 17-02-2008

$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

$ORIGIN 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

Bạn tôi để phần in đậm bạn sử theo và restart lại dịch vụ named nhé.
Chúc bạn thành công.
  Send a message via Yahoo to patrick  
Trả Lời Với Trích Dẫn
Old
  (#5 (permalink))
 
Status: Offline
Posts: 20
Tham gia: Feb 2008
Junior Member
Default 17-02-2008, 20:17 17-02-2008

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.100
$ORIGIN home.lan.
@ IN A 192.168.1.100
www IN A 192.168.1.100
ftp IN A 192.168.1.100
mail IN A 192.168.1.100
Khi restart named
Trích:
[root@mail2 ~]# service named restart
Stopping named: [ OK ]
Starting named: [ OK ]
Trích:
[root@mail2 ~]# cat /etc/resolv.conf
search home.lan
nameserver 127.0.0.1
nameserver 192.168.1.100
Sau đó em gõ mail2.home.lan trên trình duyệt thì không thể truy cập web

thay đổi nội dung bởi: truongan, 17-02-2008 lúc 20:17 17-02-2008.
   
Trả Lời Với Trích Dẫn
Old
  (#6 (permalink))
 
Status: Offline
Posts: 459
Tham gia: Dec 2007
Administrator
 
patrick's Avatar
Default 17-02-2008, 20:17 17-02-2008

$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
$ORIGIN home.lan.
@ IN A 192.168.1.100
www IN A 192.168.1.100
ftp IN A 192.168.1.100

Chỗ này bạn có khai báo record mail2 đâu mà bạn nslookup được.

mail IN A 192.168.1.100

Bạn sữa lại đi nhé.
  Send a message via Yahoo to patrick  
Trả Lời Với Trích Dẫn
Old
  (#7 (permalink))
 
Status: Offline
Posts: 20
Tham gia: Feb 2008
Junior Member
Default 17-02-2008, 20:17 17-02-2008

Sửa như thế này đúng không anh
Trích:
$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 mail.home.lan.
@ IN A 192.168.1.100
$ORIGIN home.lan.
@ IN A 192.168.1.100
www IN A 192.168.1.100
ftp IN A 192.168.1.100
mail IN A 192.168.1.100
Em gõ http://mail.home.lan/ trên trình duyệt thì không truy cập web được nhưng http://home.lan/ thì truy cập web được rùi .
   
Trả Lời Với Trích Dẫn
Old
  (#8 (permalink))
 
Status: Offline
Posts: 459
Tham gia: Dec 2007
Administrator
 
patrick's Avatar
Default 17-02-2008, 20:17 17-02-2008

Nếu như vậy bạn cấu hình web server chưa đúng thôi, bạn check lại kỹ nhé.


Kinh nghiệm của chúng tôi là kiến thức của bạn
  Send a message via Yahoo to patrick  
Trả Lời Với Trích Dẫn
Old
  (#9 (permalink))
 
Status: Offline
Posts: 20
Tham gia: Feb 2008
Junior Member
Default 17-02-2008, 20:17 17-02-2008

Em thêm dòng này vào thì làm thành công rùi, thanks anh
mail A 192.168.1.200
   
Trả Lời Với Trích Dẫn
Old
  (#10 (permalink))
 
Status: Offline
Posts: 459
Tham gia: Dec 2007
Administrator
 
patrick's Avatar
Default 17-02-2008, 20:17 17-02-2008

vậy là record mail chạy ở một server khác hả Em


Kinh nghiệm của chúng tôi là kiến thức của bạn
  Send a message via Yahoo to patrick  
Trả Lời Với Trích Dẫn
Trả lời


Ðiều Chỉnh
Xếp Bài

Quyền Sử Dụng Ở Diễn Ðàn
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is Mở
Smilies đang Mở
[IMG] đang Tắt
HTML đang Tắt
Trackbacks are Mở
Pingbacks are Mở
Refbacks are Mở


Múi giờ GMT. Hiện tại là 03:21 21-05-2012.