for app developers and others, change mac automatic - Android Q&A, Help & Troubleshooting

I use:
busybox ip link set wlan0(or eth0) address XX:XX:XX:XX:XX:XX
To change Mac address on android, it need root, terminal emulator and busybox.
It work at the first time or second. But need to be done aigain every time we want to connect a wireless.
Insted of turn the wifi off and on and quickly run the command.(the command need to run before the wifi turn on complete).
I use the terminal with su:
svc wifi disable
svc wifi on
(need to wait 0.5s to proced)
busybox ip link set wlan0(or eth0) address XX:XX:XX:XX:XX:XX
and its done .
it will be great if an app developer can make an app to run this command automatically when we want to connect to wifi. it will make the mac address not permanent but almost.

Related

[Q] Problem with openvpn on Archos 101

Hi,
Last week I received my Archos 101. In general it is great. Even better is this forum
I installed urukdroid (thanks to the project-team!). I tried to use openvpn but it failed and I am not sure about the reason.
The server-configuration is
...
ifconfig-pool 10.10.10.120 10.10.10.130
push "route 10.10.10.1"
route 10.10.10.0 255.255.255.0
ifconfig 10.10.10.1 255.255.255.0
push "route-gateway 10.10.10.1"
push "route 10.10.10.0 255.255.255.0"
...
As the Archos is the only device it would get IP 10.10.10.120.
BUT: ifconfig shows:
inet addr.: 10.10.10.255 Bcast: 10.255.255.255 Mask 255.0.0.0
That did (and cannot) work. No ping to home network possible.
When I called route it looked fine (I used redirect-gateway).
When I send the command
ifconfig tap0 10.10.10.120 broadcast 10.10.10.1 netmask 255.255.255.0
from Archos Terminal I had at least access to my home network. But all route entries are gone.
Who has an idea what I am doing wrong? I checked it in the last day again and again... If there is no solution: is it possible to 'save' the entries from route and restore it after my manual change of ifconfig? I would like to do it via script, as my home network I only reachable via dyndns.
Thanks and best regards!
I used the OpenVPN Howto Quickstart and had no problems.
macemoneta said:
I used the OpenVPN Howto Quickstart and had no problems.
Click to expand...
Click to collapse
Yes, I know the guide. I did the same with my ubuntu-netbook and it works directly.
And I think, it would work also on the Archos, if the openvpn/ifconfig on Archos accept the 10.10.10.120. But the IP is changed to 10.10.10.255 and that did not fit.
Where the h*** did the 255 instead of 120 come from?
I noticed the same problem...
No idea where it comes from, but as a workaround, you can put a script somewhere containing a suitable "ip addr add x.x.x.x/y dev z" statement, and reference that in the .conf file as "up scriptname".
Note that you need to add "--script-security 2" to the openvpn commandline to make that work. I added that to the OPENVPN_CFG variable in /etc/uruk.conf/openvpn.
regards
Patrick
This is the openvpn configuration I use for my Archos 101 (on the server). I'm not having any problems, using openvpn 2.1.1:
Code:
port 1194
dev tun
tls-server
ca /etc/openvpn/keys/ca.crt
cert /etc/openvpn/keys/[COLOR="Blue"]<my host>[/COLOR].crt
key /etc/openvpn/keys/[COLOR="blue"]<my host>[/COLOR].key
dh /etc/openvpn/keys/dh1024.pem
mode server
ifconfig 10.8.0.1 10.8.0.2
ifconfig-pool 10.8.0.4 10.8.0.255
push "route 10.8.0.1 255.255.255.255"
client-config-dir ccd
push "redirect-gateway def1"
push "dhcp-option DOMAIN [COLOR="Blue"]<my domain>[/COLOR]"
push "dhcp-option DNS [COLOR="blue"]<my dns server>[/COLOR]"
keepalive 10 60
inactive 3600
route 10.8.0.0 255.255.255.0
user openvpn
group openvpn
persist-tun
persist-key
verb 4
I examined the situation a bit further.
The problem comes from the ifconfig command that openvpn calls itself:
Code:
/system/bin/ifconfig myvpn \
192.168.x.41 \
netmask 255.255.255.0 \
mtu 1500 \
broadcast 192.168.x.255
This is only used when tap interfaces are involved, which is the case in my setup, but not in the setup macemoneta is showing. caesar68: do you also use tap interfaces?
I can reproduce the problem by just using that ifconfig command again.
When I list the IP-address-to-set as the last argument, instead, it works, i.e.
Code:
/system/bin/ifconfig myvpn \
netmask 255.255.255.0 \
mtu 1500 \
broadcast 192.168.x.255 \
192.168.x.41
A quick scanning of the openvpn manpage, does not suggest a way to override the ifconfig command that is used, but it does give an option --ifconfig-noexec which suppresses its calling.
Unfortuntely, when I just pack the is-working-after-the-interface-is-up ifconfig command into an up script with this option, it just gives me an error SIOCSIFNETMASK (Cannot assign requested address) - even if the same commandline works when I run it over an already upped interface... Probably because the interface then already had an IP address...
No problem, though, ifconfig is obsolete anyway, let us just use ip link and ip addr, which are fortunately available under Uruk.
So, caesar68, the clean solution would be to have
--script-security 2 on the openvpn commandline, e.g. via OPENVPN_CFG in /etc/uruk.conf/openvpn
in your myvpn.conf file:
Code:
ifconfig-noexec
up-delay
up-restart
up /etc/openvpn/myvpn-on-up
a corresponding script /etc/openvpn/myvpn-on-up, executable, with content
Code:
#! /system/bin/sh
ip link set $dev mtu $tun_mtu up
ip addr add $ifconfig_local/$ifconfig_netmask \
broadcast $ifconfig_broadcast \
dev $dev
Works For Me
Thanks for the explanation and the workaround, brian_o'fish. Why are you using tap though? Tap provides an Ethernet bridge, so you'll be transporting packets that really don't need to be sent to your Archos (reducing available bandwidth). Tun is layer 3 routed, so only traffic destined for either endpoint goes over the VPN connection.
macemoneta said:
Why are you using tap though?
Click to expand...
Click to collapse
That's what the server I'm using, is configured to do, as it provides transparant bridged LAN access via VPN, and that is what I want, as I am the admin of said LAN and VPN.
If the low level of broadcasts we have, ever increases or appears to be a problem to me, I'll set up an additional tun server, but for now it is simply not an issue.
Anyway, good hint in general!
Hi all!
Thanks a lot for your comments. Yes I am using tap. I would like to have access to my home network (storage etc.). Therefore I want to use the brigde functionality. And that works only when I changed the ifconfig manually afterwards. But the route is distroyed then and packages to the internet are not routed secure thru my home-network.
@ brian_o'fish: Thanks for the advise. I will try that the next days. In the moment I am happy to read, that I am not the only one with the problem (and maybe to stupid to use openvpn - but on the netbook it works).
I have never worked with tun. Maybe I could check, if that is also a workaround.
I will keep you informed, but I am on a trip the next days.
Thanks again!
*** Update ***:
I didn't work neither with tap nor with tun. Meanwhile I tried to run VPNC. I had some trouble, but it works now.
caesar68 said:
I didn't work neither with tap nor with tun.
Click to expand...
Click to collapse
Did you try the approach I described with tap, and can tell where / how it failed?

[Q] Android USB reverse tethering: How to fool the apps

USB reverse tethering = Cellphone gets network connection from PC via USB.
I know how to do USB reverse tethering except for one problem: Many Android apps will check network connection using the code below before doing any useful work:
Code:
ConnectivityManager connectivityManager = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo info = connectivityManager.getActiveNetworkInfo();
The problem is that, when using USB reverse tethering, the above code will report no network connection. However, there IS a network connection (which is the USB reverse tethering itself), and ping, wget and all programs not doing this stupid check work well.
So the question is: How can I hack the system to let this network connection check return success (so that I can fool these apps)?
BTW. I use Cyanogenmod 7. And any solution specific to this MOD is also welcome.
Hello,
Could you please tell me how did you do the USB reverse tethering? Since on USB connection there is no option to do that under CM 7.1?
...
Thank you. Unfortunately the binary /system/bin/netsharing is not part of CM7.1, apparently it exists with Sense ROM. How do you manage to run it under CM7.1?
Sense ROM has the reverse USB tether built-in ("Internet passthrough"), maybe if the 2 commands could be executed, thanks to existing HTC NDIS driver doing NAT inside the PC it will work?
I've tested in CM7 that netsharing is not needed. Just execute the rest of the commands will be OK. Of course you need to do NAT on the PC because what you've setup is just a small LAN with private IP addresses.
Thank you for your input.
What I understand:
1- connect the phone via USB cable, choose charge only
2- Assuming my router has IP 192.168.1.1:
So I have to type these commands, could you confirm?
Code:
echo 4 > /sys/devices/platform/msm_hsusb/usb_function_switch
route add default gw 192.168.1.1
ifconfig usb0 192.168.1.1 mtu 500 up
But then how to do the NAT thing is out of my knowledge!
In fact what I want is when there is no router (since mine is wireless) with available Internet connetion
(ADSL line down). So I have to use USB 56kbps modem with telephone line to access Internet from the PC (running XP).
And I would like to plug the Android phone with USB cable and allow the phone to access Internet (Internet sharing
with the PC). I am not sure of the operations to do then.
Sorry but I don't know how to set up NAT on Windows XP... I use Linux and a simple iptables command suffices:
Code:
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

[Q] How can I set up a WPA Enterprise connection?

Hello. I have a question related to WAP enterprise on Android. Basically, my employer has detailed instructions on how to connect to the building wifi via BlackBerry or iphone but sadly not Android. I was wondering if there is a workaround or hack for this that would enable me to connect using either BB or iphone settings. I downloaded WiFi Advanced from the Market but I haven’t been able to figure out what to fill in what field ( I do see checkboxes for LEAP and WPA Enterprise mentioned below but no proxy field). Any tips using this app or another solution is appreciated! These are the settings I need to enter:
BlackBerry:
Setup Wifi Network: Office network name (appears as WPA Enterprise)
Select LEAP as security type
Enter username and password (which I have)
Connect to network
Manage connections , choose Enterprise Subtype as LEAP
Enter username and password (which I have)
Iphone:
Enter Wifi settings, tap Other
Enter network name, tap Security
Choose WPA Enterprise for security
Enter username and password (which I have)
Connect to network
Tap blue arrow next to network name and tap Auto under proxy
Enter proxy URL
So one uses LEAP and the other one asks me for a Proxy so I am not sure which one might work for my Samsung Galaxy S2 using Wifi Advanced app from the Market.
NOTE: I am able to create the network and it shows as connected but no internet access, its says WPA_EAP IEEE8021X below the name, but dont know how to take it from there in Wifi Advanced to complete the setup as per above .
Any help is appreciated!!!!!!
I have exactly the same problem. Any ideas?
erkan79 said:
I have exactly the same problem. Any ideas?
Click to expand...
Click to collapse
This thread is pretty old, but I don't see any reply to this problem so I thought to share solution that worked for me.
As per your description "Garoto1973" your network connection didn't establish. It failed while authenticating. You may find below steps useful.
I was able to connect to my companies PEAP network by using following configurations. Please note that I am using adb to modify wifi settings so your phone should be rooted.
1- Connect your phone to your PC.
2- Pull wpa_supplicant.conf file to your machine for editing:
adb pull /data/misc/wifi/wpa_supplicant.conf
3- Edit wpa_supplicant.conf file adding this configuration for your network:
network={
ssid="<YOUR_NETWORK_NAME>"
scan_ssid=1
proto=WPA
key_mgmt=IEEE8021X
pairwise=TKIP
group=TKIP
auth_alg=OPEN
eap=PEAP
identity="<DOMAIN\IDENTITY>"
password="<YOUR_PASSWORD>"
phase2="auth=MSCHAPV2"
eapol_flags=2
}
Note that "eapol_flags=2" is very important or connection fails for me with error "W/wpa_supplicant(27862): EAPOL: Failed to set WEP key to the driver."
4- Replace wpa_supplicant.conf on your mobile with the modified file:
adb push wpa_supplicant.conf /data/misc/wifi
5- Reassign user and group for wpa_supplicant file:
adb shell chown 1010 /data/misc/wifi/wpa_supplicant.conf
adb shell chgrp 1010 /data/misc/wifi/wpa_supplicant.conf
6- Restart wifi and it should connect
hello, not sure if it will help.
try to use aplication LEAP WIFI free from the market. With this app I am able to connect to my corporate network

[GUIDE] USB reverse tethering - All apps working!!!

I've been looking for this for a while finally I got it, this is what I did:
- Connect your android device to your linux PC
- Enable USB tethering
- On your linux box as root (I'm using Fedora 16)
Code:
iptables -A POSTROUTING -t nat -j MASQUERADE
echo 1 > /proc/sys/net/ipv4/ip_forward
ifconfig usb0 12.12.10.1
With this you will enabled internet sharing between network interfaces and assign an IP to the usb interface.
- Enable mobile data access (3G) on your android
- On your Android using adb or terminal emulator
Code:
ifconfig rmnet0 0.0.0.0
ifconfig usb0 12.12.10.2
route add default gw 12.12.10.1 dev usb0
setprop net.dns1 8.8.8.8
The first line will disable the data traffic through your 3G connection so all the traffic wiil go through the USB
- Enjoy
All apps works because they see a vaild 3G connection!!!
WARNING: If during you are USB connected, the 3g connection is reset, the system will restore its IP and DNS so
the traffic will go through this interface you must reset again the IP to 0.0.0.0 and the dns to 8.8.8.8. Maybe
one of the devs here could help us to prevent this happened. You can always check the IP values of all interfaces by typing "netcfg"
Press Thanks if I help you
everytime,
bash: /proc/sys/net/ipv4/ip_forward: Permission denied
yes i tried with sudo, same output.
using ubuntu12.04 64 bit. all other commands are fine,
gandhar said:
everytime,
bash: /proc/sys/net/ipv4/ip_forward: Permission denied
yes i tried with sudo, same output.
using ubuntu12.04 64 bit. all other commands are fine,
Click to expand...
Click to collapse
In Ubuntu you can re-direct to files you own as the user calling sudo, such as files in your home directory, but not system files
so try this:
sudo bash -c 'echo 1 > /proc/sys/net/ipv4/ip_forward'
or you can edit /etc/sysctl.conf and then run sysctl -p
secondary problem
Thank you very much for your post, this is what I was looking for.
I have configured correctly, ubuntu 12.10 and android 2.3.7 (Huawei U8650) but there is a problem.
Only works a few seconds, the first moments. In the browser takes more time, but when I open "play store" internet is disconnected. It seems they check applications and stop working, it's strange. Configuration is successful because it works, but only a few seconds ...
Seems to prove that internet applications not from the 3g and crashes ...
I have broken the wireless on my huawei U8650 and this is the only way I can access the internet
Thanks in advance
PS: I'm Spanish, sorry for my bad English.
wideru said:
Thank you very much for your post, this is what I was looking for.
I have configured correctly, ubuntu 12.10 and android 2.3.7 (Huawei U8650) but there is a problem.
Only works a few seconds, the first moments. In the browser takes more time, but when I open "play store" internet is disconnected. It seems they check applications and stop working, it's strange. Configuration is successful because it works, but only a few seconds ...
Seems to prove that internet applications not from the 3g and crashes ...
I have broken the wireless on my huawei U8650 and this is the only way I can access the internet
Thanks in advance
PS: I'm Spanish, sorry for my bad English.
Click to expand...
Click to collapse
Yes sometimes it happen to me too but normally takes several minutes even hours not seconds, READ the WARNING.
Hope it help.
rply plx
what about windows 7 ?
how can i let my all apps including vpn to be worked with reverse tethering
Qutub Uddin said:
what about windows 7 ?
how can i let my all apps including vpn to be worked with reverse tethering
Click to expand...
Click to collapse
check this http://forum.xda-developers.com/showthread.php?t=1371345

[Q] Change mac address

Hi guys
anyone can change mac of s5830I?
I try apps and busybox command but I cant.
can you help me
TNX
my English is bad
danial199 said:
Hi guys
anyone can change mac of s5830I?
I try apps and busybox command but I cant.
can you help me
Click to expand...
Click to collapse
The MAC address is hard-coded on your network interface controller (NIC) and cannot be changed permanently with simple command line from your terminal nor in software level approach. However we can assign a temporary solution for your MAC, which will be reverted back to it's original state after Reboot/Power off .
Requirements :
- Rooted phone
- Busy box app from play store installed
- Terminal emulator from play store :
Know normally your card's interface should be eth0 ( older devices ) or in case of newer phones ( wlan0)
after granting super user permission in terminal ( Su) , type >> netcfg
Code:
busybox iplink show eth0
you may change it to wlan0 , if you are on this interface
Code:
busybox ifconfig eth0 hw ether XX:XX:XX:XX:XX:XX
change the XX to your preference value ( i,e : 00:11:22:33:44:55)
Because of kernel design and absence of monitoring mode support for mac spoofing , this method won't work on protected networks ( ONLY open networks )
and if the lines above don't work for you , try to disable and enable your eth0:
Wifi is ON
su >
Code:
busybox ifconfig eth0 down
busybox ifconfig eth0 hw ether (address)
busybox ifconfig eth0 up
ehsanotaku said:
The MAC address is hard-coded on your network interface controller (NIC) and cannot be changed permanently with simple command line from your terminal nor in software level approach. However we can assign a temporary solution for your MAC, which will be reverted back to it's original state after Reboot/Power off .
Requirements :
- Rooted phone
- Busy box app from play store installed
- Terminal emulator from play store :
Know normally your card's interface should be eth0 ( older devices ) or in case of newer phones ( wlan0)
after granting super user permission in terminal ( Su) , type >> netcfg
Code:
busybox iplink show eth0
you may change it to wlan0 , if you are on this interface
Code:
busybox ifconfig eth0 hw ether XX:XX:XX:XX:XX:XX
change the XX to your preference value ( i,e : 00:11:22:33:44:55)
Because of kernel design and absence of monitoring mode support for mac spoofing , this method won't work on protected networks ( ONLY open networks )
and if the lines above don't work for you , try to disable and enable your eth0:
Wifi is ON
su >
Code:
busybox ifconfig eth0 down
busybox ifconfig eth0 hw ether (address)
busybox ifconfig eth0 up
Click to expand...
Click to collapse
Tnx for answer
after change mac I cant connect to wifi
want a new password but pass is true
danial199 said:
Tnx for answer
after change mac I cant connect to wifi
want a new password but pass is true
Click to expand...
Click to collapse
You are trying to access protected network , which comes with encryption ( WEP/WPA/WPA2 etc etc ) ? What error you are getting from Android OS ? Are you absolutely certain your MAC address is white listed inside the router/modem settings on open network protocol settings of course ?
ehsanotaku said:
You are trying to access protected network , which comes with encryption ( WEP/WPA/WPA2 etc etc ) ? What error you are getting from Android OS ? Are you absolutely certain your MAC address is white listed inside the router/modem settings on open network protocol settings of course ?
Click to expand...
Click to collapse
wpa2
when i connect to network want a password but the password is true
There isnt any listed mac address inside the router
danial199 said:
wpa2
when i connect to network want a password but the password is true
There isnt any listed mac address inside the router
Click to expand...
Click to collapse
Already explained about protected networks and the reason behind it in the first post . You need to set it to 'Open network' ( means no wpa/wpa2/wep etc,,etc) inside the router/modem you are seeking an access.
Maybe not so
I have tried several apps and every possible command in terminal (as root) and although all can successfully change the MAC address, the device is always unable to connect to an access point thereafter. This is a known issue, but unresolved and too frequently denied. I half suspect their are some "political" purposes for withholding the resolution; many have inquired about this, yet only receive pedantic or useless replies. I wonder if there is any correlation to the wifi chipset, or if it's a built-in Android limitation. I know my chipset is very difficult to identify ('demesg | grep wlan0' yields nothing familiar) and that it also seems incapable of monitor mode.
I have scoured many forums for the solution to this and found only a suggestion to change certain files, all which appear to vary between devices, etc.
What I'd like at this point, is and explanation if not a solution. Anyway, I think the OP may have been misunderstood, ergo my 'two cents'.

Categories

Resources