How to make Termius look for hostnames on the local network first? I have four devices:


Windows 10 PC
Android Phone (v6.0.1)
Internet Router
"servername" (Raspberry Pi 4)


All are connected locally using Wifi (not that it should matter) using the simplest possible configuration imaginable.  Every device has working internet access.  Everything talks with everything else nicely apart from when I try to use Termius on Android to ssh into "servername".

On the PC I can simply issue the command putty fred@servername and I can login without difficulties, as one would expect.

However Termius on the Android phone does not seem to understand that "servername" is attached locally to the same wifi network as the phone itself.  If I open a local SSH session on the phone itself and ping "servername", then it appears to be going after some random internet IP address (92.xxx.xxx.xxx) and fails to login.

If I use the server's local IP address (192.168.xxx.xxx) then Termius can SSH to it with no issues.

So, how can I persuade Termius (free version) to understand local network host names?  I cannot find any settings that correspond to this problem.
So, how can I persuade Termius (free version) to understand local network host names?


In fact you have to persuade Android OS, not a specific app. Resolving hostnames is handled by Android's C library to which apps are linked through APIs at the time of compiling.


  On the PC I can simply issue the command putty fred@servername and I can login without difficulties, as one would expect.


You haven't mentioned which Wi-Fi router you are using and if you have a DHCP/DNS server running on local network or not. But to resolve local hostnames on Android, you must have a local DNS server running. Usually Wi-Fi router is the DHCP/DNS server.


  I cannot find any settings that correspond to this problem.


That's the difficult part, you have to configure your phone to use a local DNS server but Android doesn't provide a straightforward way to do this.


  If I open a local SSH session on the phone itself and ping servername, then it appears to be going after some random internet IP address (92.xxx.xxx.xxx) and fails to login.


It indicates that Android phone is sending DNS queries to internet. You have to make sure that DNS queries are sent to the local DNS server only. Public DNS servers don't know what hostnames you have set on your private network. Android loves Google so much, so you will often find queries going to 8.8.8.8 (may be when router is advertising the IPv6 DNS server). Configure static IP in Wi-Fi settings to set IP address of local DNS server as the first (and preferably only) DNS. Or if you have root you can use Android kernel's built-in firewall netfilter to force a nameserver. Since DNS uses UDP port 53, do a Destination Network Address Translation (DNAT):

~# iptables -t nat -I OUTPUT -p udp --dport 53 -j DNAT --to 192.168.1.1:53


Non-root solution which works for both Wi-Fi and Mobile data is to use a VPN app like Virtual Hosts which intercepts DNS traffic and makes queries to configured upstream DNS server.

This should resolve your problem.

For more details please see How to ping a local network host by hostname?.

Related: How DNS works on Android?