45

I see names of computers in my router's DHCP leasing list. My android galaxy tab is listed under an alphanumeric name. How do I set a friendly name that I like?

Suzan Cioc
  • 2,543
  • 12
  • 38
  • 52

12 Answers12

30

On Android 4.4 and lower, you can change the hostname to a less cryptic name in the Developer Options under Settings. Under the "Debugging" section in the Developer Options you will see an option called "Device hostname" which should currently be set to this rather cryptic name. You can change it to any alpha numeric name you like.

If you are on Android 5.0, that option is not there anymore. Though using the ADB shell still works. See bayuah's answer. Root doesn't seem to be required on my phone. From the answer linked above:

adb shell
getprop net.hostname
setprop net.hostname <new_hostname>
wjandrea
  • 595
  • 8
  • 19
timonsku
  • 668
  • 8
  • 13
17

Open terminal. Enter the following:

adb shell
su
getprop net.hostname
setprop net.hostname <new_hostname>

Root access is required.

bayuah
  • 301
  • 2
  • 5
  • 1
    it's sad that with no root access, it doesn't complain when you invoke setprop, it just doesn't take effect (checked with getprop). Also su fails for me: "/system/bin/sh: su: not found". Is that an indicator of device not rooted or that the device doesn't offer an su option? Or is this something missing in my ADB install? – David Jan 06 '16 at 20:57
  • Yes. It's either your device isn't support root access or you aren't manually rooting the device yet. – bayuah Jan 06 '16 at 22:35
  • @David: "Is that an indicator of device not rooted or that the device doesn't offer an su option?" - Those are the same thing. A rooted device gives you the `su` command to gain root privileges from a shell; a non-rooted device doesn't have that command. – micheal65536 Apr 29 '16 at 06:33
  • @bayuah - I can do this by opening a terminal program on my phone. All the above commands work, and `getprop ...` returns the new hostname, even when I exit out of the `su`; but the hostname that is broadcast does not change, and it doesn't stick when I reboot. Thoughts? – Diagon Jun 28 '16 at 17:31
  • @Diagon What's your Android version? I was try it on my 4.1.1. Perhaps it's work for you: http://android.stackexchange.com/a/43559/69442. A little bit work though. Basically it's edit the `/system/build.prop` file. – bayuah Jun 28 '16 at 17:56
  • @bayuah - I'm on 4.0.4. Thanks for the suggestion. I'll have a look at that link. – Diagon Jul 01 '16 at 19:59
  • 1
    One note4 6.0, the value gets reset after reboot. – Abhishek Anand Jul 05 '16 at 18:24
13

Hostname is used to easily identify and remember hosts connected to a network. It's set on boot, e.g. from /etc/hostname on Linux based systems. Hostname is also a part of DHCPREQUEST (standardized as code 12 by IETF) which a DHCP client (Android device in our case) makes to DHCP server (WiFi router) to get an IP address assigned. DHCP server stores the hostnames to offer services like DNS. See details in How to ping a local network host by hostname?.

Android - instead of using Linux kernel's hostname service - used property net.hostname (since Android 2.2) to set a unique host name for every device which was based on android_id. This hostname property was used for DHCP handshake (as added in Android 2.2 and 4.0). In Android 6 net.hostname continued to be used (1, 2, 3, 4) in new Java DHCP client when native dhcpcd was abandoned and later service was removed in Android 7. Since Android 8 - when android_id became unique to apps - net.hostname is no more set, so a null is sent in DHCPREQUEST. See Android 8 Privacy Changes and Security Enhancements:

net.hostname is now empty and the dhcp client no longer sends a hostname

So the WiFi routers show no host names for Android 8+, neither we can set / unset / change it.

However on rooted devices you can set net.hostname manually using setprop command or add in some init's .rc file to set on every boot. Or use a third party client like busybox udhcpc to send desired hostname and other options to router. See Connecting to WiFi via ADB Shell.

Irfan Latif
  • 461
  • 5
  • 11
8

In some Android phones, you may change in Wi-Fi Direct

  1. Settings
  2. WiFi
  3. Top right menu > Advanced
  4. Wi-Fi Direct
  5. Top right option Rename device
  6. Write your new device name and press OK
  7. Turn off and on your Wi-Fi
  8. If it has no effect, restart your phone.

Important: Not all Android phones have this option, and not all phones modify their hostname correctly, even after modifying the device name from that option.

Paulo Coghi
  • 1,174
  • 1
  • 11
  • 14
  • 2
    Thanks for this answer! Unfortunately I found it only after I changed hostname using `su & setprop`, but it is great to know this option is available. – MarSoft May 14 '19 at 00:08
  • My Moto G6 with Android 9 has that set already, but the router says the hostname is `--`. – wjandrea Oct 06 '20 at 21:22
2

Just wanted to reference another related solution I came across using ADB (and requires rooted device): http://nileshgr.com/2012/10/13/how-to-change-wifi-host-name-of-your-android-device. I would however prefer the ADB commands presented here on SO than this link, but it's another method at least.

David
  • 129
  • 6
2

On my Galaxy Edge S7 the device friendly name can be changed under "About phone" (near the bottom of the Settings menu):

Screenshot of "About phone" panel

Since I configured it to "Matthijs mobiel", our local router gave me the hostname "Matthijs-mobiel.fritz.box". Unfortunately it sounds like your router might be assigning a name based on MAC address rather than based on the device friendly name, in which case this probably won't help (though you can try configuring a name that's a valid hostname already, perhaps it will work).

Matthijs
  • 276
  • 2
  • 5
1

The name that is sent to the DHCP server is not the hostname as is commonly thought, it's the VID (Vendor ID Code) which you cannot change. You could try changing the name at the router level if possible.

paradd0x
  • 9,149
  • 7
  • 37
  • 44
0

This solution is using the commands posted by @bayuah above, but not using adb nor su at all. This is on a rooted device (Nougat AOSP 7.1.2). Using JuiceSSH terminal, enter two commands:

getprop net.hostname
setprop net.hostname <new_hostname>
scrat.squirrel
  • 303
  • 2
  • 10
0

Android 8.1 (possibly later as well) on Samsung Galaxy Tab...

Settings/About Tablet..."Edit"

0xG
  • 101
  • 1
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Dec 19 '21 at 21:54
0

On LineageOS 10, I could simply search in the settings for hostname and it led me to

System -> Developer Options -> Device hostname

This answer of course requires to have developer options activated, but other than that it is possible that it also works on other android versions than LineageOS.

lucidbrot
  • 488
  • 1
  • 6
  • 21
0

After struggling a lot and spending days over this, I'm going to share my experience with the community:

  1. udhcpc [RECOMMENDED]
    Udhcpc is a very small DHCP client program geared towards embedded systems. It's maintained as a part of BusyBox
    To change the hostname with udhcpc use the -h flag:
    busybox udhcpc -x hostname:READABLE_HOSTNAME
    It's persisted, and works prefect. It has more features you can read more about udchpc here.
  2. Changing the net.hostname property
    setproperty net.hostname READABLE_HOSTNAME
    and to presist it you can append net.hostname=READABLE_HOSTNAME to the /system/build.prop

This solution might not work on some Android version, I had problems with Android 11. It was working perfectly on Android 10 but after upgrading to Android 11 it stopped working.
And be aware that touching the system files can be very dangerous and brick your device.

alizeyn
  • 101
  • 3
-4

Simply download and install the app called "Change Hostname" from the Play Store and enjoy editing your android device hostname (android-xxxxxxxxxxx).

Root access is required though, sorry for the non-rooted users.

Regards.

MuRToN
  • 1