如何更改我的Android设备的名称? -- settings 领域 和 dhcp 领域 android 相关 的问题

How do I change the name of my Android device?


简体版||繁體版
61
vote

问题

中文

我的Android设备是Nexus One。但这应该适用于所有当前的Android设备。

如何更改我的Android设备的名称?

当我连接到我的无线路由器的客户端表时,我的Android设备被列为:Android_1234567890abedfc。我想给它一个更可读的名字。

english

My Android device is the Nexus One. But this should apply to all current Android devices.

How do I change the name of my Android device?

When I connect to my wireless router's client tables, my android devices is listed for example as: android_1234567890abedfc. I'd like to give it a more readable name.

     
     
     

回答列表

22
 
vote
要更改主机名(设备名称),您必须使用终端(如root):

为Eclair(2.1): echo myname> / proc / sys / kernel / hostname

for froyo(2.2):(也在大多数2.3上工作) setprop net.hostname myname

然后重新启动您的Wi-Fi。 要查看更改,请键入uname -a

一些设备需要重新启动工作!

 

To change the hostname (device name) you have to use the terminal (as root):

For Eclair (2.1): echo MYNAME > /proc/sys/kernel/hostname

For Froyo (2.2): (works also on most 2.3) setprop net.hostname MYNAME

Then restart your wi-fi. To see the change, type uname -a

some devices needs reboot for work!

 
 
   
   
17
 
vote

摘要:

  • getprop net.hostname (Android系统主机名,可能是Android_24412414类型名称)
  • echo $HOSTNAME (shell / coder / env hostname,可能的可能ro.product.device from build.prop)
  • cat /proc/sys/kernel/hostname (linux system hostname,可能是 localhost
  • head /etc/hosts (linux system hostname,可能 localhost
  • hostname (如果通过繁忙框安装,则无法始终安装命令,将读取 / proc / sys / kernel / hostname

取决于您拥有的Android版本。

Android 4.0及更高版本

较新版本将使用右 build.prop 条目。好吧,也就是说,Android读取 build.prop ,因为它是正常的引导过程。连接服务运行后,它会检查是否在设置中设置net.hostname,然后如果为空,则使用"android_" +(永久)Android ID。所以这就是你需要做的一切。

添加 net.hostname=HOSTNAMEHERE /system/build.prop (可能需要root)。留在文件末尾的空白线条。

Kitkat的ConnectivityService.java,注意如果Isempty语句:

      // setup our unique device name     if (TextUtils.isEmpty(SystemProperties.get("net.hostname"))) {         String id = Settings.Secure.getString(context.getContentResolver(),                 Settings.Secure.ANDROID_ID);         if (id != null && id.length() > 0) {             String name = new String("android-").concat(id);             SystemProperties.set("net.hostname", name);   

Android 2.3及以下

旧版本,姜饼,froyo等,只需堵塞它。它不打算检查。它将将net.hostname设置为android_24412414 ...无论如何。因此,在连接服务完成后,您需要更改它。幸运的是,它只运行初始启动一次,而不是每一个新连接。所以我们只需要运行 echo $HOSTNAME0 以便它粘。不幸的是,它在启动过程中运行得相当迟到,因此您需要一些将使Boot_Complete更改的内容。最有可能由自己运行的应用程序。

Froyo的ConnectivityService.java :

  echo $HOSTNAME1  

但后来还有另一个问题。

net.hostname设置,未复制到整个系统!如果使用控制台/终端应用程序,则可能无法获得相同的主机名。我的手机是三星侧面伙伴4G(半银河系的SATH)有一个init.rc运行 echo $HOSTNAME2 ,所以所有下面的命令都不会看到你的build.prop主机名或android_id主机名!所以你也需要设置。

echo $HOSTNAME3 echo $HOSTNAME4

注意:根据您的执行方式,您需要将上面的命令用作root,以便它工作。 init.rc通常在只读系统分区上,因此需要root访问来编辑它。

运行以获取DHCP地址的DHCPCD命令不会更新到服务器提供的主机名(可以通过添加正确的DHCPCD运行挂钩和DHCPCD.conf来修复。它不会如果 echo $HOSTNAME5 (hostname命令)为空白或localhost提供主机名,则不会在内部使用net.hostname。 libnetutils用于使用-h"net.hostname" 调用dhcpcd,但如果由于某种原因决定不调用-h,则dhcpcd仍将通过gethostname()发送系统主机名,只要它不是" (无)"," localhost",或空的。在rocoyo无论如何。三星在一些像我这样的设备上搞砸了傻瓜。没有主机名通过,强制网络时间等。

我的姜饼和下面的Samsung解决方案,编辑DHCP客户端守护程序配置:

您可以做的最后一件事是编辑/etc/dhcpcd/dhcpcd.conf。如果将 echo $HOSTNAME6 添加到文件,则它将使用它,除非命令行上给出主机名。这不会修复Android_234ETC问题,但如果主机名是localhost(我的问题,因为Samsung锁定了Libnetuts和Init.rc)的localhost。您需要root,但这跨重启工作。如果使用-h hostname选项调用dhcpcd,则不会起作用。

 

Summary:

  • getprop net.hostname (Android System Hostname, likely android_24412414 type name)
  • echo $HOSTNAME (shell/terminal/env hostname, likely ro.product.device from build.prop)
  • 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 build.prop entry. Well, that is to say, Android reads the build.prop as it's normal boot process. Once the Connectivity Service runs, it checks to see if net.hostname 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 net.hostname=HOSTNAMEHERE to /system/build.prop (Root may be needed). Leave a blank line at the end of the file.

Kitkat's ConnectivityService.java, notice the IF isEmpty statement:

    // setup our unique device name     if (TextUtils.isEmpty(SystemProperties.get("net.hostname"))) {         String id = Settings.Secure.getString(context.getContentResolver(),                 Settings.Secure.ANDROID_ID);         if (id != null && id.length() > 0) {             String name = new String("android-").concat(id);             SystemProperties.set("net.hostname", name); 

Android 2.3 and Below

Older versions, Gingerbread, Froyo, etc, just clobber it. It doesn't bother to check. It will set net.hostname 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 net.hostname 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 ConnectivityService.java:

    // setup our unique device name     String id = Settings.Secure.getString(context.getContentResolver(),             Settings.Secure.ANDROID_ID);     if (id != null && id.length() > 0) {         String name = new String("android_").concat(id);         SystemProperties.set("net.hostname", name); 

But then there is another issue.

The net.hostname 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 init.rc which runs hostname localhost, so all underneath commands will not see either your build.prop 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. Init.rc 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 dhcpcd.conf), 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 net.hostname. libnetutils is used for calling dhcpcd with -h "net.hostname", 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/dhcpcd.conf. 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 init.rc). You will need Root, but this works across reboots. This won't work if dhcpcd is called with -h Hostname option.

 
 
 
 
10
 
vote

我发现了一种用4.2.2在我的rooted nexus 7上执行此操作的方法。该设置持久保存并在整个重新启动中工作。
来源: http: //nileshgr.com/2012/10/13/how-to-change-wifi-host-name-of-your-android-device

  1. 请注意,设备必须植根才能使用adb
  2. 运行 adb pull /system/build.prop
  3. 编辑 build.prop 文件和附加 net.hostname=NewHostname
  4. 运行 adb push build.prop /sdcard/build.prop (或 /mnt/sdcard ,如果它失败)
  5. 运行 adb shell 并执行以下命令:
    $ su
    # mount -o rw,remount /system
    # cp /sdcard/build.prop /system/build.prop (或 /mnt/sdcard 如果您之前使用过)
    build.prop0
    build.prop1
  6. 重新启动设备
 

I found a way to do this on my rooted Nexus 7 with 4.2.2. The setting is saved persistently and works throughout reboots.
Source: http://nileshgr.com/2012/10/13/how-to-change-wifi-host-name-of-your-android-device

  1. Note that the device must be rooted to use adb
  2. Run adb pull /system/build.prop
  3. Edit the build.prop file and append net.hostname=NewHostname
  4. Run adb push build.prop /sdcard/build.prop (or /mnt/sdcard, if it fails)
  5. Run adb shell and execute the following commands:
    $ su
    # mount -o rw,remount /system
    # cp /sdcard/build.prop /system/build.prop (or /mnt/sdcard if you used that previously)
    # mount -o ro,remount /system
    # exit
  6. Reboot the device
 
 
       
       
9
 
vote

这对CyanogenMod作品,可能是其他修改的ROM,但不是股票AOSP roms:

转到 settings>开发人员选项并向下滚动到设备hostname 。根本不需要。

(单击图像放大)

img:

 

This works on CyanogenMod and probably other modified ROMs but not stock AOSP ROMs:

Go to Settings > Developer Options and scroll down to Device Hostname. Root is not needed.

(Click image to enlarge)

IMG:

 
 
 
 
7
 
vote

我在很长一段时间内没有股票,但在应用程序设置中>开发您将看到"设备主机名" 选项。

 

I have not ran stock in a long time but in Application Settings > Development you will see the option 'Device hostname'.

 
 
     
     
5
 
vote

转到谷歌播放商店。搜索"hostname" ,然后下载 hostname更改器 app。

必须扎根。

 

Go to Google Play Store. Search for "hostname", and download hostname changer app.

Must be rooted.

 
 
 
 
1
 
vote

hostname用于轻松识别和记住连接到网络的主机。它在启动时设置,例如,来自 /etc/hostname 在基于Linux的系统上。 hostname也是 DHCPREQUEST 的一部分(标准化为代码12 如何通过hostname发出本地网络主机?。

android - 而不是使用linux kernel的 hostname service - 二手属性 net.hostname (自android 2.2 < / a>)为每个基于 android_id 的每个设备设置唯一的主机名。此主机名属性用于DHCP握手(如在Android 2.2 和 4.0 )。在Android 6 net.hostname 继续使用( 1 , 2 , 3 , 4 )在new Java DHCP客户端当本机 abcdefghijklmn5 服务被删除< / a>在Android 7.自android 8 - 当 android_id 变得唯一应用程序 - net.hostname 是不再设置,因此, null abcdefghijklmn9 中发送。查看Android 8 隐私更改和安全增强剂:

DHCPREQUEST0 现在是空的,DHCP客户端不再发送主机名

所以

所以 wifi路由器显示Android 8+的主机名,我们都不能设置/取消设置/更改它。

然而

然而

rooted设备上您可以使用 DHCPREQUEST2 命令设置 abcdefghijklmn11 命令或添加一些 DHCPREQUEST3 DHCPREQUEST4 文件设置每个引导。或者使用 DHCPREQUEST5 等第三方客户端将所需的主机名和其他选项发送到路由器。通过adb shell 连接到WiFi,请参阅连接到WiFi。

 

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.

 
 

相关问题

3  三星Galaxy S - 获取IP地址的问题。 “请求”  ( Samsung galaxy s problem obtaining ip address nak in request ) 
我无法从我的wifi路由器获取我的Android智能手机的IP地址。 观察: 与其他路由器或通过蜂窝数据的智能手机连接正常。 我的路由器与我的电脑的wifi连接是好的。 智能手机的WiFi链接到最近。 安全打开或关闭不会改变。 路由器是tpink wr541 v7。固件升级没有帮助。 问题持续存...

7  Droidwall和无线系绳  ( Droidwall and wireless tethering ) 
我有一个非常简单的问题:当我运行 Wifi Tether 时,除非我禁用 DroidWall 防火墙,否则计算机将无法获取IP地址。 dw以白名单模式运行,但我在其菜单上运行,以启用它找到的所有无线相关的应用程序。没有。我必须阻止它来制作DHCP服务器工作。 Android 4.1中的应用程序,或者至少在库存GS...

0  Android USB共享连接是否运行DHCP服务器?  ( Does android usb shared connection runs a dhcp server ) 
我知道Android的USB共享连接,我一直在使用它来连接到我的电脑。 还有一个旧的国内路由器,具有RJ45和无线接口。我一直在考虑使用USB-RJ45转换器将手机直接连接到路由器,以便根据路由器的RJ45交换接口向计算机提供互联网,以及使用WiFi的其他无线设备。 所以我的问题是:是Android USB共享连接运...

61  如何更改我的Android设备的名称?  ( How do i change the name of my android device ) 
我的Android设备是Nexus One。但这应该适用于所有当前的Android设备。 如何更改我的Android设备的名称? 当我连接到我的无线路由器的客户端表时,我的Android设备被列为:Android_1234567890abedfc。我想给它一个更可读的名字。 ...

10  如何更改DHCP配置?  ( How to change dhcp config ) 
我正在尝试从我的Android设备中的IMS客户端访问IMS核心,但是我需要修改DHCP客户端,以将核心的IP添加为DNS之一。在Linux操作系统的情况下,以下将作业:: cd /etc/dhcp3/ ; vi dhclient.conf ; /* add the line:: prepend domain-...

0  未通过Cyanogenmod连接到公共WiFi网络  ( Fail to connect to public wifi networks with cyanogenmod ) 
我将预先安装的操作系统更改为Cyanogenmod 9在我的xperia neo v上,从那时起,我无法连接到任何需要简单注册的免费公共网络(如机场,咖啡馆等)。 我的手机确实连接到网络(它说连接)但是当我打开浏览器(Opera)注册它永远不会连接时,播放失败后一段时间后无法连接消息。 这与这个其他问题我也有?要解...

15  通过主机名识别Android设备  ( Identifying an android device by its hostname ) 
我们网络中的每个Android设备都有主机名 android_[some-hex-number].domain.local 。我确实有一个要求10个IP地址(不同的Mac,但总是同一个主机名)的设备。有没有办法从该主机名中获取IMEI或序列号? 我找到了有关hostname的不同信息: http://comm...

3  更改DNS但留在DHCP上  ( Change dns but stay on dhcp ) 
我有一个"MINIX Neo X8-H Plus" Android电视盒,运行Android 4.4(Kitkat)。 我想在WiFi连接上更改DNS服务器,但要执行此操作,如果我更改为静态IP地址,我只能获得该选择。现在,在Windows或iOS上,您可以继续使用DHCP,同时将不同的DNS服务器设置为DHCP服务...

2  在4.0 ICS中访问Internet的问题  ( Problem accessing internet in 4 0 ics ) 
对于一些奇怪的原因,我的Android 4.0 ICS平板电脑不再能够访问Internet。 首先,通过WiFi,它可以连接到两个不同的网络。 然后,我试图通过DHCP将其连接到家庭路由器。它不能。 至于Wifi,平板电脑获得IP号。 我不知道这是怎么发生的,如果它是 route 问题或dns问题或其他。 试图安装终...

3  有没有办法每网络设置IP配置?  ( Is there a way to set the ip configuration on a per network basis ) 
我连接到多个wifi网络。在一些网络上,我必须使用静态IP地址。大多数DHCP配置都没有选择使用静态IP寻址。 因为这个原因,我希望能够使用特殊设置为网络设置特定的IP设置。是这样的事情吗? ...




© 2022 it.wenda123.org All Rights Reserved. 问答之家 版权所有