DNS/DHCP 服务器

  • DNS/DHCP 服务器已关闭评论
  • 62 次浏览
  • A+
所属分类:linux技术
摘要

Dnsmasq:安装   安装 Dnsmasq,它是轻量级的 DNS 转发器和 DHCP 服务器软件。[1]  安装 Dnsmasq。


DNS/DHCP 服务器(Dnsmasq)

(01)安装Dnsmasq

Dnsmasq:安装


  安装 Dnsmasq,它是轻量级的 DNS 转发器和 DHCP 服务器软件。

[1]  安装 Dnsmasq。

root@dlp:~# apt -y install dnsmasq

 

[2]  配置 Dnsmasq。

root@dlp:~# vi /etc/dnsmasq.conf # line 19 : uncomment # never forward plain names domain-needed # line 21 : uncomment # never forward addresses in the non-routed address spaces bogus-priv # line 53 : uncomment # query with each server strictly in the order in resolv.conf strict-order # line 67 : add if you need # query the specific domain name to the specific DNS server # the example follows means query [server.education] domain to the [10.0.0.10] server server=/server.education/10.0.0.10 # line 116 : uncomment and specify network interfaces to bind interface=enp1s0 # line 134 : uncomment bind-interfaces # line 145 : uncomment to add domain name on hostname automatically expand-hosts # line 155 : add to set domain name domain=srv.world # change the link according to man page of systemd-resolved in order to avoid conflicting on 53 root@dlp:~# ln -fs /run/systemd/resolve/resolv.conf /etc/resolv.conf root@dlp:~# systemctl restart dnsmasq systemd-resolved

 

[3]  对于 DNS 记录,请将其添加到 [/etc/hosts] 中。然后,Dnsmasq 将回答客户的查询。

root@dlp:~# vi /etc/hosts # add DNS entries 10.0.0.30       dlp.srv.world dlp 10.0.0.31       www.srv.world www   root@dlp:~# systemctl reload dnsmasq

 

[4]  验证网络中客户端主机的名称或地址解析。

root@desktop:~# 

vi /etc/netplan/01-netcfg.yaml

# change DNS setting to refer to Dnsmasq Server

 

nameservers:   addresses: [10.0.0.30]
root@desktop:~# 

netplan apply

root@desktop:~# 

grep nameserver /run/systemd/resolve/resolv.conf

nameserver 10.0.0.30

root@desktop:~# 

dig dlp.srv.world.


root@desktop:~# 

dig -x 10.0.0.30
; <<>> DiG 9.18.24-0ubuntu5-Ubuntu <<>> dlp.srv.world. ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 25017 ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1  ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 65494 ;; QUESTION SECTION: ;dlp.srv.world.                 IN      A  ;; ANSWER SECTION: dlp.srv.world.          0       IN      A       10.0.0.30  ;; Query time: 0 msec ;; SERVER: 127.0.0.53#53(127.0.0.53) (UDP) ;; WHEN: Mon Apr 29 14:04:55 UTC 2024 ;; MSG SIZE  rcvd: 58

 

; <<>> DiG 9.18.24-0ubuntu5-Ubuntu <<>> -x 10.0.0.30 ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 20706 ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1  ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 65494 ;; QUESTION SECTION: ;30.0.0.10.in-addr.arpa.                IN      PTR  ;; ANSWER SECTION: 30.0.0.10.in-addr.arpa. 0       IN      PTR     dlp.srv.world.  ;; Query time: 0 msec ;; SERVER: 127.0.0.53#53(127.0.0.53) (UDP) ;; WHEN: Mon Apr 29 14:05:39 UTC 2024 ;; MSG SIZE  rcvd: 78

 

(02)配置DHCP服务器

Dnsmasq:配置DHCP服务器


  在 Dnsmasq 上启用集成 DHCP 功能并配置 DHCP 服务器。

[1]  配置 Dnsmasq。

root@dlp:~# vi /etc/dnsmasq.conf # line 168 : add : range of IP address to lease and term of lease dhcp-range=10.0.0.200,10.0.0.250,12h # line 345 : add : define default gateway dhcp-option=option:router,10.0.0.1 # line 354 : add : define NTP, DNS, server and subnetmask dhcp-option=option:ntp-server,10.0.0.10 dhcp-option=option:dns-server,10.0.0.10 dhcp-option=option:netmask,255.255.255.0 root@dlp:~# systemctl restart dnsmasq

 

[2]  没关系。

  在任何客户端计算机上配置 DHCP 客户端并验证其是否正常工作。

 

DNS 服务器(BIND)

(01)配置内部网络

(02)配置外部网络

(03)配置区域文件

(04)验证分辨率

(05)使用视图语句

(06)设置别名(CNAME)

(07)配置辅助服务器

(08)DNS over HTTPS(服务器)

(09)DNS over HTTPS(客户端)

DHCP 服务器

(01)配置DHCP服务器

(02)配置DHCP客户端