FORUMS
Remove All Ads from XDA

[SCRIPT] Change Hostname

71 posts
Thanks Meter: 33
 
By gumnaam.sur, Member on 16th January 2012, 01:15 AM
Post Reply Email Thread
No credit to me please.
I modified the script attached in http://forum.xda-developers.com/show....php?t=1366934, for LG Revo.

I merely changed /bin/hostname to /system/xbin/hostname, which is the correct path to access the hostname command in GingerVolt 1.3

Run using script manager, (su and on-boot).

Why change hostname ? Well by default the hostname is something like 'android_<IMEI-NO>', which is way too long, and makes it difficult to spot your device in your routers 'attached devices' log.

Change the "LGRevo" in the line "devName=LGRevo", to what ever hostname you like.

Code:
#!/system/bin/sh
#change devName to whatever you want.
devName=LGRevo

if [ "$(/system/xbin/hostname)" = "$devName" ] && [ "$(getprop net.hostname)" = "$devName" ]
then
	echo "Device hostname does not need to be changed."
else
	echo "Device hostname is being changed to $devName."
	/system/xbin/hostname $devName
	setprop net.hostname $devName
	if [ "$(/system/xbin/hostname)" != "$devName" ] && [ "$(getprop net.hostname)" != "$devName" ]
	then
		echo "Device hostname has not been changed."
	else
		echo "Device hostname has been successfully changed."
	fi
fi
Attached Files
File Type: txt Hostname.sh.txt - [Click for QR Code] (562 Bytes, 593 views)
The Following 3 Users Say Thank You to gumnaam.sur For This Useful Post: [ View ] Gift gumnaam.sur Ad-Free
 
 
16th January 2012, 01:58 PM |#2  
spc_hicks09's Avatar
Recognized Contributor
Flag Marion, OH
Thanks Meter: 1,868
 
Donate to Me
More
Quote:
Originally Posted by gumnaam.sur

Why change hostname ? Well by default the hostname is something like 'android_<IMEI-NO>', which is way too long, and makes it difficult to spot your device in your routers 'attached devices' log.

Nice find, just a quick question though.

Is there any way you could elaborate a little more on this? Why is shortening the hostname and making it easier to find in the "attached devices" log important?
16th January 2012, 03:15 PM |#3  
OP Member
Thanks Meter: 33
 
More
More explanation on why change the hostname....

As of this writing I have about 6 android devices connected to my home wifi router. Most wifi routers have a page which shows the details of attached devices. This helps you to determine if any unwanted device has managed to hook on your wifi etc.

With the default hostname like 'android_<IMEI-NO>', the list of attached devices is hard to de-cipher. So changing the hostname enables me to make some sense out of the 'attached devices' page. I know exactly which device has hooked to my router.

Secondly, on my router's config, I have assigned static DHCP for all these devices, and also entered them in the DNS. That way each device can talk to another if needed, say over 'SMB' / 'SSH', simply by using the other device's hostname, w/o having to remember each devices IP.

Makes sense ?
16th January 2012, 03:21 PM |#4  
spc_hicks09's Avatar
Recognized Contributor
Flag Marion, OH
Thanks Meter: 1,868
 
Donate to Me
More
Quote:
Originally Posted by gumnaam.sur

More explanation on why change the hostname....

As of this writing I have about 6 android devices connected to my home wifi router. Most wifi routers have a page which shows the details of attached devices. This helps you to determine if any unwanted device has managed to hook on your wifi etc.

With the default hostname like 'android_<IMEI-NO>', the list of attached devices is hard to de-cipher. So changing the hostname enables me to make some sense out of the 'attached devices' page. I know exactly which device has hooked to my router.

Secondly, on my router's config, I have assigned static DHCP for all these devices, and also entered them in the DNS. That way each device can talk to another if needed, say over 'SMB' / 'SSH', simply by using the other device's hostname, w/o having to remember each devices IP.

Makes sense ?

Oh ok cool! I never even thought of doing it so it's easier to check for unwanted devices. Very nice find, thanks!
Post Reply Subscribe to Thread

Tags
hostname script

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes