翼度科技»论坛 云主机 LINUX 查看内容

DNS/DHCP 服务器

4

主题

4

帖子

12

积分

新手上路

Rank: 1

积分
12
DNS/DHCP 服务器(Dnsmasq)

(01)安装Dnsmasq

Dnsmasq:安装
  安装 Dnsmasq,它是轻量级的 DNS 转发器和 DHCP 服务器软件。
[1]  安装 Dnsmasq。
  1. root@dlp:~# apt -y install dnsmasq
复制代码
 
[2]  配置 Dnsmasq。
  1. root@dlp:~# vi /etc/dnsmasq.conf
  2. # line 19 : uncomment
  3. # never forward plain names
  4. domain-needed
  5. # line 21 : uncomment
  6. # never forward addresses in the non-routed address spaces
  7. bogus-priv
  8. # line 53 : uncomment
  9. # query with each server strictly in the order in resolv.conf
  10. strict-order
  11. # line 67 : add if you need
  12. # query the specific domain name to the specific DNS server
  13. # the example follows means query [server.education] domain to the [10.0.0.10] server
  14. server=/server.education/10.0.0.10
  15. # line 116 : uncomment and specify network interfaces to bind
  16. interface=enp1s0
  17. # line 134 : uncomment
  18. bind-interfaces
  19. # line 145 : uncomment to add domain name on hostname automatically
  20. expand-hosts
  21. # line 155 : add to set domain name
  22. domain=srv.world
  23. # change the link according to man page of systemd-resolved in order to avoid conflicting on 53
  24. root@dlp:~# ln -fs /run/systemd/resolve/resolv.conf /etc/resolv.conf
  25. root@dlp:~# systemctl restart dnsmasq systemd-resolved
复制代码
 
[3]  对于 DNS 记录,请将其添加到 [/etc/hosts] 中。然后,Dnsmasq 将回答客户的查询。
  1. root@dlp:~# vi /etc/hosts
  2. # add DNS entries
  3. 10.0.0.30       dlp.srv.world dlp
  4. 10.0.0.31       www.srv.world www
  5. root@dlp:~# systemctl reload dnsmasq
复制代码
 
[4]  验证网络中客户端主机的名称或地址解析。
root@desktop:~# vi /etc/netplan/01-netcfg.yaml# change DNS setting to refer to Dnsmasq Server 
  1. nameservers:
  2.   addresses: [10.0.0.30]
复制代码
root@desktop:~# netplan apply
root@desktop:~# grep nameserver /run/systemd/resolve/resolv.conf
nameserver 10.0.0.30root@desktop:~# 
dig dlp.srv.world.
root@desktop:~# 
dig -x 10.0.0.30[code];  DiG 9.18.24-0ubuntu5-Ubuntu  dlp.srv.world.;; global options: +cmd;; Got answer:;; ->>HEADERHEADER

举报 回复 使用道具