#!/bin/bash
mkdir /mafei
mount /dev/cdrom /mafei
cd /mafei/Server
rpm -e `rpm -qa | grep ^bind` --nodeps --force
rpm -ivh bind-* --nodeps --force
rpm -ivh caching-nameserver-9.3.3-7.el5.i386.rpm
echo "search server.mafei.com" > /etc/resolv.conf
echo "nameserver 192.168.142.128" >> /etc/resolv.conf
cd /var/named/chroot/etc/
vi /var/named/chroot/etc/named.caching-nameserver.conf << MAFEI
:%s/127.0.0.1/any/g
:%s/localhost/any/g
:wq
MAFEI
echo 'zone "mafei.com" IN { type master; file "mafei.com"; };' >> /var/named/chroot/etc/named.rfc1912.zones
cd /var/named/chroot/var/named/
cp named.local mafei.com
vi /var/named/chroot/var/named/mafei.com << MAFEIFEI
:%s/1 IN PTR localhost./www IN A 192.168.142.128/g
:wq
MAFEIFEI
bind-chroot-admin -s
service named restart
ping www.mafei.com
|
[root@server ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
# Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]
DEVICE=eth0
HWADDR=00:0c:29:c1:ef:7f
ONBOOT=yes
IPADDR=192.168.142.2
NETMASK=255.255.255.0
TYPE=Ethernet
|
[root@server ~]# vi /etc/resolv.conf
search mafei.com
nameserver 192.168.142.2
|
[root@server ~]# mkdir /mafei
[root@server ~]# mount /dev/cdrom /mafei
mount: block device /dev/cdrom is write-protected, mounting read-only
[root@server ~]# cd /mafei/Server/
[root@server Server]# rpm -e `rpm -qa | grep ^bind` --nodeps
warning: /etc/sysconfig/named saved as /etc/sysconfig/named.rpmsave
/var/tmp/rpm-tmp.51087: line 2: /usr/sbin/bind-chroot-admin: No such file or directory
error: %preun(bind-chroot-9.3.3-7.el5.i386) scriptlet failed, exit status 1
|
[root@server Server]# rpm -ivh bind-* --nodeps --force
warning: bind-9.3.3-7.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:bind-utils ########################################### [ 14%]
2:bind ########################################### [ 29%]
3:bind-chroot ########################################### [ 43%]
4:bind-devel ########################################### [ 57%]
5:bind-libbind-devel ########################################### [ 71%]
6:bind-libs ########################################### [ 86%]
7:bind-sdb ########################################### [100%]
[root@server Server]# rpm -ivh caching-nameserver-9.3.3-7.el5.i386.rpm
warning: caching-nameserver-9.3.3-7.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:caching-nameserver ########################################### [100%]
|
[root@server Server]# hostname
server.mafei.com
[root@server Server]# cd /var/named/chroot/etc/
[root@server etc]# ls
localtime named.caching-nameserver.conf named.rfc1912.zones rndc.key
[root@server etc]# vi named.caching-nameserver.conf
options {
listen-on port 53 { any; };
listen-on-v6 port 53 { ::1; };
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/named_mem_stats.txt";
query-source port 53;
query-source-v6 port 53;
allow-query { any; };
};
logging {
channel default_debug {
file "data/named.run";
severity dynamic;
};
};
view any_resolver {
match-clients { any; };
match-destinations { any; };
recursion yes;
include "/etc/named.rfc1912.zones";
};
|
[root@server etc]# vi named.rfc1912.zones
zone "0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa" IN {
type master;
file "named.ip6.local";
allow-update { none; };
};
zone "255.in-addr.arpa" IN {
type master;
file "named.broadcast";
allow-update { none; };
};
zone "0.in-addr.arpa" IN {
type master;
file "named.zero";
allow-update { none; };
};
zone "mafei.com" IN {
type master;
file "mafei.com";
};
|
[root@server etc]# vi named.rfc1912.zones
[root@server etc]# cd ../var/named/
[root@server named]# ls
data localhost.zone named.ca named.local slaves
localdomain.zone named.broadcast named.ip6.local named.zero
[root@server named]# cp named.local mafei.com
[root@server named]# vi mafei.com
$TTL 86400
@ IN SOA localhost. root.localhost. (
1997022700 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
IN NS localhost.
www IN A 192.168.142.2
|
[root@server named]# bind-chroot-admin –s
[root@server etc]# service named restart
Stopping named: [FAILED]
Starting named: [ OK ]
[root@server etc]# ping www.mafei.com
PING www.mafei.com (192.168.142.2) 56(84) bytes of data.
64 bytes from 192.168.142.2: icmp_seq=1 ttl=64 time=0.027 ms
64 bytes from 192.168.142.2: icmp_seq=2 ttl=64 time=0.028 ms
64 bytes from 192.168.142.2: icmp_seq=3 ttl=64 time=0.030 ms
--- www.mafei.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2001ms
rtt min/avg/max/mdev = 0.027/0.028/0.030/0.004 ms
|
[root@server etc]# vi named.rfc1912.zones
zone "mafei.com" IN {
type master;
file "mafei.com";
};
zone "142.168.192.in-addr.arpa" IN {
type master;
file "mafeifei.com";
};
zone "fei.com" IN {
type master;
file "fei.com";
};
|
[root@server named]# cp mafei.com fei.com
[root@server named]# cp named.local mafeifei.com
[root@server named]# vi mafeifei.com
$TTL 86400
@ IN SOA localhost. root.localhost. (
1997022700 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
IN NS localhost.
2 IN PTR www.mafeifei.com.
root@server named]# ls
data localhost.zone named.broadcast named.local
fei.com mafei.com named.ca named.zero
localdomain.zone mafeifei.com named.ip6.local slaves
|
[root@server named]# bind-chroot-admin -s
[root@server named]# service named restart
Stopping named: [ OK ]
Starting named: [ OK ]
|
[root@server named]# nslookup
> www.mafei.com
Server: 192.168.142.2
Address: 192.168.142.2#53
Name: www.mafei.com
Address: 192.168.142.2
> www.fei.com
Server: 192.168.142.2
Address: 192.168.142.2#53
Name: www.fei.com
Address: 192.168.142.2
> 192.168.142.2
Server: 192.168.142.2
Address: 192.168.142.2#53
2.142.168.192.in-addr.arpa name = www.mafeifei.com.
|