Hero Image

Dnsmasq setup on centos 7

Configuring the server

Create a file /etc/dnsmasq.d/main.conf containing the following:

# ignore resolv.conf
no-resolv

# use google dns servers for internet lookups
server=8.8.8.8
server=8.8.4.4

# define localdomain, answers for this domain will come from /etc/hosts or static hosts files
local=/local/
auth-zone=/local/

# don't require FQDN for local domain hostnames
expand-hosts

# in addition to entries in /etc/hosts
# read in all the files in this directory for hosts
# entries.  All such files should be in /etc/hosts format
addn-hosts=/etc/dnsmasq.d/static

Enabling and starting the service

systemctl enable dnsmasq.service
systemctl start  dnsmasq.service

Adding/editing a host

# create a one-liner file in /etc/dnsmasq.d/static
# with content ala a host file entry for that host
echo "192.168.0.123 foo.local foo" > /etc/dnsmasq.d/static/foo
# then sighup the dnsmasq process
systemctl kill -s HUP dnsmasq.service
# at this point you should be able to resolv 'foo'
dig foo

Other Related Posts:

Cacti with apache, mariadb on AMI 2018 Linux

Install apache, mod_ssl, net-snmp and php72 modules

yum install httpd24 mod24_ssl.x86_64 php72 net-snmp net-snmp-utils php72 php72-xml php72-session php72-sockets php72-ldap php72-gd php72-gmp php72-intl php72-mbstring php72-mysqlnd php72-pdo php72-process php72-snmp php72-mysql php72-pear php72-c...

Read more

29th Jul 2020