Bring up network from command line? [Lollipop] - Android Q&A, Help & Troubleshooting

I've got a little shell script that uses ffmpeg to record an http audio stream on my rooted Amazon Fire 5th generation tablet with Nexus ROM. If I manually run my script, it's all good. But when I use SManager to schedule the script to run at a time that the device is asleep, ffmpeg can't access the network ... even though SManager gets a wakelock. Hmm.
I put "netcfg" in my script; when it next does its scheduled run (while device is sleeping) netcfg shows that wlan0 is up but has an IP of 0.0.0.0. Problem! Can I successfully bring up the network from the command line in this situation? This is what I've come up with:
ifconfig wlan0 up
ifconfig wlan0 192.168.1.140 netmask 255.255.255.0
route add default gw 192.168.1.1 dev wlan0
setprop net.wlan0.dns1 8.8.8.8
setprop net.wlan0.dns2 4.4.4.4
After that, wlan0 does have an IP address, but ffmpeg still can't access the network. Giving ffmpeg an IP address rather than a URL results in "no route to host", so I don't think that it's DNS problem. I'm probably just not giving the right commands to bring up the network. Is there a way to succeed at what I'm trying to do?

Related

Bluetooth tethering with Tablet S and Wildfire

I have write a script that simpliefies a bluetooth pan connection on the devices in topic.
I have spend a lot of time doing this. Not for writing the script but to find out whats going wrong when connect those devices.
You need ics on phone or wireless tether on honeycomb or others. If you use wireless tether you have to set it to use bluetooth.
So on now copy this script somewhere on your device save it under initpan.sh.
In console chmod 755 initpan.sh
Execute it and yes thats it so easy but so so heavy.
Here is the script:
#!/system/bin/sh
# Setup Handy Network
/system/bin/pand --connect F8B:7F:099:66
/system/bin/ifconfig bnep0 down
dhcpcd bnep0
setprop net.dns1 8.8.8.8
Sent from my Sony Tablet S using XDA Premium HD app
Your sensemilla
I'm not certain on this (haven't used PAN on Android much), but I'm pretty sure that script would need to be changed by whoever wants to use it, since it seems to be hardcoded to the Bluetooth interfaces MAC address which is device-unique.
Also, what are you actually trying to do? In the script, you bring the virtual interface down, then configure it for DHCP, then manually set the Google DNS, then don't bring it back up again? What's actually meant to be going on?

Reverse USB tethering Script

Hello every body,
This is my first post here
I had rooted my Xperia S two days ago and since then I am exploring my root capabilities.
I wrote a script to hook my Xperia S to my LAN Via USB.
Here is what I did.
1-connect Xperia S to PC in Regular USB Tethering mode.
2-bridge the network adapter form the phone with PC LAN Adapter and set IPv4 Settings Manually.
3-Run the following script on the phone.
Code:
ifconfig rndis0 192.168.1.99
ip route add 0.0.0.0/0 via 192.168.1.1 dev rndis0
ip route add 0.0.0.0/0 via 192.168.1.1 dev rndis0 metric 213
ip route del 192.168.1.0/24
ip route add 192.168.1.0/24 via default dev rndis0 proto kernel scope link src 192.168.1.99 metric 213
ip route add 192.168.1.1 via default dev rndis0 scope link
setprop net.nds1 8.8.8.8
setprop net.nds2 8.8.4.4
here I tried to mimic the same routing table form regular WIFI connection.
And it WORKS!!
but with a strange behavior.
After these steps I try to ping PC (form phone) and it is Unreachable, and the gateway is the same.
But after I reverse the operation and ping the phone from PC and from the gateway, the network operates normally , and phone pings through the gateway to the internet. also , I can receive streams from my PC and Access my mobile's FTP server , stock browser works.
But the Market cannot download apps , Maps cannot load.
I wonder why This is happening?
If you have an answer , I would be delighted to know it.
Thank You.
Maps cannot load.
Click to expand...
Click to collapse
It did load after some time , it needed patience , although it popped up "Data Connection not Available".
After these steps I try to ping PC (form phone) and it is Unreachable, and the gateway is the same.
But after I reverse the operation and ping the phone from PC and from the gateway, the network operates normally , and phone pings through the gateway to the internet.
Click to expand...
Click to collapse
Since it worked after it was pinged and learned MAC addresses.
I think there is a problem in layer 2, for some reason it cannot send ARP requests.
Success
After Upgrading to Windows 8 , The same script works as it should.
My Xperia S can now ping all network devices directly.
It seems that there was some thing wrong with My previous Win7.
But still there are some applications that can't deal with USB internet.
Google Play can navigate and search but can't download apps.
I think this topic was moved to inappropriate sub-forum (> Sony Xperia P, U, Sola, Go > Xperia P, U, Sola, Go General ) , it is related to Xperia S Please move it there.
Thank You.

[Q] Help with Tethering via wifi/bluetooth to OpenVPN

Hello,
I'm new to the forum, and I've tried to get this working on my own, but I'm stumped and am hoping someone out there can help me out.
I just bought a shiny new Nexus 7 tablet and would like to tether it to my Galaxy S III phone. I'm currently on a pay as you go plan on my phone where I have an "internet browsing" plan (via SpeakOut). This appears to limit my data services so I can't tether my tablet to the phone and get internet service on the tablet. Tethering works fine if the phone is connected to WiFi, an option I don't have when I'm on the train, doing my commute to work.
So, I've been trying to get OpenVPN set up at home to route all my mobile traffic through that and get tethering working for the tablet. But, I'm stuck with getting the tablet to route traffic over the VPN tunnel. The phone itself has no problems connecting and using the VPN link, but the tethered tablet (via WiFi or Bluetooth) gets no service. The best I can do is ping the phone and traceroutes go to the phone, but never get past it.
I've tried to read the man pages for OpenVPN, but each example uses its own IP blocks and it makes piecing it all together really confusing. In any case, I'm hoping someone here can help me out with this setup.
Here's my setup:
Code:
HOME LAN NET: 192.168.1.0/24
HOME GATEWAY: 192.168.1.1
OPENVPN NET: 10.8.0.0/24
OPENVPN SERVER
LAN IP: 192.168.1.116
VPN (internal) IP: 10.8.0.1
VPN (external) IP: 10.8.0.2
PHONE
VPN IP: 10.8.0.6
WIFI TETHER NET: 192.168.43.0/24
WIFI TETHER IP: 192.168.43.1
TABLET
WIFI TETHER IP: 192.168.43.150
Here is my OpenVPN server.conf file:
Code:
port 1194
proto tcp
dev tun
ca /etc/openvpn/keys/ca.crt
cert /etc/openvpn/keys/server.crt
key /etc/openvpn/keys/server.key
dh /etc/openvpn/keys/dh1024.pem
server 10.8.0.0 255.255.255.0
ifconfig-pool-persist ipp.txt
client-config-dir /etc/openvpn/ccd
route 192.168.43.0 255.255.255.0
push "redirect-gateway def1 bypass-dhcp"
push "dhcp-option DNS 8.8.8.8"
push "dhcp-option DNS 8.8.4.4"
keepalive 10 120
comp-lzo
user nobody
group nobody
persist-key
persist-tun
status openvpn-status.log
verb 4
and the client config file for the phone:
Code:
iroute 192.168.43.0 255.255.255.0
Please note, the OpenVPN server is a Mac running OS X 10.7.5 so I use the following script to set up the environment:
Code:
#!/bin/sh
sysctl -w net.inet.ip.fw.enable=1
sysctl -w net.inet.ip.forwarding=1
killall -9 natd
natd -interface en1 -u
ipfw -f flush
ipfw add divert natd ip from any to any via en1
here's my routing table on the server (netstat -rn):
Code:
Internet:
Destination Gateway Flags Refs Use Netif Expire
default 192.168.1.1 UGSc 10 31915 en1
10.8/24 10.8.0.2 UGSc 0 0 tun0
10.8.0.2 10.8.0.1 UH 2 0 tun0
127 127.0.0.1 UCS 0 0 lo0
127.0.0.1 127.0.0.1 UH 0 765 lo0
169.254 link#5 UCS 0 0 en1
192.168.1 link#5 UCS 3 0 en1
192.168.1.1 98:fc:11:82:7d:4b UHLWIi 11 8799 en1 1171
192.168.1.116 127.0.0.1 UHS 2 153 lo0
192.168.1.120 0:1f:e2:88:af:a9 UHLWIi 0 1678 en1 1165
192.168.1.255 ff:ff:ff:ff:ff:ff UHLWbI 1 98 en1
192.168.43 10.8.0.2 UGSc 0 0 tun0
and the output of ipfw list:
Code:
00100 divert 8668 ip from any to any via en1
65535 allow ip from any to any
Any help with getting this running would be appreciated. Note, NEITHER the phone or tablet is rooted and I'd prefer to keep it that way, if possible. Secondly, I'd prefer to get the tethering set up via Bluetooth, so any guidance on that would be helpful, too. I have no idea how to inspect Bluetooth connectivity, though. Or, if you know a better way to get this tethering to work that doesn't involve OpenVPN I'd love to hear it.
Thanks!
Squeaky
Solution see cross-link
See http://forum.xda-developers.com/showpost.php?p=33749904&postcount=10
Recommended app, i use it to tether all the time
https://play.google.com/store/apps/details?id=com.opengarden.android.MeshClient&hl=en

enable wireless and 4g at the same time

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.
I think your best bet is going to be setting up a vpn
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
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.
http://forum.xda-developers.com/showthread.php?t=1667025
This app uses them both simultaneously, maybe you can get some info there..
SUCCESS I think: enable wireless and 4g at the same time
bigworm50 said:
http://forum.xda-developers.com/showthread.php?t=1667025
This app uses them both simultaneously, maybe you can get some info there..
Click to expand...
Click to collapse
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.
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.
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.
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
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

[Q] Changing MAC Address

I have a need to change the WiFi MAC address on the phone. I looked a few places and it seems it's something very device specific. So how can I change it on my S3? Please and thank you.
Change it or spoof it?
Sent from my GT-I9300 using Tapatalk 2
In terminal emulator type these commands:
Disable network
ifconfig "interface" down
Change the MAC address of the interface
ifconfig "interface" hw ether 01:02:03:04:05:06
Enable network
ifconfig "interface" up
Checking the MAC address
ifconfig "interface"
where "interface" is usually wlan0, it should work

Categories

Resources