0845680984
  1. Dnsmasq – Install
  2. Dnsmasq – Configure DHCP Server

Install Dnsmasq which is the lightweight DNS forwarder and DHCP Server Software.

[1] Install Dnsmasq.
[root@localhost ~]# yum -y install dnsmasq
[2] Configure Dnsmasq.
[root@soncq ~]# 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 41: uncomment (query with each server strictly in the order in resolv.conf)
strict-order
# line 55: 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 123: uncomment (add domain name automatically)
expand-hosts
# line 133: add (define domain name)
domain=soncq.local
[root@soncq ~]# systemctl start dnsmasq
[root@soncq ~]# systemctl enable dnsmasq
[3] For DNS records, add them in /etc/hosts.
Then, Dnsmasq will answer to queries from clients.
[root@soncq ~]# vi /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
# add records
10.0.0.30   soncq.local soncq 

[root@soncq ~]# systemctl restart dnsmasq
[4] If Firewalld is running, allow DNS service.
[root@soncq ~]# firewall-cmd --add-service=dns --permanent
success
[root@soncq ~]# firewall-cmd --reload
success
[5] Verify to resolve Name or IP address from a client in internal network.
[root@client ~]# yum -y install bind-utils
# change DNS setting to Dnsmasq Server (replace "ens3" to your own environment)
[root@client ~]# nmcli c modify ens3 ipv4.dns 10.0.0.30
[root@client ~]# nmcli c down ens3; nmcli c up ens3
[root@client ~]# dig soncq.local.

; <<>> DiG 9.9.4-RedHat-9.9.4-29.el7_2.3 <<>> soncq.local
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 11613
;; flags: qr aa rd ra ad; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;soncq.local.                 IN      A

;; ANSWER SECTION:
soncq.local.          0       IN      A       10.0.0.30

;; Query time: 2 msec
;; SERVER: 10.0.0.30#53(10.0.0.30)
;; WHEN: Thu July 14 13:44:51 ICT 2022
;; MSG SIZE  rcvd: 47

[root@client ~]# dig -x 10.0.0.30

; <<>> DiG 9.9.4-RedHat-9.9.4-29.el7_2.3 <<>> -x 10.0.0.30
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 61937
;; flags: qr aa rd ra ad; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;30.0.0.10.in-addr.arpa.                IN      PTR

;; ANSWER SECTION:
30.0.0.10.in-addr.arpa. 0       IN      PTR     soncq.local.

;; Query time: 3 msec
;; SERVER: 10.0.0.30#53(10.0.0.30)
;; WHEN: Thu July 14 13:47:51 ICT 2022
;; MSG SIZE  rcvd: 67

Leave a Comment

Your email address will not be published. Required fields are marked *

Bài viết gần đây:

Shopping Cart