I have a server on my local network which I resolve its name as using this /etc/hosts entry:
This works fine, so 'ping localserver' or 'ssh localserver' will resolve to 184.108.40.206 and work. Now when I'm not at home (i.e. not on my local wifi network) I need to access the server using its FQDN, localserver.mydomain.com.
This worked fine in Ubuntu 16.04. Because the /etc/hosts entry only specified the simple name 'localserver' and not the full FQDN 'localserver.mydomain.com', doing 'ssh localserver.mydomain.com' would use whatever DNS server was configured on whatever network I was connected to (e.g. Google Public, Cloudflare) to resolve localserver.mydomain.com and get its public IP.
The problem is that this no longer works on 18.04, probably because of systemd-resolved. Now even localserver.mydomain.com gets resolved using /etc/hosts to 192.168.0.4, which is no good because I need that FQDN to resolve to the public IP using DNS, not /etc/hosts.
Is there a way I can configure sytsemd-resolved to do this? Or do I have to switch back to dnsmasq? which I sometimes need to access