搭建域名服务器。
1. 搭建域名服务器
可以直接在服务器安装BIND 9软件,BIND介绍摘自维基百科:
BIND (/ˈbaɪnd/) is a suite of software for interacting with the Domain Name System (DNS). Its most prominent component, named (pronounced /ˈneɪmdiː/, short for name daemon), performs both of the main DNS server roles, acting as an authoritative name server for DNS zones and as a recursive resolver in the network.
安装BIND 9,
sudo apt-get install bind9
修改/etc/named.conf
配置文件。需要将服务器的DNS服务器设为服务器的IP地址?
重启named服务,
service bind9 start
service bind9 restart
2. 设置DNS服务器
接下来,其他机器的DNS服务器设为该服务器的IP地址。
2.1 Windows
控制面板 --> 网络和 Internet --> 网络和共享中心 --> 更改适配器设置 --> 右击网络图标 --> 属性,可以手动设置,也可以自动获取,如下图所示:
2.2 Linux
编辑/etc/resolv.conf
文件,nameserver
指定DNS服务器。
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
# 127.0.0.53 is the systemd-resolved stub resolver.
# run "systemd-resolve --status" to see details about the actual nameservers.
nameserver 127.0.0.53
options timeout:2 attempts:3 rotate single-request-reopen
3. 怎么知道根域名服务器
ICANN (Internet Corporation for Assigned Names and Numbers, 互联网名称与数字地址分配机构)负责维护根域名服务器信息,文件在这里:https://www.internic.net/domain/named.root。部分内容如下:
; This file holds the information on root name servers needed to
; initialize cache of Internet domain name servers
; (e.g. reference this file in the "cache . <file>"
; configuration file of BIND domain name servers).
;
; This file is made available by InterNIC
; under anonymous FTP as
; file /domain/named.cache
; on server FTP.INTERNIC.NET
; -OR- RS.INTERNIC.NET
;
; last update: March 29, 2023
; related version of root zone: 2023032901
;
; FORMERLY NS.INTERNIC.NET
;
. 3600000 NS A.ROOT-SERVERS.NET.
A.ROOT-SERVERS.NET. 3600000 A 198.41.0.4
A.ROOT-SERVERS.NET. 3600000 AAAA 2001:503:ba3e::2:30
;
; FORMERLY NS1.ISI.EDU
;
注:1998年9月18日以前,根域名服务器信息是由互联网络信息中心(Internet Network Information Center, InterNIC)负责。
BIND 9将根域名服务器信息存放在/var/named/named.ca
,文件的内容实为上述named.root
的内容。