[root@localhost ~]# ifconfig eth0 //查看网卡信息
eth0 Link encap:Ethernet HWaddr 00:0C:29:07:48:16
inet addr:192.168.0.1 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe07:4816/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:100 errors:0 dropped:0 overruns:0 frame:0
TX packets:51 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:19566 (19.1 KiB) TX bytes:6000 (5.8 KiB)
Interrupt:185 Base address:0x2000
[root@localhost ~]# rpm -qa|grep bind //查看是否安装bind所要的包,没有就用rpm安装
bind-libs-9.2.4-16.EL4
bind-9.2.4-16.EL4
ypbind-1.17.2-8
bind-chroot-9.2.4-16.EL4
bind-utils-9.2.4-16.EL4
[root@localhost ~]# vi /etc/hosts //编辑主机hosts文件
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
192.168.0.1 www.company.com
[root@localhost ~]# vi /etc/resolv.conf //编辑域名解析resolve文件
; generated by /sbin/dhclient-script
#search localdomain
#nameserver 192.168.59.1
search company.com
nameserver 192.168.0.1
nameserver 192.168.0.1
[root@localhost ~]# cat /etc/named.conf //编辑主配置named文件
//
// named.conf for Red Hat caching-nameserver
//
options {
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
/*
* 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;
};
//
// a caching only nameserver config
//
controls {
inet 127.0.0.1 allow { localhost; } keys { rndckey; };
};
zone "." IN {
type hint;
file "named.ca";
};
zone "localdomain" IN {
type master;
file "localdomain.zone";
allow-update { none; };
};
zone "localhost" IN {
type master;
file "localhost.zone";
allow-update { none; };
};
zone "0.0.127.in-addr.arpa" IN {
type master;
file "named.local";
allow-update { none; };
};
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 "company.com" IN {
type master;
file "company.com";
allow-update { none; };
};
zone "0.168.192.in-addr.arpa" IN {
type master;
file "192.168.0";
allow-update { none; };
};
include "/etc/rndc.key";
[root@localhost ~]# cd /var/named/chroot/var/named/
[root@localhost named]# ls -l
[root@localhost named]# cp -p localhost.zone company.com
[root@localhost named]# cp -p named.local 192.168.0
[root@localhost named]# vi company.com //编辑正向解析文件
$TTL 86400
@ IN SOA @www.company.com. root.www.company.com. (
2009102001 ; serial (d. adams)
3H ; refresh
15M ; retry
1W ; expiry
1D ) ; minimum
IN NS @www.company.com.
IN A 127.0.0.1
IN AAAA ::1
www.company.com. IN A 192.168.0.1
dns.company.com. IN CNAME www.company.com.
[root@localhost named]# vi 192.168.0 //编辑逆向解析文件
$TTL 86400
@ IN SOA www.company.com. root.www.company.com. (
2009102003 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
IN NS www.company.com.
1 IN PTR www.company.com.
1 IN PTR dns.company.com.
[root@localhost named]# /etc/init.d/named start //启动服务
启动 named: [ 确定 ]
[root@localhost named]# nslookup //测试
> www.company.com
Server: 192.168.0.1
Address: 192.168.0.1#53
Name: www.company.com
Address: 192.168.0.1
> dns.company.com
Server: 192.168.0.1
<, FONT size=3>Address: 192.168.0.1#53
dns.company.com canonical name = www.company.com.
Name: www.company.com
Address: 192.168.0.1
> 192.168.0.1
Server: 192.168.0.1
Address: 192.168.0.1#53
1.0.168.192.in-addr.arpa name = dns.company.com.
1.0.168.192.in-addr.arpa name = www.company.com.
> exit
[root@localhost named]#