CentOS 8.x dnsmasq

From Notes_Wiki

Home > CentOS > CentOS 8.x > DNS servers > dnsmasq

If we do not want to setup full fledged DNS using bind and only need a few A/MX records resolved, similar to /etc/hosts file then we can use dnsmasq. dnsmasq is often automatically deployed and used by libvirt. If KVM based virtualization is being used there might be dnsmasq already listening on default virbr0 - 192.168.122.1 on UDP Port 53.

If we need DNS services for VM with custom A records then we can use following steps:

  1. Create '/etc/dnsmasq.d/05-custom.conf' with
    addn-hosts=/etc/dnsmasq-hosts
  2. Add required hosts entries to '/etc/dnsmasq-hosts':
    10.1.1.10 server1.sbarjatiya.com server1
    10.1.1.11 server2.sbarjatiya.com server2
  3. Since 'systemctl stop dnsmasq' does not seems to work we need to kill the process using:
    killall dnsmasq
  4. Start and enable dnsmasq service:
    systemctl start dnsmasq
    systemctl enable dnsmasq
  5. After any changes to /etc/dnsmasq-hosts file, the service again needs to be restarted (killall dnsmasq, systemctl start dnsmasq) for changes to take effect.


Refer:


MX record resolution using dnsmasq

If we want to resolve MX query then we can create '/etc/dnsmasq.d/sbarjatiya.conf' with:

domain=sbarjatiya.com
mx-host=sbarjatiya.com,mail.sbarjatiya.com,5

Optionally there can be lines such as:

server=<ip-address>

for upstream DNS. This way only query for MX record for sbarjatiya.com would be answered via dnsmasq. Any other sbarjatiya.com query such as www.sbarjatiya.com instead of returning NXRECORD, can be queried via upstream recursive DNS and replied. Thus, we can add a few custom entries with help of dnsmasq without needing to copy all zone record.



Home > CentOS > CentOS 8.x > DNS servers > dnsmasq