On a Mac you may want names under your home domain to go to the router, while everything else keeps using the DNS from the network you happen to be on. macOS has a simple, old mechanism for that.
Create a file named after the domain:
sudo mkdir -p /etc/resolver
echo "nameserver 192.0.2.1" | sudo tee /etc/resolver/home.example
From now on, lookups for home.example and its subdomains go to 192.0.2.1. The man page for resolver(5) says the file name is used as the domain name, so you do not need a domain line inside. You can add up to three nameserver lines, and a port line if your server listens somewhere else than 53.
Check that macOS picked it up:
scutil --dns | grep -A3 home.example
Here comes the part I find confusing. nslookup and dig do not use this system; they read /etc/resolv.conf and ask that server directly. So they will tell you it does not work while Safari and ssh resolve the name fine. Test with dscacheutil -q host -a name nas.home.example or just ping.
To undo it, delete the file. It needs no restart either way.
Further reading: resolver(5) man page