Change Android Hostname Without Root

How do I change the name of my Android device?

Summary:
getprop name (Android System Hostname, likely android_24412414 type name)
echo $HOSTNAME (shell/terminal/env hostname, likely from)
cat /proc/sys/kernel/hostname (Linux System Hostname, likely localhost)
head /etc/hosts (Linux System Hostname, likely localhost)
hostname (Command not always installed, if installed via busy box, will read /proc/sys/kernel/hostname)
Depends on which version of Android you have.
Android 4. 0 and Above
Newer versions will use the right entry. Well, that is to say, Android reads the as it’s normal boot process. Once the Connectivity Service runs, it checks to see if name is set in the Settings, then if empty, then it uses the “android_” + (permanent) android ID. So that’s all you need to do.
Add name=HOSTNAMEHERE to /system/ (Root may be needed). Leave a blank line at the end of the file.
Kitkat’s, notice the IF isEmpty statement:
// setup our unique device name
if (Empty((“name”))) {
String id = (tContentResolver(), );
if (id! = null && () > 0) {
String name = new String(“android-“)(id);
(“name”, name);
Android 2. 3 and Below
Older versions, Gingerbread, Froyo, etc, just clobber it. It doesn’t bother to check. It will set name to android_24412414… no matter what. So you will need to change it after that Connectivity Service has finished loading. Luckily, it only runs the startup once, not on every new connection. So we just need to run setprop name HOSTNAMEHERE after that for it to stick. Unfortunately, it runs fairly late in the boot process, so you need something that will make the changes on boot_complete. Most likely an App that runs by itself.
Froyo’s
String name = new String(“android_”)(id);
But then there is another issue.
The name setting, is not copied to the entire system! If you use a console/terminal application, you might not get the same hostname. My phone, a Samsung Sidekick 4G (semi-Galaxy S based) has an which runs hostname localhost, so all underneath commands will not see either your hostname or the android_id hostname! So you need to set that too.
hostname HOSTNAMEHERE or echo HOSTNAMEHERE > /proc/sys/kernel/hostname
Note: Depending on how you are doing it, you’ll need to run the above command as root in order for it to work. is typically on the read only system partition, so root access is needed to edit it.
The dhcpcd command, which is run to get a dhcp address, will not update to a hostname provided by the server (That can be fixed by adding the right dhcpcd-run-hooks and), and it will not provide a hostname to the dhcp server if $(hostname) (The hostname command) is blank or localhost, and it does not internally use name. libnetutils is used for calling dhcpcd with -h “name”, but if for some reason it decides not to call with -h, DHCPCD WILL STILL SEND THE SYSTEM HOSTNAME via gethostname(), as long as it’s not “(none)”, “localhost”, or empty. On Stock Froyo anyway. Samsung screwed the pooch on some devices like mine. No hostname pass through, forced network time, etc.
My Solution for Gingerbread and below Samsung, Edit the DHCP Client Daemon config:
The last thing you can do is edit /etc/dhcpcd/ If you add hostname YOURHOSTNAME to the file, it will use that, unless a hostname is given on the commandline. This won’t fix the android_234etc issue, but will if the hostname is localhost (My problem, since Samsung screwed libnetutils and localhost in). You will need Root, but this works across reboots. This won’t work if dhcpcd is called with -h Hostname option.
How do I change the name of my Android device?

How do I change the name of my Android device?

Summary:
getprop name (Android System Hostname, likely android_24412414 type name)
echo $HOSTNAME (shell/terminal/env hostname, likely from)
cat /proc/sys/kernel/hostname (Linux System Hostname, likely localhost)
head /etc/hosts (Linux System Hostname, likely localhost)
hostname (Command not always installed, if installed via busy box, will read /proc/sys/kernel/hostname)
Depends on which version of Android you have.
Android 4. 0 and Above
Newer versions will use the right entry. Well, that is to say, Android reads the as it’s normal boot process. Once the Connectivity Service runs, it checks to see if name is set in the Settings, then if empty, then it uses the “android_” + (permanent) android ID. So that’s all you need to do.
Add name=HOSTNAMEHERE to /system/ (Root may be needed). Leave a blank line at the end of the file.
Kitkat’s, notice the IF isEmpty statement:
// setup our unique device name
if (Empty((“name”))) {
String id = (tContentResolver(), );
if (id! = null && () > 0) {
String name = new String(“android-“)(id);
(“name”, name);
Android 2. 3 and Below
Older versions, Gingerbread, Froyo, etc, just clobber it. It doesn’t bother to check. It will set name to android_24412414… no matter what. So you will need to change it after that Connectivity Service has finished loading. Luckily, it only runs the startup once, not on every new connection. So we just need to run setprop name HOSTNAMEHERE after that for it to stick. Unfortunately, it runs fairly late in the boot process, so you need something that will make the changes on boot_complete. Most likely an App that runs by itself.
Froyo’s
String name = new String(“android_”)(id);
But then there is another issue.
The name setting, is not copied to the entire system! If you use a console/terminal application, you might not get the same hostname. My phone, a Samsung Sidekick 4G (semi-Galaxy S based) has an which runs hostname localhost, so all underneath commands will not see either your hostname or the android_id hostname! So you need to set that too.
hostname HOSTNAMEHERE or echo HOSTNAMEHERE > /proc/sys/kernel/hostname
Note: Depending on how you are doing it, you’ll need to run the above command as root in order for it to work. is typically on the read only system partition, so root access is needed to edit it.
The dhcpcd command, which is run to get a dhcp address, will not update to a hostname provided by the server (That can be fixed by adding the right dhcpcd-run-hooks and), and it will not provide a hostname to the dhcp server if $(hostname) (The hostname command) is blank or localhost, and it does not internally use name. libnetutils is used for calling dhcpcd with -h “name”, but if for some reason it decides not to call with -h, DHCPCD WILL STILL SEND THE SYSTEM HOSTNAME via gethostname(), as long as it’s not “(none)”, “localhost”, or empty. On Stock Froyo anyway. Samsung screwed the pooch on some devices like mine. No hostname pass through, forced network time, etc.
My Solution for Gingerbread and below Samsung, Edit the DHCP Client Daemon config:
The last thing you can do is edit /etc/dhcpcd/ If you add hostname YOURHOSTNAME to the file, it will use that, unless a hostname is given on the commandline. This won’t fix the android_234etc issue, but will if the hostname is localhost (My problem, since Samsung screwed libnetutils and localhost in). You will need Root, but this works across reboots. This won’t work if dhcpcd is called with -h Hostname option.
How to set friendly network name of android computer?

How to set friendly network name of android computer?

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?
asked Apr 4 ’12 at 15:03
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 name
setprop name
wjandrea5686 silver badges19 bronze badges
answered Jan 22 ’13 at 15:45
timonskutimonsku6288 silver badges13 bronze badges
7
Open terminal. Enter the following:
su
Root access is required.
answered Jan 12 ’15 at 11:26
bayuahbayuah1811 silver badge5 bronze badges
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 name (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 name 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 – name is no more set, so a null is sent in DHCPREQUEST. See Android 8 Privacy Changes and Security Enhancements:
name 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 name manually using setprop command or add in some init’s 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.
answered Nov 22 ’19 at 20:36
Irfan LatifIrfan Latif2213 silver badges9 bronze badges
In some Android phones, you may change in Wi-Fi Direct
Settings
WiFi
Top right menu > Advanced
Wi-Fi Direct
Top right option Rename device
Write your new device name and press OK
Turn off and on your Wi-Fi
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.
answered Mar 2 ’18 at 10:51
Paulo CoghiPaulo Coghi9541 gold badge10 silver badges14 bronze badges
2
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.
answered Apr 4 ’12 at 15:20
paradd0xparadd0x8, 6236 gold badges34 silver badges43 bronze badges
4
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:
answered Apr 7 ’18 at 22:25
On my Galaxy Edge S7 the device friendly name can be changed under “About phone” (near the bottom of the Settings menu):
Since I configured it to “Matthijs mobiel”, our local router gave me the hostname “”. 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).
answered Feb 19 at 22:43
MatthijsMatthijs2362 silver badges5 bronze badges
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.
answered Feb 8 ’13 at 2:35
Not the answer you’re looking for? Browse other questions tagged networking android or ask your own question.

Frequently Asked Questions about change android hostname without root

How can I change my Android hostname without root?

Go to Settings > Developer Options and scroll down to Device Hostname. Search for “hostname”, and download hostname changer app.

How do I change my hostname on Android?

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.

How do I find my hostname on Android?

On Android Open the Settings app, then tap About phone. It will show the device info, including the device name.Jun 29, 2021

Leave a Reply

Your email address will not be published. Required fields are marked *