Follow the instruction:
1.Add the DNS server to host:
sudo echo "nameserver my.new.dns.server" | sudo tee /etc/resolv.conf
2.Add the new DNS server to the dnsmasq config file:
sudo sed "s/server=.*/server=my.new.dns.server/g" /etc/dnsmasq.confq
3.Restart dnsmasq service:
sudo systemctl reload dnsmasq
or test this one:
sudo service dnsmasq restart
You can also use this little command to it:
sudo echo "nameserver my.new.dns.server" | sudo tee /etc/resolv.conf && sudo sed "s/server=.*/server=my.new.dns.server/g" /etc/dnsmasq.confq && sudo systemctl reload dnsmasq
There is also another way which pihole clients DNS is your host and you just need to change the hosts DNS server.
For example (the host ip is 192.168.1.100):
sudo sed "s/server=.*/server=192.168.1.100/g" /etc/dnsmasq.confq
Then
sudo echo "nameserver my.new.dns.server" | sudo tee /etc/resolv.conf