運行環(huán)境redhat 9.0 ,IP地址172.18.121.35,實現(xiàn)的域名為jb51.net
1.安裝DNS所要的軟件包.
查看是否安裝bind軟件,在終端中輸入
代碼如下:
[root@localhost root]# rpm -qa|grep bind
redhat-config-bind-1.9.0-13
bind-9.2.1-16
bind-utils-9.2.1-16
ypbind-1.11-4
若出現(xiàn)以上的文字則表示安裝成功,若沒有出現(xiàn)以上東西插入正確的光盤,進行安裝.或者通過下載源代碼進行安裝。
2.設(shè)定好IP地址與DNS
在終端中輸入netconfig,回車,在第一行中輸入IP,172.18.121.35.第二行輸入子網(wǎng)掩碼255.255.255.0第三行輸入網(wǎng)關(guān)地址:172.18.121.1,最后一行輸入DNS 172.18.121.35.再確定.再在終端中輸入下面的命令
代碼如下:
[root@localhost root]#service network reload
[root@localhost root]#service network restart
通過ifconfig查看IP信息
3.配置DNS
配置DNS正向搜索,配置文件如下:
代碼如下:
[root@localhost root]#cp /var/named/localhost.zone /var/named/jb51.net
先復(fù)制本機DNS的一個配置模板文件,進行修改
代碼如下:
[root@localhost root]# vi /var/named/jb51.net
$TTL 86400
$ORIGIN jb51.net.
@ 1D IN SOA jb51.net. root.jb51.net. (
42 ; serial (d. adams)
3H ; refresh
15M ; retry
1W ; expiry
1D ) ; minimum
1D IN NS @
1D IN MX 5 mail.jb51.net.
www 1D IN A 172.18.121.35
mail 1D IN A 172.18.121.35
ftp 1D IN A 172.18.121.35
pop3 IN CNAME mail.jb51.net.
smtp IN CNAME mail.jb51.net.
保存退出,先按ESC ,再:wq.
配置DNS正向搜索,配置文件如下:
代碼如下:
[root@localhost root]#cp /var/named/named.local /var/named/172.18.121.rev
先復(fù)制本機DNS的一個配置模板文件,進行修改
代碼如下:
[root@localhost root]# vi /var/named/172.18.121.rev
$TTL 86400
@ IN SOA jb51.net. root.jb51.net. (
1997022700 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
IN NS jb51.net.
< p>35 IN PTR
35 IN PTR mail.jb51.net.
35 IN PTR ftp.jb51.net.
配置本機DNS的一個主文件,安裝好后它有一個模板,修改它,修改的部分是粗線表示
代碼如下:
[root@localhost root]# vi /etc/named.conf
// generated by named-bootconf.pl
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;
};
//
// a caching only nameserver config
//
controls {
inet 127.0.0.1 allow { localhost; } keys { rndckey; };
};
zone "." IN {
type hint;
file "named.ca";
};
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 "jb51.net"IN{
type master;
file "jb51.net";
};
zone "121.18.172.in-addr.arpa"IN{
type master;
file "172.18.121.rev";
};
include "/etc/rndc.key";
"/etc/named.conf" [已轉(zhuǎn)換] 45L, 894C
配置本機的域名轉(zhuǎn)換程序的順序
代碼如下:
[root@localhost root]# vi /etc/host.conf
order bind,hosts
multi off
trim jb51.net
[root@localhost root]# vi /etc/resolv.conf
nameserver 172.18.121.35
nameserver 218.196.42.2
namedsever 218.196.42.2
domain jb51.net
search jb51.net
option nochecknames rotate
4.啟動named服務(wù).
代碼如下:
[root@localhost root]#service named start
5.檢查配置是否成功
代碼如下:
[root@localhost root]# nslookup
Note: nslookup is deprecated and may be removed from future releases.
Consider using the `dig' or `host' programs instead. Run nslookup with
the `-sil[ent]' option to prevent this message from appearing.
>
Server: 172.18.121.35
Address: 172.18.121.35#53
Name:
Address: 172.18.121.35
> 172.18.121.35
Server: 172.18.121.35
Address: 172.18.121.35#53
35.121.18.172.in-addr.arpa name = ftp.jb51.net.
35.121.18.172.in-addr.arpa name =
35.121.18.172.in-addr.arpa name = mail.jb51.net.
>
ctrl +D退出
若出現(xiàn)上面的情況的文字表示已經(jīng)配置成功.
6.其實在配置的過程中,查看自己是否配置正確可以通過named –g 進行查看你的配置文件到底錯在那個地方,再進行修改
PS:DNS相關(guān)配置文件說明
. /etc/host.conf
當(dāng)系統(tǒng)中同時存在DNS域名解析和/etc/hosts主機表機制時,由該/etc/host.conf確定主機名解釋順序。示例:
order hosts,bind #名稱解釋順序
multi on #允許主機擁有多個IP地址
nospoof on #禁止IP地址欺騙
order是關(guān)鍵字,定義先用本機hosts主機表進行名稱解釋,如果不能解釋,再搜索bind名稱服務(wù)器(DNS)。
. /etc/resolv.conf
該文件是DNS域名解析的配置文件,它的格式很簡單,每行以一個關(guān)鍵字開頭,后接配置參數(shù)。resolv.conf的關(guān)鍵字主要有四個,分別是:
nameserver #定義DNS服務(wù)器的IP地址
domain #定義本地域名
search #定義域名的搜索列表
sortlist #對返回的域名進行排序
/etc/resolv.conf的一個示例:
domain ringkee.com
search ringkee.com
nameserver 202.96.128.86
nameserver 202.96.128.166
最主要是nameserver關(guān)鍵字,如果沒指定nameserver就找不到DNS服務(wù)器,其它關(guān)鍵字是可選的。
. /etc/hosts
設(shè)置IP地址與主機名對應(yīng)表,可用該文件來進行主機名稱解釋。如:
#格式:IP地址 主機名 別名
代碼如下:
127.0.0.1 localhost localhost.localdomain
192.168.1.1 debian debian
192.168.0.2 t02 t02.tiger
192.168.0.4 t04 t04.tiger
./etc/name.conf
// generated by named-bootconf.pl
< p>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;
};
< p>//
// a caching only nameserver config
//
< p>zone "." IN {
type hint;
file "named.ca";
};
< p>zone "0.0.127.in-addr.arpa" IN {
type master;
file "named.local";
allow-update { none; };
};