头歌实验:Linux 网络实战(一)- DNS 配置_头歌dns服务器配置
头歌实验:Linux 网络实战(一)- DNS 配置
第一关:Linux 本机 DNS 配置
操作步骤
- 
vim /etc/hosts - 
按
a键进入编辑模式,输入以下内容:127.0.1.1 newLocalhost127.1.1.1 www.baidu.com - 
按Esc键,输入:wq 保存并退出;
 - 
测评结果:
按照上述步骤操作后,进行测评。
 
第二关:安装 DNS 服务软件
操作步骤
- 
更新软件包列表并安装
bind9:apt-get updateapt-get install bind9 - 
按
Y确认安装:安装完成后,进行测评。
 
第三关:DNS 服务器启动/关闭
操作步骤
- 
启动 DNS 服务:
service bind9 start - 
测评结果:
按照上述步骤操作后,进行测评。
 
第四关:DNS 服务器配置
操作步骤
- 
初始化环境并编辑
/etc/bind/named.conf.default-zones文件:apt-get updateapt-get install hostvim /etc/bind/named.conf.default-zones - 
按
A键进入编辑模式,文件最后输入以下内容:zone \"test.com\" { type master; file \"/etc/bind/db.test.com\";};zone \"211.40.10.in-addr.arpa\" { type master; file \"/etc/bind/db.10\";}; - 
按Esc键,输入:wq 保存并退出;
 - 
编辑
/etc/bind/db.test.com文件:vim /etc/bind/db.test.com - 
按
A键进入编辑模式,输入以下内容:;; BIND data file for local loopback interface;$TTL 604800@ IN SOA test.com. root.test.com. ( 2 ; Serial 604800 ; Refresh 86400 ; Retry 2419200 ; Expire 604800 ) ; Negative Cache TTL;@ IN NS test.com.@ IN A 10.40.211.244 - 
按Esc键,输入:wq 保存并退出;
 - 
编辑
/etc/bind/db.10文件:vim /etc/bind/db.10 - 
按
A键进入编辑模式,输入以下内容:;; BIND reverse data file for local loopback interface;$TTL 604800@ IN SOA test.com. root.test.com. ( 1 ; Serial 604800 ; Refresh 86400 ; Retry 2419200 ; Expire 604800 ) ; Negative Cache TTL;@ IN NS test.com.244 IN PTR test.com. - 
按Esc键,输入:wq 保存并退出;
 - 
编辑
/etc/resolv.conf文件:vim /etc/resolv.conf - 
按
A键进入编辑模式,将第一行的 IP 地址修改为127.0.0.1:nameserver 127.0.0.1 - 
按Esc键,输入:wq 保存并退出;
 - 
重启 DNS 服务:
service bind9 restart 


