linux 如何配置dns
1970-01-01 来源:
本篇文章介绍了linux 如何配置dns,下面小编给大家介绍详细的解决步骤
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
若出现以上的文字则表示安装成功,若没有出现以上东西插入正确的光盘,进行安装.或者通过下载源代码进行安装。
2. 设定好IP地址与DNS
在终端中输入netconfig,回车,在第一行中输入IP,172.18.121.35.第二行输入子网掩码255.255.255.0第三行输入网关地址: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/zljlinux.com
先复制本机DNS的一个配置模板文件,进行修改,修改的部分是粗线表示
[root@localhost root]# vi /var/named/zljlinux.com
$TTL 86400
$ORIGIN zljlinux.com.
@ 1D IN SOA zljlinux.com. root.zljlinux.com. (
42 ; serial (d. adams)
3H ; refresh
15M ; retry
1W ; expiry
1D ) ; minimum
1D IN NS @
1D IN MX 5 mail.zljlinux.com.
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.zljlinux.com.
smtp IN CNAME mail.zljlinux.com.
保存退出,先按ESC ,再:wq.
配置DNS正向搜索,配置文件如下:
[root@localhost root]#cp /var/named/named.local /var/named/172.18.121.rev
先复制本机DNS的一个配置模板文件,进行修改,修改的部分是粗线表示
[root@localhost root]# vi /var/named/172.18.121.rev
$TTL 86400
@ IN SOA linuxidc.com. root.linuxidc.com. (
1997022700 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
IN NS linuxidc.com.
35 IN PTR www.linuxidc.com.
35 IN PTR mail.linuxidc.com.
35 IN PTR ftp.linuxidc.com.
配置本机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 "linuxidc.com"IN{
type master;
file "linuxidc.com";
};
zone "121.18.172.in-addr.arpa"IN{
type master;
file "172.18.121.rev";
};
include "/etc/rndc.key";
"/etc/named.conf" [已转换] 45L, 894C
配置本机的域名转换程序的顺序
[root@localhost root]# vi /etc/host.conf
order bind,hosts
multi off
trim linuxidc.com
[root@localhost root]# vi /etc/resolv.conf
nameserver 172.18.121.35
nameserver 218.196.42.2
namedsever 218.196.42.2
domain linuxidc.com
search www.linuxidc.com linuxidc.com
option nochecknames rotate
4. 启动named服务.
[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.
> www.linuxidc.com
Server: 172.18.121.35
Address: 172.18.121.35#53
Name: www.linuxidc.com
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.linuxidc.com.
35.121.18.172.in-addr.arpa name = www.linuxidc.com.
35.121.18.172.in-addr.arpa name = mail.linuxidc.com.
>
ctrl +D退出
若出现上面的情况的文字表示已经配置成功.
6. 其实在配置的过程中,查看自己是否配置正确可以通过named ?g 进行查看你的配置文件到底错在那个地方,再进行修改.
以上所述就是linux 如何配置dns的介绍,希望大家能够喜欢,更多内容请继续关注爱站技术频道网站!
标签: dns idc linux 本机dns 代码 搜索 网站 域名
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点!
本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。