> 技术文档 > 头歌实验:Linux 网络实战(一)- DNS 配置_头歌dns服务器配置

头歌实验:Linux 网络实战(一)- DNS 配置_头歌dns服务器配置


头歌实验:Linux 网络实战(一)- DNS 配置

第一关:Linux 本机 DNS 配置

操作步骤

  1. 编辑 /etc/hosts 文件

    vim /etc/hosts
  2. a 键进入编辑模式,输入以下内容

    127.0.1.1 newLocalhost127.1.1.1 www.baidu.com
  3. 按Esc键,输入:wq 保存并退出;

  4. 测评结果:

    按照上述步骤操作后,进行测评。


第二关:安装 DNS 服务软件

操作步骤

  1. 更新软件包列表并安装 bind9

    apt-get updateapt-get install bind9
  2. Y 确认安装:

    安装完成后,进行测评。


第三关:DNS 服务器启动/关闭

操作步骤

  1. 启动 DNS 服务:

    service bind9 start
  2. 测评结果:

    按照上述步骤操作后,进行测评。


第四关:DNS 服务器配置

操作步骤

  1. 初始化环境并编辑 /etc/bind/named.conf.default-zones 文件:

    apt-get updateapt-get install hostvim /etc/bind/named.conf.default-zones
  2. 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\";};
  3. 按Esc键,输入:wq 保存并退出;

  4. 编辑 /etc/bind/db.test.com 文件:

    vim /etc/bind/db.test.com
  5. 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
  6. 按Esc键,输入:wq 保存并退出;

  7. 编辑 /etc/bind/db.10 文件:

    vim /etc/bind/db.10
  8. 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.
  9. 按Esc键,输入:wq 保存并退出;

  10. 编辑 /etc/resolv.conf 文件:

    vim /etc/resolv.conf
  11. A 键进入编辑模式,将第一行的 IP 地址修改为 127.0.0.1

    nameserver 127.0.0.1
  12. 按Esc键,输入:wq 保存并退出;

  13. 重启 DNS 服务:

    service bind9 restart