openness configure dns server

 Prepare:

详解 DNS 与 CoreDNS 的实现原理 

 调查

 采用什么来搭建一个dns server?  

 1.  BIND

Learn how to use BIND to set up your own server for resolving domain names.

How to Install and Configure DNS Server in Linux 

2. Dnsmasq (dnsmasq - archlinux)

Consul, DNS and Dnsmasq

experience

Create a Home Network DNS Server Using DNSMasq 

How to Setup a DNS/DHCP Server Using dnsmasq on CentOS/RHEL 8/7   

Use dnsmasq to provide DNS & DHCP services 

Dnsmasq setup

# https://somoit.net/linux/configure-simple-dns-server
# https://oracle-base.com/articles/linux/dnsmasq-for-simple-dns-configurations
# https://www.tecmint.com/setup-a-dns-dhcp-server-using-dnsmasq-on-centos-rhel/
yum install dnsmasq -y
yum install bind-utils -y


mkdir -p ~/dnsmasq

DNSP=$(realpath ~/dnsmasq)
IFC=$(ip route get 1 | awk '{match($0, /.+dev\s([A-Za-z.0-9]+)/, a);print a[1];exit}')
IP=$(ip route get 1 | awk '{match($0, /.+src\s([.0-9]+)/, a);print a[1];exit}')
DHCP_R=10.10.10.2,10.10.10.192

configure 

echo "192.168.127.10  test.host.openness.com" > $DNSP/dns.addnhosts

cat << EOF > $DNSP/dnsmasq.conf
#/etc/dnsmasq.conf
##WARNING:  THIS IS AN AUTO-GENERATED FILE. CHANGES TO IT ARE LIKELY TO BE
##OVERWRITTEN AND LOST.  Changes to this configuration should be made using:
##    virsh net-edit ansible_cloud
## or other application using the libvirt API.
##
## dnsmasq conf file created by libvirt
strict-order
pid-file=${DNSP}/dnsmasq.pid
except-interface=lo
bind-dynamic
interface=$IFC
dhcp-range=$DHCP_R
dhcp-no-override
dhcp-authoritative
dhcp-lease-max=191
dhcp-hostsfile=${DNSP}/dhcp.hostsfile
addn-hosts=${DNSP}/dns.addnhosts
# --
# domain-needed
# bogus-priv
# expand-hosts
#
# # The address 192.168.0.176 is the static IP of this server
# # You can find this ip by running ifconfig and look for the
# # IP of the interface which is connected to the router.
# listen-address=127.0.0.1
# listen-address=192.168.0.176
# bind-interfaces
#
# # Use open source DNS servers
# server=8.8.8.8
# server=8.8.4.4
# server=208.67.220.220
#
# # Create custom 'domains'.
# # Custom 'domains' can also be added in /etc/hosts
# address=/busyserver.net/192.168.0.176
EOF

start 

/usr/sbin/dnsmasq --conf-file=$DNSP/dnsmasq.conf --leasefile-ro

validation 

IP=$(ip route get 1 | awk '{match($0, /.+src\s([.0-9]+)/, a);print a[1];exit}')
dig @$IP test.host.openness.com

restart

DNSP=$(realpath ~/dnsmasq)
pkill dnsmasq
/usr/sbin/dnsmasq --conf-file=$DNSP/dnsmasq.conf --leasefile-ro
ps -ef | grep dnsmasq

or just sed a SIGHUB to reload configure

Kill Command in Linux 

kill -HUP $(pidof dnsmasq)

# or
kill -SIGHUP $(pidof dnsmasq)

# or 
kill -1 $(pidof dnsmasq)

 

add a new host entry 

Linux – Simple DNS server using DNSmasq  

echo "192.168.100.117      testhost.mydomain.com testhost" >>  /etc/hosts

specified dsn host files

DNSP=$(realpath ~/dnsmasq)
pkill dnsmasq

/usr/sbin/dnsmasq --conf-file=$DNSP/dnsmasq.conf --leasefile-ro --addn-hosts=$DNSP/dns.addnhosts

ps -ef | grep dnsmasq 

still can not works, what's wrong?  other sample configrue 

can works by "--address"

/usr/sbin/dnsmasq --conf-file=$DNSP/dnsmasq.conf --leasefile-ro --addn-hosts=$DNSP/dns.addnhosts --address=/test.host.openness.com/192.168.127.10

 default setting

cat /usr/lib/systemd/system/dnsmasq.service
[Unit]
Description=DNS caching server.
After=network.target

[Service]
ExecStart=/usr/sbin/dnsmasq -k

[Install]
WantedBy=multi-user.target

 

REF:

OpenNESS,开源的边缘网络服务平台 EAA

coreDNS配置私有DNS服务器和上游DNS服务器

 K8S official:  自定义 DNS 服务 ,  自定义 DNS 服务 V1.17 

K8S official:  Pod 与 Service 的 DNS

K8S official: 调试 DNS 问题 

配置自定义DNS服务 ETCD备份

CoreDNS系列1:Kubernetes内部域名解析原理、弊端及优化方式  CoreDNS VS kubedns

 KubeDNS 和 CoreDNS  

 CoreDNS 插件系统的实现原理  

CoreDNS 添加自定义DNS解析记录

详解 DNS 与 CoreDNS 的实现原理  

kubernetes之coredns玩法 介绍了dnsmasqconsul 用法

DNS解析中的A记录、AAAA记录、CNAME记录、MX记录、NS记录、TXT记录、SRV记录、URL转发等

 

https://somoit.net/linux/configure-simple-dns-server

posted @ 2021-06-12 12:05  lvmxh  阅读(75)  评论(0编辑  收藏  举报