[Guide] Mac Spoofing / Changing - Networking

After reading several posts on mac spoofing and having failed to find a working thread.I decided to fill in the gaps with my linux knowledge (however little of that I may have).
So this method seems to solve some issues I've seen (MAC not changing because device wasn't downed) in these threads:
http://forum.xda-developers.com/showthread.php?t=1385577
http://forum.xda-developers.com/showthread.php?t=902354
without editing the nvram.txt
I've tested the ip link method on my recently rooted Samsung Tab 2 7.0"
Changing your mac address:
Prerequisites:
*A rooted device
*Busybox
*Terminal emulator
*Turn wifi on from your device's menu, do not connect to any network.
*Open your terminal emulator, now type:
$su
#ip link
*This should list all networking interfaces, identify your wifi device, take note of the name. now:
#ip link set NAME down
#ip link set NAME address 00:11:22:33:44:55
#ip link set NAME up
I believe that when using ifconfig the procedure is as follows:
$su
#ifconfig
*Take note of the device name
#ifconfig NAME down
#ifconfig NAME hw ether 00:11:22:33:44:55
#ifconfig NAME up
After doing the above you can connect to the desired network normally, using the default / other user interfaces.
NOTE: The mac address will be reset when WIFI is switched off.
I have confirmed the ip link method to be working. i.e. transmitted mac address is the new / changed one!

Actually in my case (SGS) i had to restart wifi first and then (while it's starting) quickly change the MAC using:
Code:
busybox ifconfig wlan0 hw ether 00:11:22:33:44:55
Important: It must be done about 500ms after enabling wifi, otherwise it won't work.
If I change MAC when wifi is off it simply returns to the original during next start.
Worked on i9000 with CM9 / 10

pawci0 said:
Actually in my case (SGS) i had to restart wifi first and then (while it's starting) quickly change the MAC using:
Code:
busybox ifconfig wlan0 hw ether 00:11:22:33:44:55
Important: It must be done about 500ms after enabling wifi, otherwise it won't work.
If I change MAC when wifi is off it simply returns to the original during next start.
Worked on i9000 with CM9 / 10
Click to expand...
Click to collapse
So downing the interface before changing and uping afterwards doesn't work?

i want to learn well the mac spoofing

setoPul Wilcox
this is actually incredibly useful, I got MACblocked off a network near college. thanks!

Doesn't work for me
Code:
# su
# ifconfig tiwlan0 down
# ip link set tiwlan0 address 00:11:22:33:44:55
ip: SIOCSIFHWADDR: Operation not supported on transport endpoint
# ifconfig tiwlan0 hw ether 00:11:22:33:44:55
error: SIOCSIFADDR (Invalid argument)
I guess its a kernel/driver problem... at least I know it works on normal Linux systems.

Itcouldbeyou said:
Doesn't work for me
Code:
# su
# ifconfig tiwlan0 down
# ip link set tiwlan0 address 00:11:22:33:44:55
ip: SIOCSIFHWADDR: Operation not supported on transport endpoint
# ifconfig tiwlan0 hw ether 00:11:22:33:44:55
error: SIOCSIFADDR (Invalid argument)
I guess its a kernel/driver problem... at least I know it works on normal Linux systems.
Click to expand...
Click to collapse
Funny that only some manufacturers disable such features. You could always try editing the nvram file? I haven't tried it though.

Isnt it dangerous ?

Script to apply random mac
I've made a script to create a random ghost mac every time I run it on the terminal emulator with su.
Code:
macaddr="52:54:$(dd if=/dev/urandom count=1 2>/dev/null | md5sum | sed 's/^\(..\)\(..\)\(..\)\(..\).*$/\1:\2:\3:\4/')"
ip link set wlan0 down
ip link set wlan0 address $macaddr
ip link set wlan0 up
I've named it as gmac.sh and saved it on /sdcard/, thus by running:
Code:
$ su
# sh /sdcard/gmac.sh
the mac is changed.
Regards :cyclops:

Works differently on HTC Desire
Hello,
This is just to "set in stone" somewhere in the Internet that on some devices, you need *not* to down and up the network interface. Otherwise, the network driver will restore its MAC address from hardware/driver settings.
On a HTC Desire, MAC spoofing works this way:
* turn on the wifi interface using the standard Android interface
* run this script :
Code:
macaddr="52:54:$(dd if=/dev/urandom count=1 2>/dev/null | md5sum | sed 's/^\(..\)\(..\)\(..\)\(..\).*$/\1:\2:\3:\4/')"
ip link set wlan0 address $macaddr
Best regards,

On some devices (e.g. HTC Desire among others), the wifi GUI still resets the mac address even with the method described in this thread.
worstenbrood has modified the wifi driver so that the mac address can be configured from a text file. It is described here:
http://forum.xda-developers.com/showthread.php?t=1525230
This is compatible with the wifi GUI and solves the problem of the wifi interface reloading its original mac address.
Anyone interested, I have backported his modifications to the latest state of the kernel developement in CM7.
thanks!

I get a 'operation not supported on transport endpoint' error when running the 'ip link set wlan0 address 00:11:22:33:44:55' and a about the same error with busy box.

Thanks for this! Gonna try this later.

damien.courousse said:
Hello,
This is just to "set in stone" somewhere in the Internet that on some devices, you need *not* to down and up the network interface. Otherwise, the network driver will restore its MAC address from hardware/driver settings.
On a HTC Desire, MAC spoofing works this way:
* turn on the wifi interface using the standard Android interface
* run this script :
Code:
macaddr="52:54:$(dd if=/dev/urandom count=1 2>/dev/null | md5sum | sed 's/^\(..\)\(..\)\(..\)\(..\).*$/\1:\2:\3:\4/')"
ip link set wlan0 address $macaddr
Best regards,
Click to expand...
Click to collapse
anyone help me mine Hcl me 2G 2.0 i can't change mac please help me....

Related

isdn > linux-pbx > SIP > BT-Bridge > XDA2

Hi,
today i received my first ISDN call on my MDA2
- get you ISDN-Card working under Linux
- install asterisk
- install bluez
- install brctr
- BluetoothGPS.cab
- install X-Lite on the XDA2
Code:
/etc/asterisk/modem.conf
[interfaces]
context=remote
driver=i4l
stripmsd=1
dialtype=tone
mode=immediate
msn=YourMSN
device => /dev/ttyI5
/etc/asterisk/sip.conf
[general]
[olli]
type=friend
username=olli
host=dynamic
canreinvite=no
add somthing like:
exten => 500,2,Dial(SIP/olli)
[from-sip]
exten => olli,1,Dial(SIP/olli)
exten => olli,2,Hangup
in the /etc/asterisk/extensions.conf
Give the XDA a static IP and connect to the
Bluez(0) Network Accesspoint.
Than configure the BT-Bridge:
Code:
modprobe usb-uhci
modprobe uhci
modprobe usbcore
mount /proc/bus/usb/
modprobe bluez
modprobe l2cap
modprobe bnep
modprobe sco
modprobe rfcomm
modprobe hci_usb
hcid
sdpd
pand -s -r NAP -M
ifconfig eth0 down
ifconfig eth0 0.0.0.0
ifconfig bnep0 0.0.0.0
brctl addbr pan0
ifconfig pan0 192.168.1.19
brctl addif pan0 eth0
brctl addif pan0 bnep0
route del default
route add default gw 192.168.1.1 dev pan0
brctl showmacs pan0
ping the XDA.
Install X-lite
configure:
user: olli (see sip.conf)
sip-proxy: IP of the astrisk server
mark sent internal IP
Now your can receive IP and PSTN calls.
PSTN by dialing your MSN+500 from any phone.
Has anybody an idea how to configure asterisk
to forward SIP-Calls from the xda to PSTN ?
bye Olli
The XDA a static IP and connect to the
Bluez Network Accesspoint. how is the other?
_________________
Ip pbx

[How to] Change DNS server on Android phones

Domain Name System / Server is the one which takes care of translating the human readable domain names into machine understandable IP addresses. If you are not able to access a particular set of websites either from your laptop /phone, DNS server could be a reason for it. To fix the problem, one has to change the network configurations to use some of the popular DNS servers like Open DNS or Google’s public DNS. On Android phones, changing the DNS server is easy if you are using the static IP. You can do it from Settings > Wireless & network settings > Wi-Fi settings > Advanced (from menu) > check the ‘Use static IP’ option. After that, you will be able to change the DNS servers. However, when you are using dynamic IP (which will be the case most likely), the process is not straight forward. DNS server details will be taken from the DHCP server which assigns the IP.
Here are the steps to be followed to change the (WIFI Connection) DNS servers:
- Android system chooses the DNS servers using the script located at “/system/etc/dhcpcd/dhcpcd-hooks/20-dns.conf”
- By default, /system partition is mounted as read-only. Need to re-mount the same in re-write mode.
- Take a backup of the script. Download the modified version of the script from here (http://varun-scratchpad.googlecode.com/svn/trunk/static/20-dns.conf). The modified script has two additional lines which will override the DNS server changes. The modified script uses the Google’s public DNS.
- Changes will be applied after restarting the connection /device.
3G Connection:
- Download the wrapper script from here (http://varun-scratchpad.googlecode.com/svn/trunk/static/change-dns.sh) This wraps all the commands needed for changing the DNS server in a shell script.
- Download and install an interpreter for executing your shell script from your phone (e.s. scripter from Rom Toolbox)
- Launch the script. Grant the Super permission when asked.
- You just have to run this script whenever you are connecting to your mobile network.
Done. You settings are proper by visiting http://welcome.opendns.com. Remember, the settings will be applicable only for the current session.
By: http://blog.varunkumar.me/2010/09/how-to-change-dns-server-on-android.html?m=1
Or use Set DNS from Market
lol.. I cover my head with ashes!!!
I didn't know about these apps... I apologize!!!
uffapple said:
lol.. I cover my head with ashes!!!
I didn't know about these apps... I apologize!!!
Click to expand...
Click to collapse
your work isn't useless.. it tell me how it work.. thanks
Help
Help, after i did this i can't connect to Wi-Fi anymore. I copied the old 20-dns file and nothing u_u. Pls help
Override DNS for KitKat
uffapple said:
Domain Name System / Server is the one which takes care of translating the human readable domain names into machine understandable IP addresses. If you are not able to access a particular set of websites either from your laptop /phone, DNS server could be a reason for it. To fix the problem, one has to change the network configurations to use some of the popular DNS servers like Open DNS or Google’s public DNS. On Android phones, changing the DNS server is easy if you are using the static IP. You can do it from Settings > Wireless & network settings > Wi-Fi settings > Advanced (from menu) > check the ‘Use static IP’ option. After that, you will be able to change the DNS servers. However, when you are using dynamic IP (which will be the case most likely), the process is not straight forward. DNS server details will be taken from the DHCP server which assigns the IP.
Here are the steps to be followed to change the (WIFI Connection) DNS servers:
- Android system chooses the DNS servers using the script located at “/system/etc/dhcpcd/dhcpcd-hooks/20-dns.conf”
- By default, /system partition is mounted as read-only. Need to re-mount the same in re-write mode.
- Take a backup of the script. Download the modified version of the script from here (http://varun-scratchpad.googlecode.com/svn/trunk/static/20-dns.conf). The modified script has two additional lines which will override the DNS server changes. The modified script uses the Google’s public DNS.
- Changes will be applied after restarting the connection /device.
3G Connection:
- Download the wrapper script from here (http://varun-scratchpad.googlecode.com/svn/trunk/static/change-dns.sh) This wraps all the commands needed for changing the DNS server in a shell script.
- Download and install an interpreter for executing your shell script from your phone (e.s. scripter from Rom Toolbox)
- Launch the script. Grant the Super permission when asked.
- You just have to run this script whenever you are connecting to your mobile network.
Done. You settings are proper by visiting http://welcome.opendns.com. Remember, the settings will be applicable only for the current session.
By: http://blog.varunkumar.me/2010/09/how-to-change-dns-server-on-android.html?m=1
Click to expand...
Click to collapse
Thank you for sharing, but I have to say that the "setprop" method does not work on KitKat (I'm talking about mobile connections).
I wrote an app called "Override DNS for KitKat" to solve this issue. It's on the Play Store.
There's a much more reliable and easier method. Just use this as AFWall custom script or use manually in init.d (replace '$IPTABLES' with 'iptables' and just use the last 2 lines).
Code:
$IPTABLES -t nat -D OUTPUT -p tcp --dport 53 -j DNAT --to-destination 208.67.222.222:53 || true
$IPTABLES -t nat -D OUTPUT -p udp --dport 53 -j DNAT --to-destination 208.67.222.222:53 || true
$IPTABLES -t nat -I OUTPUT -p tcp --dport 53 -j DNAT --to-destination 208.67.222.222:53
$IPTABLES -t nat -I OUTPUT -p udp --dport 53 -j DNAT --to-destination 208.67.222.222:53
DualJoe said:
There's a much more reliable and easier method. Just use this as AFWall custom script or use manually in init.d (replace '$IPTABLES' with 'iptables' and just use the last 2 lines).
Code:
$IPTABLES -t nat -D OUTPUT -p tcp --dport 53 -j DNAT --to-destination 208.67.222.222:53 || true
$IPTABLES -t nat -D OUTPUT -p udp --dport 53 -j DNAT --to-destination 208.67.222.222:53 || true
$IPTABLES -t nat -I OUTPUT -p tcp --dport 53 -j DNAT --to-destination 208.67.222.222:53
$IPTABLES -t nat -I OUTPUT -p udp --dport 53 -j DNAT --to-destination 208.67.222.222:53
Click to expand...
Click to collapse
The "iptables" commands also works good on my Nexus 4 and Slimkat, thank you!

Share reverse tethered via wifi?

Hey, wondering if it would be possible to share the internet connection via wifi from reverse tether?
PC > Android > Wifi Hotspot > Other Device
Basically my 3G internet plan doesn't include tethering so I'm looking for a way to get internet on other devices in the room via wifi...
Though the computer does not have a wifi card so wondering if it would be possible to use the android device as a wifi switch?
I can connect my device to the internet through the PC connection via ADB Reverse USB Tunnel.. But then can I then enable wifi tethering to use that connection to share across the wifi for other devices to connect to and then share the same PC connection?
If its not possible I'm sure I'd be able to install drivers for one of my USB wifi cards, not ideal but if its the only way then I guess I'd have to.
Cheers, Dave
I also scoured everywhere and only thing i found was an app that allowed phone to use computer internet but don't think it broadcasted like Wi-Fi to other devices. I'll look in my Google play and try to locate it.
*Shaolin Shadowboxing*
I have my phone using the PC connection okay, but was looking to then share that through the phone wifi.. but I guess that wouldn't work.
I have a USB wifi adapter that I can setup to share the connection.
DavidTiger said:
I have my phone using the PC connection okay, but was looking to then share that through the phone wifi.. but I guess that wouldn't work.
I have a USB wifi adapter that I can setup to share the connection.
Click to expand...
Click to collapse
How is the pc connected to the internet?
Still Charged Up
Yes. Search reverse tether in play store.
*Shaolin Shadowboxing*
Connected via cable, there's no other connections available hence I was using USB Tethering on my Android phone..
Since there's no wifi available I'm just looking for a way to share it to others and my iPod etc..
JediNinjafication said:
Yes. Search reverse tether in play store.
Click to expand...
Click to collapse
I have reverse tethering working fine, Looking to see if it would be possible to then share that via wifi from the device.
Though I guess that would just slow things down and strain the phone a bit. I'll just setup the USB WiFi Adapter to share the connection
FOund Anything
HEy am trying to share my reverse tethering connection with another android phone. i successfully connected the android phone pop with my pc internet connection using usb tunnel (Reverse tethering). now i need to use the hotspot function on this phone to share the reverse tethered connection with other phones. IS THAT POSSIBLE ???
Reverse USB Tethered Connection Sharing via wifi?
CypherDroid said:
HEy am trying to share my reverse tethering connection with another android phone. i successfully connected the android phone pop with my pc internet connection using usb tunnel (Reverse tethering). now i need to use the hotspot function on this phone to share the reverse tethered connection with other phones. IS THAT POSSIBLE ???
Click to expand...
Click to collapse
Hey anyone found something for this issue ???
Managed to share reverse-tethered viw wifi-HotSpot!
I have managed to do it (provide access to PC's internet through android's wifi-hotspot) with linux-PC & Cyanogen-11 (hence "rooted") on a GS4 (i9505) with the following script. I had to manually set DNS at the bottom.
Code:
## 0.a. Connect android-phone to PC through USB.
## 0.b Enable Settings|...|Tethering
## (so that the device gets detected by the PC's kernel, you should see the following with 'dmsg':
## [ 3.976599] rndis_host 1-1:1.0 usb0: register 'rndis_host' at usb-0000:00:0b.0-1, RNDIS device, 4e:d5:8c:7b:4f:5a
## Enable Settings|...|Wifi-Hotspot
## Setup usb reverse-tethering.
# from: [url]http://forum.xda-developers.com/showthread.php?t=2287494[/url]
#
# Yours device might be 'rndis0' or something else. Check by just typing 'netcfg'.
#
netcfg usb0 dhcp
busybox route add default gw 10.42.0.1 dev usb0
## Disable mobile-data.
#
busybox ifconfig rmnet_usb0 0.0.0.0
## Masquerade through USB.
#
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -F
iptables -t nat -A POSTROUTING -o usb0 -j MASQUERADE
iptables -P FORWARD ACCEPT
## Set DNS (if neccessary).
#
setprop net.dns1 XX.YY.ZZ.WW
ankostis said:
I have managed to do it (provide access to PC's internet through android's wifi-hotspot) with linux-PC & Cyanogen-11 (hence "rooted") on a GS4 (i9505) with the following script. I had to manually set DNS at the bottom.
Code:
## 0.a. Connect android-phone to PC through USB.
## 0.b Enable Settings|...|Tethering
## (so that the device gets detected by the PC's kernel, you should see the following with 'dmsg':
## [ 3.976599] rndis_host 1-1:1.0 usb0: register 'rndis_host' at usb-0000:00:0b.0-1, RNDIS device, 4e:d5:8c:7b:4f:5a
## Enable Settings|...|Wifi-Hotspot
## Setup usb reverse-tethering.
# from: [url]http://forum.xda-developers.com/showthread.php?t=2287494[/url]
#
# Yours device might be 'rndis0' or something else. Check by just typing 'netcfg'.
#
netcfg usb0 dhcp
busybox route add default gw 10.42.0.1 dev usb0
## Disable mobile-data.
#
busybox ifconfig rmnet_usb0 0.0.0.0
## Masquerade through USB.
#
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -F
iptables -t nat -A POSTROUTING -o usb0 -j MASQUERADE
iptables -P FORWARD ACCEPT
## Set DNS (if neccessary).
#
setprop net.dns1 XX.YY.ZZ.WW
Click to expand...
Click to collapse
I have been looking for something like for .. forever, I am truely amazed to have finally find something that hints that it was done
did you really get it to work properly?
I have rooted 2.3 and xp,
if I have busy box installed and I run these via ssh server on my droid, should it work for my setup as well with no changes?
I am really surprised nobody ever made an app that does that automatically, this stuff is so basic and actually super useful and needed!
A random question but have you tried the "Fox-fi" app? i haven't tried to do this myself, but it's a little more flexible than the build in options, it may give you what you are looking for. I've used fox-fi in the past for abnormal tethering, short of going out and buying a cheap USB WiFi adapter of course..
tytiger said:
A random question but have you tried the "Fox-fi" app? i haven't tried to do this myself, but it's a little more flexible than the build in options, it may give you what you are looking for. I've used fox-fi in the past for abnormal tethering, short of going out and buying a cheap USB WiFi adapter of course..
Click to expand...
Click to collapse
in case you asked that me,
my rom has a built in hotspot feature, so I don't need an app for that
I am AMAZED that there are countries in which you are charged extra if you waste your already-paid 3g traffic via another medium that is not particularly your android.
really, next thing you you, you will be charged for having a private phonebook that helps you remember numbers instead of clicking on digits every time you want to call someone, because the cell-supplier wants you to pay extra to use it's phonebook app...
as far as I know from testing FoxFi, its not capable of turning the android into a router, thus bridging the two networks together
and by two networks, I mean the network created by connecting the android via usb to the pc,
and connecting the android via hotspot wifi to another pc/laptop/w'e
ankostis said:
I have managed to do it (provide access to PC's internet through android's wifi-hotspot) with linux-PC & Cyanogen-11 (hence "rooted") on a GS4 (i9505) with the following script. I had to manually set DNS at the bottom.
Code:
## 0.a. Connect android-phone to PC through USB.
## 0.b Enable Settings|...|Tethering
## (so that the device gets detected by the PC's kernel, you should see the following with 'dmsg':
## [ 3.976599] rndis_host 1-1:1.0 usb0: register 'rndis_host' at usb-0000:00:0b.0-1, RNDIS device, 4e:d5:8c:7b:4f:5a
## Enable Settings|...|Wifi-Hotspot
## Setup usb reverse-tethering.
# from: [url]http://forum.xda-developers.com/showthread.php?t=2287494[/url]
#
# Yours device might be 'rndis0' or something else. Check by just typing 'netcfg'.
#
netcfg usb0 dhcp
busybox route add default gw 10.42.0.1 dev usb0
## Disable mobile-data.
#
busybox ifconfig rmnet_usb0 0.0.0.0
## Masquerade through USB.
#
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -F
iptables -t nat -A POSTROUTING -o usb0 -j MASQUERADE
iptables -P FORWARD ACCEPT
## Set DNS (if neccessary).
#
setprop net.dns1 XX.YY.ZZ.WW
Click to expand...
Click to collapse
did you really got the solution??
i tried it but it didnt work!!
plz post d whole procedure!!
plz plz plz....!!!!
thanks in advance
Siddhesh09 said:
did you really got the solution??
i tried it but it didnt work!!
plz post d whole procedure!!
plz plz plz....!!!!
thanks in advance
Click to expand...
Click to collapse
There's already a thread that goes into detail on this... See http://forum.xda-developers.com/showthread.php?t=2287494
Sent from my HTCONE using xda app-developers app
Doesn't work here with Galaxy S2 and samsung stock rooted rom. Will try later with Cyanogenmod.
ankostis said:
I have managed to do it (provide access to PC's internet through android's wifi-hotspot) with linux-PC & Cyanogen-11 (hence "rooted") on a GS4 (i9505) with the following script. I had to manually set DNS at the bottom.
Click to expand...
Click to collapse
Which device was it?
Didn't get it working here on cyanogemod 11 anyway, got reverse tethering as much. The op doesn't explain which commands are for the linux and which ones for the phone, and he's the only one that claims it works. A further explanation is necessary. Attachment is for clarification.
The ppp adapter in my case was rmnet0.
So, I modified it as:
## Disable mobile-data.
#
busybox ifconfig rmnet0 0.0.0.0
After following all the steps, I get internet connection on mozilla firefox on Android for a few seconds but then immediately firefox goes to offline mode. I am able to ping servers like facebook from terminal emulator and I am even able to get internet on default browser.
But I can neither get internet on Google Play apps nor get internet on my laptop to which I tethered my Android device using portable wifi hotspot.
What could be the possible issue here ?
---------- Post added at 06:14 PM ---------- Previous post was at 05:32 PM ----------
can you please explain the purpose of using -o flag in setting the NAT rule for masquerade ?
iptables -t nat -A POSTROUTING -o usb0 -j MASQUERADE
I am assuming that usb0 here is the adapter through which the Android device recieves data from the system (Ubuntu Desktop in my case).
So how does usb0 become the output interface ?
Our intention is to share the reverse tethered network via portable wifi hotspot. So we need to masquerade all traffic recieved by the device to the wifi adapter say wlan0.
So shouldn't it be :
iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
Or is there any need to specify an output adapter, because
Initially we did set up reverse tethering from the Linux Desktop (the Linux Desktop without GUI case) and there,
we masqueraded packets recieved from ethernet adapter (ethernet connection from wired router) to the usb adapter (usb used for reverse tethering).
For that we did not specify any output adapter anywhere.
So would this be fine :
iptables -t nat -A POSTROUTING -j MASQUERADE
Having said these, I was not able to successfully reverse tether as I was getting reverse tethered data only on terminal emulator and default browser and not on Google Play apps. I have added details in another comment for that.
got it working for me!
reversed tethering worked for me by following the instructions and calling "netcfg usb0 dhcp".
However the WiFi tethering didnt work at first: Other Devices could connect to my phone but no data was forwarded...
The problem was that iptables was not setup properly...
Now I just connect my phone to the pc, enable usb tethering and wifi tethering and run the following:
Code:
adb devices
pause
adb shell netcfg usb0 dhcp
adb shell busybox ifconfig rmnet0 0.0.0.0
adb shell echo 1 > /proc/sys/net/ipv4/ip_forward
adb shell iptables --flush
adb shell iptables --delete-chain
adb shell iptables --table nat --delete-chain
adb shell iptables --table nat -F
adb shell iptables --table nat -X
adb shell iptables -t nat -A POSTROUTING -o usb0 -j MASQUERADE
adb shell iptables -P FORWARD ACCEPT
adb shell iptables -A FORWARD -i usb0 -o wlan0 -j ACCEPT -m state --state RELATED,ESTABLISHED
adb shell setprop net.dns1 8.8.8.8
Hope this helps
where did you posted the above codes ??
puit said:
got it working for me!
reversed tethering worked for me by following the instructions and calling "netcfg usb0 dhcp".
However the WiFi tethering didnt work at first: Other Devices could connect to my phone but no data was forwarded...
The problem was that iptables was not setup properly...
Now I just connect my phone to the pc, enable usb tethering and wifi tethering and run the following:
Code:
adb devices
pause
adb shell netcfg usb0 dhcp
adb shell busybox ifconfig rmnet0 0.0.0.0
adb shell echo 1 > /proc/sys/net/ipv4/ip_forward
adb shell iptables --flush
adb shell iptables --delete-chain
adb shell iptables --table nat --delete-chain
adb shell iptables --table nat -F
adb shell iptables --table nat -X
adb shell iptables -t nat -A POSTROUTING -o usb0 -j MASQUERADE
adb shell iptables -P FORWARD ACCEPT
adb shell iptables -A FORWARD -i usb0 -o wlan0 -j ACCEPT -m state --state RELATED,ESTABLISHED
adb shell setprop net.dns1 8.8.8.8
Hope this helps
Click to expand...
Click to collapse
where to paste the above codes ?

[Q] adhoc network problem

I have android 4.2.2 ,Nexus 4 I would like to setup adhoc network . Firstly I rooted the device, secondly I tried to create adhoc network in android phone : I create ad hoc network in an android smartphone like below:
[email protected]:/ # ip link set dev wlan0 down
[email protected]:/ # iwconfig wlan0 mode ad-hoc
[email protected]:/ # iwconfig wlan0 channel 6
[email protected]:/ # iwconfig wlan0 essid 'Test1'
[email protected]:/ # ip link set dev wlan0 up
[email protected]:/ # ifconfig wlan0 192.168.65.129
when I typed iwconfig wlan0: the result is:
Qcom:802.11n ESSID:"Test1"
Mode:Ad-Hoc Frequency:2.437 GHz Cell: 02:82:5F:C1:4B:C1
Bit Rate=0 kb/s Tx-Power=0 dBm
RTS thr=2347 B Fragment thr=8000 B
Encryption keyff
Secondly, in my laptop ,I could see "Test1",so I did connect to "Test1" and I configure static ip address 192.168.65.128. in this case ,the smartphone create the ad hoc network and my laptop join it,then I can ping from my laptop to mobile and vice-versa.
However,in other case when : my laptop create ad hoc network
and later in an android mobile ,I tried to join it :
[email protected]:/ # iwconfig wlan0 mode ad-hoc
[email protected]:/ # iwconfig wlan0 channel 6
[email protected]:/ # iwconfig wlan0 essid 'Test1'
But,when I type iwconfig wlan0 ,essid still off/any
Qcom:802.11n ESSIDff/any
Mode:Ad-Hoc Frequency:2.437 GHz Cell: Not-Associated
Bit Rate:0 kb/s Tx-Power=0 dBm
RTS thr=2347 B Fragment thr=8000 B
Encryption keyff
it seems that android mobile can create ad hoc network but can not join existing one.so the same result I found when I try to setup adhoc network between two android mobiles. can anybody tell me what it's wrong here,and if there is any possible solution.
I tried many methods to setup ad hoc network in android ,and only this method that it seems work,but it still something wrong that prevent android phone to join existing ad hoc network.
fadwa.ww said:
[email protected]:/ # iwconfig wlan0 mode ad-hoc
[email protected]:/ # iwconfig wlan0 channel 6
[email protected]:/ # iwconfig wlan0 essid 'Test1'
Click to expand...
Click to collapse
Did you forgot to execute "ip link set dev wlan0 up"?

[PORT] DHCPv6 Client for Android

Hi everyone,
This thread is obsolete because I found a solution check out my app here: http://forum.xda-developers.com/android/apps-games/app-dhcpv6-client-t3176443
This is port of Roy Marples dhcpcd client for Android.
Background:
The fact that Android doesn't support DHCPv6 is for many system administrators an eyesore.
The guys from google don't plan to implement this feature very soon or not at all. See https code.google.com/p/android/issues/detail?id=32621
Because of this I decided to cross compile the dhcpcd client from Roy Marples for android.
source: http roy.marples.name/projects/dhcpcd/home
This client was tested on my Nexus 5 with:
Chroma ROM (build from 05-06-2015 with Android 5.1.1)
3.4.107 UBER-L Kernel
Working
Execution of dhcpcd
Optaining AND setting IPv4 address
Optaining IPv6 address (but not assigning the address to an interface)
NOT Working
Assigning IPv6 address to an interface
running as dhcp user (will give you permission denied on the interfaces)
as replacement for the stock client (see below)
Installation
Connect your phone to your PC
Open an adb shell (adb shell)
ON PHONE:
Make a folder for the dhcp client
cd /sdcard && mkdir dhcpcd
ON COMPUTER:
Copy files to phone
adb push roy-marples-dhcpcd-android.tar.gz /sdcard/dhcpcd
ON PHONE:
cd /sdcard/dhcpcd
extract roy-marples-dhcpcd-android.tar.gz
tar -xf roy-marples-dhcpcd-android.tar.gz
aquire root
su
remount /system rw
mount -o remount,rw /system
copy dhcpcd client
cp out/system/bin/dhcpcd /system/bin/dhcpcd6
DO NOT OVERWRITE THE STOCK DHCP CLIENT!!!!!
Copy all other files and create folders
mkdir /data/misc/dhcp6 && mkdir /system/etc/dhcpcd6
cp out/system/etc/dhcpcd6/* /system/etc/dhcpcd6/.
copy required libs
cp libs/* /system/lib
setting permissions
chmod 755 /system/bin/dhcpcd6
chown root:shell /system/bin/dhcpcd6
chmod 644 /system/lib/ld-linux-armhf.so.3
chmod 644 /system/lib/libc.so.6
chmod 755 /system/etc/dhcpcd6
chmod 550 /system/etc/dhcpcd6/dhcpcd-run-hooks
chmod 644 /system/etc/dhcpcd6/dhcpcd.conf
chmod 770 /data/misc/dhcp6
chown dhcp:dhcp /data/misc/dhcp6
Behavior
dhcpcd - stock dhcp client
dhcpcd6 - my cross compiled dhcp client
This client will not work without the stock dhcpcd client for some reason.
When killing dhcpcd and connecting to a w-lan network dhcpcd will be started, you can then call dhcpcd6 and you will get a secondary IPv4 address, however you can get but not set an IPv6 address, see Issues to fix.
If you replace dhcpcd with dhcpcd6, android will not invoke a dhcpcd process, when connecting to a network, also manually over command line by calling dhpcd will not get an IP address.
If dhcpcd6 is invoked by the dhcp user (su dhcp -c "/system/bin/dhcpcd6") will give a permission denied at the interfaces for some reason.
Issues to Fix
You can obtain an IPv6 address but you can not assign it to an interface for some reason:
Code:
wlan0: soliciting a DHCPv6 lease
wlan0: ADV xxxx:67c:xxxx:52cc:xxxx::1419/128 from xxxx:67c:xxxx:52cc:xxxx::1
wlan0: REPLY6 received from xxxx:67c:xxxx:52cc:xxxx::1
wlan0: adding address xxxx:67c:xxxx:52cc:xxxx::1419/128
if_addaddress6: Invalid argument
I went through the source code and found out that the problem might come from the sendmsg function which basically sends data through a socket: if-linux.c line 865
Any advice would be appreciated
Troubleshooting
If you get something like this:
Code:
wlan0: Router Advertisement from 1234::1234:xxxx:xxxx:xxxx
wlan0: ignoring RA from 1234::1234:xxxx:xxxx:xxxx (no public prefix, no managed address)
Add ipv6ra_accept_nopublic to the /system/etc/dhcpcd6/dhcpcd.conf file
Help needed!
Basically just how to get it fully working
Any advise would be appreciated
Compiled with:
Compiled on: x86_64 GNU/Linux (Debian Jessie)
arm-linux-gnueabihf-
package: binutils-arm-linux-gnueabihf
preconfigure.sh
Code:
export CROSS_TARGET=arm-linux-gnueabihf
export CC="${CROSS_TARGET}-gcc-5"
## export CXX="${CROSS_TARGET}-g++"
export AR="${CROSS_TARGET}-ar"
export AS="${CROSS_TARGET}-as"
export LD="${CROSS_TARGET}-ld"
export RANLIB="${CROSS_TARGET}-ranlib"
export READELF="${CROSS_TARGET}-readelf"
export STRIP="${CROSS_TARGET}-strip"
Compile:
Code:
./configure --host=arm-linux-gnueabihf --enable-static --enable-ipv4 --enable-ipv6 --enable-embedded --sysconfdir=/system/etc/dhcpcd6 --bindir=/system/bin --libexecdir=/system/etc/dhcpcd6 --statedir=/data/misc/dhcp6 --dbdir=/data/misc/dhcp6 --rundir=/data/misc/dhcp6 --libdir=/system/lib
make -j2 ARCH=arm
mkdir out
make install DESTDIR=out
Thanks To:
Roy Maprles - for the source of his dhcp client
-realm_01
Edit 1 10:20 17-06-2015
I rebuilded the dhcpcd client with some changes in the directories, also I figured out what why I can't assign a IPv6 address
This thread is obsolete because I found a solution check out my app here: http://forum.xda-developers.com/android/apps-games/app-dhcpv6-client-t3176443

Categories

Resources