How to make Termius look for hostnames on the local network first?


Question

I have four devices:




  1. Windows 10 PC

  2. Android Phone (v6.0.1)

  3. Internet Router

  4. "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.


Answer


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?


Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes