[SCRIPT] Change Hostname - LG Revolution

No credit to me please.
I modified the script attached in http://forum.xda-developers.com/showthread.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

gumnaam.sur said:
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.
Click to expand...
Click to collapse
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?

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 ?

gumnaam.sur said:
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 ?
Click to expand...
Click to collapse
Oh ok cool! I never even thought of doing it so it's easier to check for unwanted devices. Very nice find, thanks!

Related

How to change the X1 mac address?

Hi,
yesterday i tried nearly the whole day to change my mac address on my x1. first i made a hardspl for x1. the new bootloader is working.
After that, i connected via mtty. I tried some commands like emapiTest, emapiWlanMac and some other what i found at xda-dev. I only go "command error" in mtty.
Then i flashed the latest rom (R2A) and tried it again with mtty. Same bad results.
There is a posting at xda-dev: NOTE: To use rbmc you need to
authenticate with proper password .... otherwise bootloader returns "Command error !!!" or "Command is Locked!". (if you're using Hard-SPL, this is unlocked, and any address can be read with 2.30.Olipro)
Do i make the same authenticate with the X1 HardSpl that i am able to work with any commands?
Best regards
strohrum
You can't change the MAC address of a network device. It's the unique hardware serial number of the network device.
My guess is that you're trying to get your Xperia to connect to a hotspot that only allows specific MAC addresses. In that case it makes more sense to find the wifi MAC address of your phone, go into the configuration page for your wifi router and enter the MAC address on the filter list.
You can get the phone's wifi MAC fairly easily. Turn on wifi, then:
Start > Settings > Connections > Wireless LAN > Advanced
... and the MAC is there for you.
ZenithUK said:
You can't change the MAC address of a network device. It's the unique hardware serial number of the network device.
My guess is that you're trying to get your Xperia to connect to a hotspot that only allows specific MAC addresses. In that case it makes more sense to find the wifi MAC address of your phone, go into the configuration page for your wifi router and enter the MAC address on the filter list.
You can get the phone's wifi MAC fairly easily. Turn on wifi, then:
Start > Settings > Connections > Wireless LAN > Advanced
... and the MAC is there for you.
Click to expand...
Click to collapse
Actually it is possible to "spoof" a network device.
I'm just not sure how to do this on a WM device.
i tried the registry method... didnt find any data for mac address
and i tried what jockyw wrote:
"You can run or flash the USPL (see sticky) and set a MAC address of your own choice.
Connect with MTTY and at the command prompt type:
emapiWlanMac 01 02 03 04 05 06 (the six two-digit numbers are the hexadecimal MAC byte values and should be replaced by anything you like)"
but i only get "command error" at any command.
strohrum said:
How to change the X1 mac address?
Click to expand...
Click to collapse
Is that legal ??
who cares ?
exxi said:
who cares ?
Click to expand...
Click to collapse
hmmm...
Maybe you are right and xda-devs wouldn't care about that...
.
That is not legal I am sure.
Legal WHERE? 50% of the content here is probably not koscher! What a stupid question!
ANY medling with software is illegal worldwide! Read the license agreements!
I would suggest NOT to discuss this...waste of time and effort! Just a thought ;-)
why should be illegal to change mac address? It's not IMEI
guap said:
why should be illegal to change mac address? It's not IMEI
Click to expand...
Click to collapse
BTW, I was just asking, not stating
Fulgore69 said:
That is not legal I am sure.
Click to expand...
Click to collapse
Well, its not illegal in the "go to jail" sense... but more of a torts way. SE won't care that a relatively small group is tinkering with their own phones since it doesn't affect their income at all. Rather, if we filed a warranty claim, they can deny it on breach of terms.
The only time a modified MAC could be considered "illegal" is if you are pirating as a result of modifying it.
Why would you even want to change the mac-adress?
Fulgore69 said:
That is not legal I am sure.
Click to expand...
Click to collapse
Please don't assume that something is illegal simply because it's "sometimes" associated with "hacking". Password recovery is not illegal, port scanning is not illegal, packet sniffing is not illegal. These are all used by most large companies on a regular basis. I'm a network engineer and I can assure you that it is legal to "spoof" your mac address. Even though there may be some unethical reasons for doing this, there are also unethical reasons for owning a kitchen knife. We change our mac addresses of many of the devices at work all the time for many, very legitimate reasons.
While there's no easy way to change the actual information stored in the CIS of a device, depending on the NIC driver, many drivers support dynamic mac addresses. Even Microsoft provides support for configurable mac addresses.
I dug around in the registry a bit and it doesn't seem like there is a default setting for this on Xperia (well, that I could find), but I'm sure there's a way to change the NDIS miniport drivers to simply call a new string value containing whatever you're trying to change your mac to.
Check out these MSDN articles that might help with a solution.
http://msdn.microsoft.com/en-us/library/bb648482.aspx
http://msdn.microsoft.com/en-us/library/ms893567.aspx
hi jhoffa,
thanks for the solution links. but i already need help:
At MSDN:
Finally, if the card information structure (CIS) of the PC Card contains a network address value, Ndis.dll creates a \HKEY_LOCAL_MACHINE\Comm\Miniport Instance\Parms\NetworkAddress key to store the network address.
My registry dosent show the path ...\NetworkAddress
\HKEY_LOCAL_MACHINE\Comm\TNETW12511
DisplayName
IEEE 802.11b/g Compatible Wi-Fi Adapter
At: HKEY_LOCAL_MACHINE\Comm\TNETW12511\Parms\TcpIp it shows me: Autocgf, autointerval, automask, autoseed, autosubnet, dhcpdns, dhcpipaddress, dhcpserver, dhcpsubnetmask, enabledhcp, lease, leaseobtainedhigh, leaseobtainedlow, prevreqoptions, t1 and t2. but nothing like a mac address.
is it possible that i am looking the wrong way?
thanks for helping
strohrum
strohrum said:
hi jhoffa,
thanks for the solution links. but i already need help:
At MSDN:
Finally, if the card information structure (CIS) of the PC Card contains a network address value, Ndis.dll creates a \HKEY_LOCAL_MACHINE\Comm\Miniport Instance\Parms\NetworkAddress key to store the network address.
My registry dosent show the path ...\NetworkAddress
\HKEY_LOCAL_MACHINE\Comm\TNETW12511
DisplayName
IEEE 802.11b/g Compatible Wi-Fi Adapter
At: HKEY_LOCAL_MACHINE\Comm\TNETW12511\Parms\TcpIp it shows me: Autocgf, autointerval, automask, autoseed, autosubnet, dhcpdns, dhcpipaddress, dhcpserver, dhcpsubnetmask, enabledhcp, lease, leaseobtainedhigh, leaseobtainedlow, prevreqoptions, t1 and t2. but nothing like a mac address.
is it possible that i am looking the wrong way?
thanks for helping
strohrum
Click to expand...
Click to collapse
Have you tried adding
Network Adress as a (i'm presuming) a Dword to \HKEY_LOCAL_MACHINE\Comm\TNETW12511\Parms\ ?
i added "NetworkAddress" as String and typed a 12 letter mac in it. didnt work. Dword same.
jhoffa said:
I dug around in the registry a bit and it doesn't seem like there is a default setting for this on Xperia (well, that I could find), but I'm sure there's a way to change the NDIS miniport drivers to simply call a new string value containing whatever you're trying to change your mac to.
Click to expand...
Click to collapse
i skiped this as i read your posting before. i know that i cant handle this, i am too noobish in registry files edit.
maybe someone could help me with that?
thanks
strohrum
i found that at eggheadcafe.com:
Step 1 --> changes to driver
Steps [2-5] from C# application
1) In NDIS Intermediate driver (QueryMiniport function), I made the
following changes
a) When OID is CURRENT_MAC_ADDRESS , open registry , read a
registry name ChangeMAC,
b) if value of ChangeMAC is 1 then read registry value of "NewMAC"
and then convert it appropriately to MAC format
(remove extra unicode characters etc)
c) then do a NDISMoveMemory to current adapters MACaddr field.
d) close registry
2) Set value of ChangeMAC (DWord) to 1
3) Set value of NewMAC (string) to the new mac address
4) Invoke a NDIS_REBIND_ADAPTER (this internally will call
QueryMiniport ) and inturn execute step (1)
5) Set value of ChangeMAC (DWord) to 0
anybody an idea how does it work?
michaelthemage said:
Legal WHERE? 50% of the content here is probably not koscher! What a stupid question!
ANY medling with software is illegal worldwide! Read the license agreements!
I would suggest NOT to discuss this...waste of time and effort! Just a thought ;-)
Click to expand...
Click to collapse
Using an unofficial program "stealed" from other phone or cook a personal ROM is not paragonable as change MAC Address.
MAC Address changes are the same of IMEI's ones: if you want to create-problems to a WiFi network (for example) with your modified MAC Address, you are not more identificable...so this is illegal.
To prevent the possibility of this type of "problems", all changes acts to alterate UNIQUE IDENTIFICATION of a device (IMEI or MAC Address numbers) are illegal, because it will cause a POSSIBLE multi-identity.

[Q] Help! Changing DNS settings

I need to change the DNS settings for a connection I use a lot that is managed by company who has setup OpenDNS to block a lot of stuff...
How can I go about doing this on a wpa encrypted wireless network where i do no not have a dynamic ip address?? It seems it only supports changing a DNS server when the phone is setup dynamically.. I need it to work on DHCP, I just need the DNS server changed, i dont need or want a dynamic ip..
HELP!
tiptoekirk said:
I need to change the DNS settings for a connection I use a lot that is managed by company who has setup OpenDNS to block a lot of stuff...
How can I go about doing this on a wpa encrypted wireless network where i do no not have a dynamic ip address?? It seems it only supports changing a DNS server when the phone is setup dynamically.. I need it to work on DHCP, I just need the DNS server changed, i dont need or want a dynamic ip..
HELP!
Click to expand...
Click to collapse
This is the code needed to change the DNS settings. Just connect your N1 to your PC and open command in your PC then;
adb shell setprop net.dns1 8.8.8.8
adb shell setprop net.dns2 8.8.8.4
henihazbay said:
This is the code needed to change the DNS settings. Just connect your N1 to your PC and open command in your PC then;
adb shell setprop net.dns1 8.8.8.8
adb shell setprop net.dns2 8.8.8.4
Click to expand...
Click to collapse
That did not seem to do it... I tried several times with wifi on and off and even restarted the phone.. any other ideas??
tiptoekirk said:
I need to change the DNS settings for a connection I use a lot that is managed by company who has setup OpenDNS to block a lot of stuff...
How can I go about doing this on a wpa encrypted wireless network where i do no not have a dynamic ip address?? It seems it only supports changing a DNS server when the phone is setup dynamically.. I need it to work on DHCP, I just need the DNS server changed, i dont need or want a dynamic ip..
HELP!
Click to expand...
Click to collapse
Not sure if i get that... When you use static ip there is a section that allows you to specify the DNS... not sure what you mean The problem as i see it, is that there is no easy way (via android GUI) of changing DNS if you use DHCP
Anyways... try...
adb shell setprop dhcp.eth0.dns1 <IP>
adb shell setprop dhcp.eth0.dns2 <IP>
etc
This will only change the DNS server. If you know shell scripting, You could make this more permanent by editing :
/system/etc/dhcpcd/dhcpcd-hooks/20-dns.conf
If that works, and you are unfamiliar with shell scripting, then post some conditions (i.e SSID of network, gw of network etc) and i'll see if i can knock something up for you.
Hope that helps
yasn77 said:
Not sure if i get that... When you use static ip there is a section that allows you to specify the DNS... not sure what you mean The problem as i see it, is that there is no easy way (via android GUI) of changing DNS if you use DHCP
Anyways... try...
adb shell setprop dhcp.eth0.dns1 <IP>
adb shell setprop dhcp.eth0.dns2 <IP>
etc
This will only change the DNS server. If you know shell scripting, You could make this more permanent by editing :
/system/etc/dhcpcd/dhcpcd-hooks/20-dns.conf
If that works, and you are unfamiliar with shell scripting, then post some conditions (i.e SSID of network, gw of network etc) and i'll see if i can knock something up for you.
Hope that helps
Click to expand...
Click to collapse
Yes i am wanting to just change the DNS server that my phone uses when connecting to wifi but i cant set it up dynamically so i am forced to keep it dhcp.
i tried the way you said and it didn't do it.. this android stuff is new to me.. after i type in that command in it does not say anything.. i have rooted and unlocked my nexus one and pretty good with computers but this linux stuff is another ballgame..
ive done some dos scripting back in the day, is this anything similar? what other info would u need from me to create the file? SSID, password, ??
THANKS!
How to set the dns for the mobile internet connection?! I wanna use FoolDNS in place of Google DNS.. Because with froyo 2.2 and flashplayer we see allllllll the advertising on web and navigation becames much slower

HOWTO: Set up your G1's Wi-Fi (in order to make it actually *work*)

I've received my Dream yesterday and the wi-fi is painfully slow. At first it didn't work at all, so I entered all settings by hand, assigned it a static IP address and other stuff. Then it worked, albeit very slowly. So, here's what you need to do if your wi-fi isn't too fast.
Go to Wi-Fi settings, press Menu and select Advanced Settings. On your computer (if you're using an unix based OS, at least - can some Windows guru help me out with this?), get to a terminal emulator and type:
Code:
ifconfig en1
This should give you output like this:
Code:
Wiktoria:~ Nekkoru$ ifconfig en1
en1: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
ether 00:1c:b3:bd:b9:cb
inet6 fe80::21c:b3ff:febd:b9cb%en1 prefixlen 64 scopeid 0x6
inet 192.168.55.102 netmask 0xffffff00 broadcast 192.168.55.255
media: <unknown subtype>
status: active
Wiktoria:~ Nekkoru$ [CODE]
The IP address after inet (192.168.55.102 in my case) is what you're after. On your phone, enter your IP address as the IP adress you got, with the last block changed to anything that's not being used on your network. I assigned 192.168.55.69 to my phone, because it's easy to remember and it's kind of childish.
Now, your "Gateway" should be your router's IP address. Your router's IP should be specified in it's manual - or your system settings. Your subnet mask should always be 255.255.255.0.
We need your DNS settings now - this is where most of us screw up and this is what you need to fix the most. Go back to your computer's terminal and type in
[CODE]dig
Look at the bottom. You're interested in a line that says "SERVER: xxx.xxx.xxx.xxx". That's your primary, first DNS. If you give that to your phone, your wi-fi should work way faster. Set it up as the second DNS as well, unless you know a better DNS server than your ISP's (anyone?).
I'm sorry this got so complicated, but that's the best way to set up your G1's internet if it gives you any trouble. I hope I helped somewhat.

Any way to name my phone

Just wondering cause i like seeing names for the devices that are connected to my router without having to check on each item.. My phone comes up as blank on my router settings page. My wifes iphone(hate saying that word) shows up as her name. Same with all my PCs just wish my phone showed up other than a blank.
My Uncle had asked me about that at one point as well. He uses MAC address approval on his AP at his house and had no clue how to distinguish which from phone from who had it. We have 3 Captivates in my house.
Sucks having to check mac address just to see whos connected to my router.
For now I know I'm the only one on it but I check everyday to see if some one tried to jump on my ship and would love to see a name. .
Sent from my SAMSUNG-SGH-I897 using XDA App
Couldn't someone just change their device name and MAC address to match yours?
On any note, some devices use the same name stored for bluetooth. I can't really test it right now, but try and change it from the default BT name. Sounds dumb, usually I would test these things before saying anything though, so forgive me if I'm wrong!
I don't use mac address security.
The blue tooth is a good idea. Image test after work today. If u get a chance before me just let me know what happens.
Thanks for the idea
Sent from my SAMSUNG-SGH-I897 using XDA App
Our phone does not use the BT name as its network name. I have been trying to figure out where it would keep its name, because I would like to accomplish the same thing. I mean, all my devices have names, even my network printer, the kid's wii, etc.
on a normal linux box, the host name would be stored in /etc/hostname
Pirateghost said:
Our phone does not use the BT name as its network name. I have been trying to figure out where it would keep its name, because I would like to accomplish the same thing. I mean, all my devices have names, even my network printer, the kid's wii, etc.
on a normal linux box, the host name would be stored in /etc/hostname
Click to expand...
Click to collapse
Haven't confirmed it on the captivate (mines at the shop getting repaired) but i did try this method on my tilt2 running xdandroid (froyo 2.2) and a smartq V7 android tablet (eclair 2.1).
edit your init.rc file
find the section that looks something like this
Code:
on boot
#basic network init
ifup lo
hostname localhost
domainname localdomain
change hostname localhost to hostname name_of_device.
For example I called mine XDAndroiD. This is how the section looks like.
Code:
on boot
#basic network init
ifup lo
hostname XDAndroiD
domainname localdomain
This method will survive a phone reboot. Another method (that wont survive reboot) is to issue this command in a terminal under root
Code:
su
echo name_of_device > /proc/sys/kernel/hostname
This example using my XDAndroiD name would look like this.
Code:
su
echo XDAndroiD > /proc/sys/kernel/hostname
***Again I haven't tried this on my Captivate yet. Will test it out when I get my phone back from the shop.
thanks for that. i will have a look later today and see what happens.

[Q] sh script for WiFi

I've been having issues with the Wifi on my captivate since day one (two different devices over the span of about 2 months now). Since no updates from Samsung or AT&T have fixed it, I'm trying my own thing.
The problem I am having is that the Subnet Mask does NOT get configured properly on the eth0 interface from DHCP on a classless subnet. That is, if the Mask is 255.0.0.0 or 255.255.255.0, I have no problems, but at work my subnet mask is 255.255.252.0. The framework and DHCP report the right mask, but the interface itself always reports 255.0.0.0.
I've rooted the phone and figured out that I can manually change the mask using the ifconfig netmask command, but don't want to do that every time.
What I've been trying is creating a dhcpcd.exit-hook script that gets called by the dhcpcd-run-hooks script to check the mask and set it appropriately.
If the script ONLY sets the interface netmask to the classless mask, it works but then won't set the classful mask properly.
I've tried various if and case statement variations to fix this, but always seem to get weird syntax errors when I run them via sh. Obviously they don't work from being called from the run-hooks script.
Below is the latest code I've tried:
Code:
#!/system/bin/sh
# This script runs last, after all network configuration
# has completed. It sets a property to fix the Subnet Mask
# to use the classless mask from DHCP instead of classful.
varMask=`getprop dhcp.eth0.mask`
case "$varMask" in "255.255.255.0" )
exit
;;
esac
/system/bin/ifconfig eth0 netmask "$varMask"
exit
The error I'm getting is:
Code:
dhcpcd.exit-hook: 11: Syntax error: word unexpected (expecting ")")
When I did this with an if statement, was getting a similar error, except it was asking for a then, even though there was a then in the code and the syntax was right, as far as I've been able to determine.
I am not android or linux expert, so any assistance would be greatly appreciated.
Tks.
~CJ
I think I got it
Figures! I'd figure it out 10 mins after I asked for help!
The syntax error seems to have been casued by file formats. I originally was using wordpad and apparently android/*nix didn't like the carrige returns.
I installed and used Notepad++, saw the file format difference and coverted it.
No errors and the script appears to work as desired, though I haven't had a chance to test in on my home "classfull" network yet.
I'll update when I test things fully.
EDIT: Thought wrong! It appears to work when I manually run it, but it does not appear to be running from the dhcpcd-run-hooks script...
Perhaps now
After rebooting the phone, it appears to be working. I've even bounced back and forth between a test network I have here on the 255.255.255.0 subnet and the production network which is 255.255.252.0.
I did have turn wifi off and on the first time I went from production to test, but it seemed to work both ways.
I'm going to continue to test from my home and other networks before I feel comfortable calling this one won.
Still having trouble at home. Seems to want to assign 255.255.255.255 mask on class C subnets. Hmmm.

Categories

Resources