How to configure nslookup/dig to resolve hostnames mentioned in /etc/hosts? DNS masquerade
Posted: Tue Jul 24, 2018 3:51 pm
nslookup and dig cannot resolve IP address from /etc/hosts since it was not design that way. There is a workaround that can help resolve entries in /etc/hosts.
You may need an account with Red Hat to access the following link:
https://access.redhat.com/site/solutions/46767
Steps:
You may need an account with Red Hat to access the following link:
https://access.redhat.com/site/solutions/46767
Steps:
- Install DNSMASQ
Code: Select all
# yum install dnsmasq -y
- Edit /etc/resolve.conf to add the following line lookup the localhost
Code: Select all
nameserver 127.0.0.1
- Add the following lines in /etc/dnsmasq.conf
Code: Select all
domain-needed bogus-priv filterwin2k resolv-file=/etc/resolv.external expand-hosts domain=example.com log-queries log-facility=/var/log/dnsmasq conf-dir=/etc/dnsmasq.d
- Make a file for to specify external DNS server
Code: Select all
cp /etc/resolv.conf /etc/resolv.external
- Put the entry of your entries not in DNS into /etc/hosts
Code: Select all
1.1.1.1 test.xyz.com
- Start DNSMASQ Service
Code: Select all
# service dnsmasq start
- check the results
Code: Select all
# nslookup test.xyz.com Server: 127.0.0.1 Address: 127.0.0.1#53 Name: test.xyz.com Address: 1.1.1.1
Code: Select all
# service dnsmasq restart
Shutting down dnsmasq: [ OK ]
Starting dnsmasq: [ OK ]