[Q] [ Reverse Tethering ] DNS is not working - General Questions and Answers

When I did same thing on Galaxy S3, it's working fine.
But When it did it on Galaxy Note2, it some times works. once out of 10 times works.
If you look below, ping is working. but it's not working with the domain name.
I did nslookup and it's working.
I browsed to a website throught IP and it's working. but it's not working with domain.
I tried to adjust DNS info in ADB shell but still not working.
it's working some times. but most out of times it's not working.
Please some body gives me any hint.
thank you.
--------------------------------------------------------------
C:\Users\JaeHo>ipconfig
Ethernet adapter Local Area Connection 9:
Connection-specific DNS Suffix . :
Link-local IPv6 Address . . . . . : fe80::99d3:e644:18aa:c0fe%49
IPv4 Address. . . . . . . . . . . : 192.168.137.1
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . :
---------------------------------------------------------------
C:\Users\JaeHo>adb shell
[email protected]:/ $ su
su
[email protected]:/ # netcfg rndis0 dhcp
netcfg rndis0 dhcp
[email protected]:/ # route add default gw 192.168.137.1 dev rndis0
route add default gw 192.168.137.1 dev rndis0
[email protected]:/ # ping -c5 philgo.com
ping -c5 philgo.com
ping: unknown host philgo.com
2|[email protected]:/ # ping -c5 168.126.63.1
ping -c5 168.126.63.1
PING 168.126.63.1 (168.126.63.1) 56(84) bytes of data.
64 bytes from 168.126.63.1: icmp_seq=1 ttl=52 time=105 ms
64 bytes from 168.126.63.1: icmp_seq=2 ttl=52 time=100 ms
64 bytes from 168.126.63.1: icmp_seq=3 ttl=52 time=100 ms
64 bytes from 168.126.63.1: icmp_seq=4 ttl=52 time=132 ms
64 bytes from 168.126.63.1: icmp_seq=5 ttl=52 time=100 ms
--- 168.126.63.1 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4005ms
rtt min/avg/max/mdev = 100.747/108.058/132.237/12.238 ms
[email protected]:/ # getprop net.dns1
getprop net.dns1
[email protected]:/ # nslookup philgo.com
nslookup philgo.com
nslookup: can't resolve '(null)': Name or service not known
Name: philgo.com
Address 1: 116.122.36.242
[email protected]:/ # ip route show
ip route show
default via 192.168.137.1 dev rndis0
192.168.137.0/24 dev rndis0 proto kernel scope link src 192.168.137.131

When setprop does not set the prop... :
Code:
iptables -t nat -A OUTPUT -p udp --dport 53 -j DNAT --to-destination 8.8.8.8:53

Related

[Q] problem with network apps from busybox on prime 1.6

Hello xda,
I have the problem with all networks apps from busybox like ping, wget etc. BTW, the same apps from android work fine:
Code:
bash-4.1# which ping
/system/xbin/ping
bash-4.1# ls -la /system/xbin/ping
lrwxrwxrwx 1 root 2000 20 Jul 26 07:49 /system/xbin/ping -> /system/xbin/busybox
bash-4.1# ping google.com
ping: bad address 'google.com'
bash-4.1# /system/xbin/busybox ping google.com
ping: bad address 'google.com'
bash-4.1# /system/xbin/busybox wget google.com
wget: bad address 'google.com'
bash-4.1# /system/bin/ping -c1 google.com
PING google.com (209.85.148.99) 56(84) bytes of data.
64 bytes from google.com (209.85.148.99): icmp_seq=1 ttl=53 time=44.2 ms
--- google.com ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 44.271/44.271/44.271/0.000 ms
bash-4.1#
Any solutions?
Thanks
using jping
I have terminal IDE, which includes jping, so I can use:
jping google.com | sed 's/.*: \(.*\)/\1/' | xargs ping
And I get the name resolved for me.

Reverse USB Tether Successful - Root, Command Line, Linux

Hey All,
Hope this hasn't been covered. I did search a bit and found some clues, but not something that totally worked for me. I figured I'd put up a post telling y'all how I made it work. I suppose this post is just more clues for somebody else, but at least it seems like a different set of clues than what I was able to find.
I've wanted to use the phone's USB connection to use work's Internet connection to download updates to my phone and conserve my measly 2GB/month data.
Running Cyanogenmod 9.1.0. Don't know how this would translate to others.
The tricks to reverse USB tether are
A) Get the phone to connect to a Linux host over the USB as in a normal tether
B) Set up IP forwarding and NAT on the Linux host (which has a perfectly fine Ethernet connection to the Internet)
C) Change the phone's default route to point at the Linux host
D) Change the phone to use the same DNS servers visible to the Linux host
A-C were pretty easy. D was actually the hardest. Here's my notes I'm storing on the phone:
***********************************************************************
* On the linux host
# ip addr show
2: p2p1: ...
inet 10.2.59.107/18 brd 10.2.63.255 scope global p2p1
7: usb0: ...
inet 192.168.42.151/24 brd 192.168.42.255 scope global usb0
* This part is classic "setting up a NAT" which is easily googled.
# echo 1 > /proc/sys/net/ipv4/ip_forward
# iptables -t nat -A POSTROUTING -o p2p1 -j MASQUERADE
# iptables -A FORWARD -i p2p1 -o usb0 -m state --state RELATED,ESTABLISHED -j ACCEPT
# iptables -A FORWARD -i usb0 -o p2p1 -j ACCEPT
* This tells us some IP addresses to use as nameservers.
cat /etc/resolv.conf
# nameserver 10.2.10.24
# nameserver 10.2.10.26
***********************************************************************
* On the android device disable all other methods of accessing the internet.
* That is, turn off Wi-Fi and System Settings, Wireless & networks, Mobile
* networks, Uncheck "Data enabled". This might not be necessary. I did it to
* make sure the rest of what I was doing worked.
* Try 'ip route' without other args and delete any existing default route if
* you have one.
# ip route add default via 192.168.42.151 dev rndis0
# getprop | grep dns
[net.change]: [net.dns2]
[net.dns1]: [172.26.38.1]
[net.dns2]: [172.26.38.2]
[net.dnschange]: [1]
[net.rmnet_sdio0.dns1]: []
# setprop net.dns1 10.2.10.24
# setprop net.dns2 10.2.10.26
* * Avoid the Primrose Path. This sort of acted like it would work, but then
* * didn't at all.
*
* # cat /emmc/resolv_work.conf
* nameserver 10.2.10.24
* nameserver 10.2.10.26
*
* # pkill dnsmasq
* # dnsmasq -d -r /emmc/resolv_work.conf

[Q] Android KITKAT - VPNService Route Exclusion

Hi All,
It is know that IP exclusion is almost impossible using Android VPN Service API in NON ROOTED Device.
But I have rooted device . So I first connect VPN ( openvpn ).
After than from ADB ROOT SHELL - I run following command
./route add -net <<DESTINATION_IP>> netmask 255.255.255.255 gw 192.168.1.1
For example if I run following command
./route add -net 141.101.120.15 netmask 255.255.255.255 gw 192.168.1.1
All traffic to whatismyip DOT com/ go directly ( Not passing through VPN )
Hence whatismyip.com reports my Local ISP IP in Its home page.
By these way I could exclude IPs from VPN path. This is working fine in ICS and Jelly without any issue.
But this same procedure not working in KITKAT. I tested both in 4.4.2 and 4.4.4
If I modify route, traffic still goes through VPN path. Whatismyip.com displaying VPN Server IP in its home page.
My KITKAT routing table shows following same as ICS and jelly. Command is successfully executed in routing table..But just not working..
Can anybody please point out what changes I need to make for KITKAT.
Thank you
----Fresh Routing Table -----
Code:
ip route
default via 192.168.1.1 dev wlan0
default via 192.168.1.1 dev wlan0 metric 324
192.168.1.0/24 dev wlan0 scope link
192.168.1.0/24 dev wlan0 proto kernel scope link src 192.168.1.2 metric 324
192.168.1.1 dev wlan0 scope link
----- After VPN Connected------
Code:
ip route
default via 192.168.1.1 dev wlan0
default via 192.168.1.1 dev wlan0 metric 324
172.22.1.4/30 dev tun0 proto kernel scope link src 172.22.1.6
192.168.1.0/24 dev wlan0 scope link
192.168.1.0/24 dev wlan0 proto kernel scope link src 192.168.1.2 metric 324
192.168.1.1 dev wlan0 scope link
------ After whatismyip dot com [141.101.120.15] exclusion ------
Code:
ip route
default via 192.168.1.1 dev wlan0
default via 192.168.1.1 dev wlan0 metric 324
[B]141.101.120.15 via 192.168.1.1 dev wlan0[/B]
172.22.1.4/30 dev tun1 proto kernel scope link src 172.22.1.6
192.168.1.0/24 dev wlan0 scope link
192.168.1.0/24 dev wlan0 proto kernel scope link src 192.168.1.2 metric 324
192.168.1.1 dev wlan0 scope link

[Q] Manually configure routing options for VPN tunnel

Hi All,
I have a stupid Juniper VPN device at work which does not support 64 bit linux clients using netconnect. I have found ways around this previously, but now we are setting up 2 factor auth which throws a lot of javascript into the mix, making the scripts I used pretty much obsolete. The Junos pulse client works well for android, so I am thinking I want to use an android device as a router. Connecting to the VPN and using wifi tethering does not work, same with USB tethering does not work, and those are not exactly what I want anyway.
So basically I want to be able to connect my android device to my wifi here at home, connect to the VPN on it, run a script to do my setup on the Android device, lastly add a route on my client pc to tunnel through the android device. here is what I tried so far on the device:
Code:
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -o tun0 -j MASQUERADE
iptables -P FORWARD ACCEPT
iptables -t nat -I POSTROUTING -s 192.168.0.0/16 -d 10.0.0.0/8 -j MASQUERADE
ip rule add from all to 10.0.0.0/8 fwmark 0x3c lookup 60
and on the client PC:
Code:
route add -net 10.0.0.0 netmask 255.0.0.0 gw 192.168.1.29
where 192.168.1.29 is the IP of my android device, and 10.0.0.0/8(I know its lazy) is the IP range I want to go through tun0 on the device. This is however not working.
The only thing I need to do on a standard linux box to do this would be:
Code:
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -I POSTROUTING -s 192.168.0.0/16 -d 10.0.0.0/8 -j MASQUERADE
And setup the same route command on the client but point it at the linux box instead. This currently works, but when we decide to flip the switch and use the 2 factor auth only I will not be able to make it work on a standard linux box, but 2 factor does work on android via the Junos app.
I fear I am missing something simple in Android land, please help...

[Guide][Root] Internet connection on Gear2 in 2 steps [Updated 2014.12.08]

I made attempt to share internet connection directly to Gear2 with quite big success. But first things first.
What you need:
- rooted gear 2 (neo)
- enabled network tethering over bluetooth on phone paired with gear 2 (tested on Galaxy S4)
Step 0: Enable sdb root
Code:
sdb root on
Step 1: using sdb copy required network tools to /tmp/ directory on gear and change permissions:
Code:
sdb push ifconfig /tmp/
sdb push pand /tmp/
sdb push route /tmp/
sdb push ping /tmp/
sdb shell chmod +x /tmp/ifconfig
sdb shell chmod +x /tmp/pand
sdb shell chmod +x /tmp/route
sdb shell chmod +x /tmp/ping
Step 2: open shell and run hcitool:
Code:
sdb shell
sh-3.2# hcitool con
Connections:
> ACL 5C:2E:xx:xx:xx:xx handle 12 state 1 lm SLAVE AUTH ENCRYPT
5C:2E:xx:xx:xx:xx - this is mac of your phone
Step 3: connect to phone
Code:
sh-3.2# cd /tmp/
sh-3.2# ./pand --connect 5C:2E:xx:xx:xx:xx
Now you should have new interface bnep0, you can run ./ifconfig -a to check
Step 4: Set IP and gateway
This part is bit tricky because I can't manage to get IP addres by dhcp so you have to check which addres you should assign. I've connected to S4 with other android phone and checked ip with IP Tools from Google Play.
Code:
sh-3.2# ./ifconfig bnep0 up
sh-3.2# ./ifconfig bnep0 192.168.44.200
sh-3.2# ./route add default gw 192.168.44.1
Step 5: Test connection
Code:
sh-3.2# ./ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8): 56 data bytes
64 bytes from 8.8.8.8: icmp_seq=0 ttl=44 time=716.873 ms
64 bytes from 8.8.8.8: icmp_seq=1 ttl=44 time=119.090 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=44 time=220.530 ms
64 bytes from 8.8.8.8: icmp_seq=5 ttl=44 time=197.332 ms
64 bytes from 8.8.8.8: icmp_seq=6 ttl=44 time=199.790 ms
64 bytes from 8.8.8.8: icmp_seq=7 ttl=44 time=136.653 ms
64 bytes from 8.8.8.8: icmp_seq=8 ttl=44 time=147.867 ms
^C--- 8.8.8.8 ping statistics ---
9 packets transmitted, 7 packets received, 22% packet loss
round-trip min/avg/max/stddev = 119.090/248.305/716.873/194.396 ms
As you can see connection isn't very stable.
What opportunities does that give to us?
XMLHttpRequest from watchface or application without bridge app on phone
Standalone webbrowser
...?
TODO:
dhclient
auto connection when paired with phone
DNS
Integration with ROM
Update 1:
dhclient now works (dirty hand made dhclient-script)
DNS works (thanks to Talon^)
Permanent write to rom (still no autoconnect)
I've crated tar package which should make all process more easy
To install gearnet.tar package do the following:
1. By adb
Code:
sdb push gearnet.tar /tmp/
sdb root on
sdb shell
In Gear shell prompt:
Code:
sh-3.2# mount -o remount,rw /
sh-3.2# tar --overwrite -xvf /tmp/gearnet.tar -C /
sh-3.2# reboot
now after reboot you should be able to run command as root:
Code:
sh-3.2# gearnet
sh-3.2# ping google.pl
PING google.pl (74.125.195.94): 56 data bytes
64 bytes from 74.125.195.94: icmp_seq=0 ttl=45 time=132.238 ms
64 bytes from 74.125.195.94: icmp_seq=1 ttl=45 time=184.377 ms
64 bytes from 74.125.195.94: icmp_seq=2 ttl=45 time=151.909 ms
64 bytes from 74.125.195.94: icmp_seq=3 ttl=45 time=104.898 ms
64 bytes from 74.125.195.94: icmp_seq=4 ttl=45 time=153.549 ms
64 bytes from 74.125.195.94: icmp_seq=5 ttl=45 time=181.517 ms
^C--- google.pl ping statistics ---
6 packets transmitted, 6 packets received, 0% packet loss
round-trip min/avg/max/stddev = 104.898/151.415/184.377/27.474 ms
sh-3.2#
Oh what fun that was! This is really cool. It worked on my Gear 1 . I had 9% packet loss....... can't wait to see what's next and thanks for sharing!
Chris
Awesome!
I was searching for this FOREVER! This is awesome I really look forward to any updates for this.
When I first bought the watch I assumed this was already possible, but greatly disappointed that it wasn't possible. This now gives me hope, and makes me want to keep the watch!
any chance for dns?
following your guide, I snooped at other packages. I managed to get these installed for an attempt at perl:
gdbm-1.8.3-1.1.armv7l.rpm
perl-libs-5.12.1-1.4.armv7l.rpm
perl-Module-Pluggable-3.60-1.4.armv7l.rpm
perl-Pod-Simple-3.07-1.4.armv7l.rpm
perl-IO-Compress-Base-2.008-1.4.armv7l.rpm
perl-5.12.1-1.4.armv7l.rpm
still missing a few dependencies but it finally worked with --nodeps and now I have perl5 on my gear 2 neo
I wanted to test some sockets so I wrote a quick snippet for irc and it kept failing with my die message of can't connect. then I tried to "ping" a domain, and realized there's no DNS, so once I resolved the irc servers domain and used the IP, it connected flawlessly!
here's a screenshot of my sdb shell running a test perl file of the IRC client snippet.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
got any ideas how to get DNS working to resolve domains so you don't have to find the IP?
found how to get DNS
theres a file in /etc called resolv.conf, I just modified it to include googles nameservers 8.8.8.8 and 8.8.4.4, now DNS lookups are possible, you can now say: ./ping google.com
dumb question...but does web gear has standalone web browsing? Correct me if i'm wrong....
the GearWeb browser?
the GearWeb browser from the Samsung Galaxy APPS store uses the SAP for it's content. (Samsung accessory protocol) Without rooting and doing this networking trick, the gear 2 (gear 2 neo also) has no direct ties to the internet, nor do any available apps. They all use the phone itself for content and share that content via SAP.
This requires you to also know Java, as the nature of how this works is an android application running as a background process on your phone waiting for a SAP connection from your wearable device, then serving the content back to the device over bluetooth. I could be wrong but this appears to be a poll-only operation. You can't just send content from the host Java App without first having a fetch request from the wearable device, which to me makes it almost worthless, especially if you wanted to do any real protocol development for your gear like IRC, Facebook Messenger, etc.. that require a live streaming socket.
Btw, I have successfully tested this networking with the STOCK Tizen IDE for Wearable with the ECMA 3 Browser Support XMLHttpRequest() and can confirm that this does now work on the watch, as long as you initiated the network.
It didn't work at first but I figured out why. You must grant it internet privileges in your config.xml and also give it an access parameter under the Policy tab. Wildmatches DO work for access policy. I gave it a vague "*" with allow subdomain true, and it works just fine.
I don't know about auto-reconnect but I believe that I should be able to make a service descriptor for systemd to init your new gearnet script. The .service files are located in /usr/lib/systemd/system
I'm going to try modifying the sap.service file in there and making a new one called gearnet.service and seeing if I can get network to start upon boot.
If this works, upon starting your gear, it should automatically attempt to establish a network connection. Not sure about making it reconnect if you walked too far away from your phone and came back into range, but as long as you don't do that, networking should be possible on boot of your wearable device
successful networking upon boot
ok so I figured out how to get the watch to connect on first boot.
this is a linux operating system (tizen is a form of linux) you need some tool that can handle UTF-8 character encoding with the line ending of Unix/Linux. Typical windows notepad uses windows standard line ending which is CRLF (carrage return [ASCII CODE: 13], line feed [ASCII CODE: 10]) while I believe unix/linux just uses LF. I pulled a .service file and just modified it and saved it as a different name but I used a windows build of the popular gnome editor known as 'gedit'. WordPad will also work, but NotePad will NOT!
make a file (or pull one and modify it to keep the UNIX line endings if you plan on using wordpad), call it gearnet.service with the following code:
Code:
[Unit]
Description=GearNet service
After=weconn.service
[Service]
Type=forking
ExecStart=/sbin/gearnet
Restart=always
[Install]
WantedBy=multi-user.target
push the file to /usr/lib/systemd/system
then systemctl enable gearnet.service
shut down the watch. The problem with this is, if/when you disable bluetooth on your device (on my S4) the bluetooth tethering is turned off. you must re-enable it. make sure it's enabled before powering your watch on again. (S4 it's in settings > More Networks > Tethering and Portable Hotspot)
power on your watch, you'll see once it boots on your phone, connected to <device> then shortly after, Tethering/Portable Hotspot active.
NOTE: tested to see if the internet would come back if you walk too far away from your phone. As I suspected, this fails, while the bluetooth pairing comes back, the network does not :/ I'll have to see if I can figure a way to fix this issue, but for now, instant network access upon boot is GREAT! no more needing to connect your gear to the PC and manually start networking
EDIT
I'm looking for a better solution, but I have modified the gearnet shell script and pushed it to /sbin/gearnet. This will fix the issue of losing internet connection when walking too far away from your phone, once you come back in range, the network will also come back.
Code:
#!/bin/sh
while true; do #create a infinite loop to keep looking at your connection
NET=$(ifconfig bnep0 | grep "inet addr:") # verify if the interface has an assigned IP
if [ ! "$NET" != "" ]; then # If we don't already have an IP
btaddr=$(hcitool con | awk '{print $3}' | sort -rn | head -n 1)
if [ "$btaddr" != "" ]; then #verify there's a paired device to connect to
pand --connect $btaddr
sleep 5
dhclient bnep0
fi
fi
sleep 5
done

Categories

Resources