By default, the operating system uses the dns servers configured in /etc/resolv.conf and for each lookup it will ask the same set of dns servers. It is possible to configure dnsmasq to use different dns servers for specific domains.
When looking for entries in xyz.com dnsmasq should ask dns server 192.168.1.1, and when using abc.com, it should ask dns server 192.168.100.1.
1. Install dnsmasq:
# yum install dnsmasq
2. Enable it to start at boot:
# systemctl start dnsmasq
3. Take a backup of the original configuration:
# cp /etc/dnsmasq.conf /etc/dnsmasq.conf.orig
4. Adjust the default configuration:
# vi /etc/dnsmasq.conf
and set the following basics:
listen-address=::1,127.0.0.1,[your nics ip] interface=[your nic, eg eth0 and lo] expand-hosts domain=[your default domain name]
Then configure xyz.com and abc.com:
server=/xyz.com/192.168.1.1 server=/1.168.192.in-addr.arpa/192.168.1.1 server=/abc.com/192.168.100.1 server=/100.168.192.in-addr.arpa/192.168.100.1
and set the default dns server:
server=169.254.169.254
so all lookups for xyz.com and the reverse lookups 1.168.192.in-addr.arpa go to 192.168.1.1, while abc.com and the reverse lookups go to 192.168.100.1. All other lookups go to 169.254.169.254.
5. Then start dnsmasq:
# systemctl start dnsmasq
6. Replace the current nameserver in /etc/resolv.conf with 127.0.0.1 (dnsmasq is listening there):
# vi /etc/resolv.conf search [your default domain].com abc.com xvz.com nameserver 127.0.0.1