I am trying to set up an Android SSH client to connect to another machine on my local network. I can connect if I use the IP address, but the IP address can change. How can I determine the hostname that my Android device assigns to the other machine, so that I can connect using that instead?

(Right now the specifics happen to be using JuiceSSH to connect to an Ubuntu 13.10 laptop running sshd and mosh-server, but I'd like to learn a general approach that is not client or target specific. Ideally, a system-level Android command.)

1 Answer 1


For that, you'd need a local DNS server on your local network, which gets updated by the DHCP server assigning the IP to that machine (many routers offer this feature).

You can then tell your Android device to use that DNS as primary when connected to your WiFi network, while leaving the secondary as-is (so the latter would still resolve everything outside your network). This option is located in the WiFi APN settings: Long-press the entry for your home WiFi, select to edit it, enable "advanced options".

  • I think you're answering "how can I use the same IP address on a given network every time?" - what I'd like to do is find out what hostname the Android device sees, so I can use that instead of the IP address - let me know if I've misunderstood your answer
    – lofidevops
    Commented Mar 10, 2014 at 12:53
  • No, I don't. The DHCP server is assigning the IP to your PC. If the same server acts as DNS server, it can tell that to your device. For details on this part, Super User is the better part to ask. On the Android part, you just configure what DNS servers to use. I'm not sure it that setting persists when you switch back to DHCP afterwards, so you might be correct that using a fixed IP address for your Android device could be involved as well.
    – Izzy
    Commented Mar 10, 2014 at 12:57
  • ok, I think I get it - the Android device can't tell me "I see that the hostname of your laptop at IP address is yourhost.local" but I can dig into the DNS server itself to see what hostname it has assigned to my laptop, and then hook up my Android device to that DNS server and use that hostname
    – lofidevops
    Commented Mar 10, 2014 at 13:52
  • (and without access to the DHCP and/or DNS server, there's nothing I can do)
    – lofidevops
    Commented Mar 10, 2014 at 13:52
  • 1
    @d3vid every machine on the network should be able to query the DNS server, that's exactly what it's there for. I can't try them at the moment, but if you search the Play Store for something like "nslookup" those tools should allow you to query the DNS server.
    – GAThrawn
    Commented Mar 10, 2014 at 16:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .