enable wireless and 4g at the same time

jdock

Senior Member
Dec 27, 2011
242
63
48
Is there any way to do this? It seems that when I enable wifi, the rmnet_usb0 interface becomes inaccessible (no ipv4 address). When I disable wifi, even the wlan and cfg80211 modules get unloaded. I can't seem to find the way to load them (with wifi set as disabled) to try to ifconfig the interface up. Maybe I am just going about it in the completely wrong way!

All I really want is to have both interfaces up and running at the same time, with the default gateway pointing out the rmnet_usb0 interface so that I can access the internet via 4g, but still being able to route to my local wireless lan.
 
  • Like
Reactions: maxleebo

chrisphoenix7

Senior Member
Jan 23, 2011
260
24
0
My laptop has wifi and bluetooth on the same assembly, and only 1 is accessible at once. Maybe its like that.

Sent from my LG-E970 using xda app-developers app
 

jdock

Senior Member
Dec 27, 2011
242
63
48
I know they can physically be enabled at the same time, because the phone can be a hotspot. That doesn't really help me though if I want to connect wired devices to it. I want it to remain a wifi client.

There's an app called SuperDownload or something that uses wifi and mobile data simultaneously for downloading. It seems to bring the mobile data up in some special mode where the app can use it but it's not otherwise generally routable. That's what the author says, at least, but I'm not sure that makes sense. Normally when data is in use it basically looks like any other network interface.

A more general way of asking my question might be "what happens behind the scenes when you enable wifi?" if there's a script being run I can see what's going on (loading the module and so on) and maybe adapt it to my needs.
 

jdock

Senior Member
Dec 27, 2011
242
63
48
SUCCESS I think: enable wireless and 4g at the same time

http://forum.xda-developers.com/showthread.php?t=1667025

This app uses them both simultaneously, maybe you can get some info there..
Yep that's the one I mentioned. Doesn't seem to be much help.

I think I've gotten somewhere. I can't test this fully because I don't have access to any other machines on the current wireless lan, but I can get a dhcp address from it and ping its gateway, while meanwhile traceroutes to the internet are going through the mobile network.

1. Turn off wifi in the normal way (from the phone's user interface) if it's not already off.

All the following steps done in a root shell:

2. load the drivers

busybox insmod /system/lib/modules/cfg80211.ko
busybox insmod /system/lib/modules/wlan.ko

3. start wpa_supplicant to connect to the first available wireless network. The wpa_supplicant.conf file I list below is the one maintained automatically by the phone as you join new networks. If you want more control (e.g. connect to only a specific network), copy the wpa_supplicant.conf file somewhere, modify it as needed, and specify it on the command line.

wpa_supplicant -B -Dnl80211 -iwlan0 -c/data/misc/wifi/wpa_supplicant.conf

4. dhcpcd

busybox pkill dhcpcd
rm /data/misc/dhcp/*
dhcpcd wlan0

5. verify route

busybox route

For me this is showing the original default first on the list (goes through rmnet_usb0) followed by the new one configured for the wireless lan wlan0. Traceroute shows the traffic going out the first one.

Now, at this point if you try to enable wifi normally from the phone it will not work. To make it work:

ifconfig wlan0 down
ifconfig wlan0 unplumb
rmmod wlan
rmmod cfg80211


And you can turn on wireless again.
 

jdock

Senior Member
Dec 27, 2011
242
63
48
I was able to test at home, and it is definitely working.

As for what this buys us, there are two things. First, I have crappy satellite internet at home, so I want to be able to transfer files back and forth, and sometimes even use the LG OSP, without my phone having to use that instead of 4G (which is marginal but still better).

More usefully, it allows non-tethered proxying. I can run a socks or http proxy on my phone and point my non-wireless devices at it, letting me browse the web without routing all my internet traffic through the phone.

I'm still a little bit away from non-wireless tethering (i.e. being able to set my pc's default gateway to my phone and have it route all internet traffic through the mobile data connection), but that would be nice as well. I will need to set up some iptables NAT stuff the way wifi tether does, and I haven't gotten the right combination yet since I don't get much opportunity to test it.
 
Last edited:
  • Like
Reactions: ashishtanwer

sordna

Senior Member
Dec 12, 2012
1,262
646
113
works on nexus4 too

Thank you so much for this info, I was able to change things a bit and make it work on my stock / rooted Nexus 4:

Code:
# enable dual-networking:
pkill dhcpcd
svc wifi disable
svc data enable
netcfg wlan0 up
cd /data/misc/wifi/.
wpa_supplicant -B -Dnl80211 -iwlan0 -c/data/misc/wifi/wpa_supplicant.conf
dhcpcd wlan0
ip route add x.x.x.x via x.x.x.y # add any desired local route

# disable dual-networking:
ip route del x.x.x.x/x via x.x.x.y
pkill dhcpcd
pkill wpa_supplicant 
rm -rf /data/misc/wifi/wlan0
netcfg wlan0 down
svc wifi disable
svc data disable
I use SH Script runner to create and run the 2 above scripts easily.
 

harshitaneja

Member
Sep 26, 2012
32
1
0
I am a newbie... Do I have to just run the script in Sh script runner? And I don't know what IP route to use.

Sent from my GT-I9300 using XDA Premium 4 mobile app

---------- Post added at 12:25 PM ---------- Previous post was at 11:26 AM ----------

I am not able to load the drivers.. It's showing not found.. Even though I have installed busy box using busy box installer pro

Sent from my GT-I9300 using XDA Premium 4 mobile app

---------- Post added at 12:30 PM ---------- Previous post was at 12:25 PM ----------

I checked the directory using root Explorer and I can't find cfg80211.ko and wlan.ko

Sent from my GT-I9300 using XDA Premium 4 mobile app
 

sordna

Senior Member
Dec 12, 2012
1,262
646
113
Whether you have any kernel modules to install with insmod, depends on your phone model, ROM, kernel.

For my nexus 4 with franco.kernel I don't have the modules either, but got it to work fine. So maybe its a similar situation with your phone .

SH script runner is not required, you can run the script in any terminal app after doing su.

EDIT: Some other interesting threads related to this topic are here:
http://forum.xda-developers.com/showthread.php?t=1640472
http://forum.xda-developers.com/showpost.php?p=13758490&postcount=1
http://forum.xda-developers.com/showthread.php?t=1667025
 
Last edited:
  • Like
Reactions: vandiere