[Q] wifi 3g/4g simultaneously - Nexus 5 Q&A, Help & Troubleshooting

I want to do MPTCP.
I've tried many ways to let them work at the same time.
But I still can't use them.
I use adb shell.
First, I let 3g always on, and turn off the wifi
then,
netcfg wlan0 up
wpa_supplicant -B -Dnl80211 -iwlan0 -c/data/misc/wifi/wpa_supplicant.conf
but in here, i use 'netcfg' to see the network informantion
I can't get the WiFi's IP address, I only can get 3G IP or WiFi IP
http://forum.xda-developers.com/showthread.php?t=2197776
http://forum.xda-developers.com/showthread.php?t=1640472
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
I use dhcpcd wlan0
「Version 5.5.6 Starting,
wlan0: waiting for carrier
timed out
allowing 8 seconds for IPv4LL timeout
timed out 」
so, how can I get the dual networks IP address?

Related

[ubuntu] Manual (no app) LAN Reverse Tethering

this has been tested on ICS. You will need Terminal Emulator with root privileges. you may not have to use (or have different) full path to the binaries but they are shown when used as part of a file eg. "/system/bin/".
Android
Code:
Settings -> More... -> Tethering & portable hotspot -> USB tethering
this will bring up the usb network device with an automatically assigned IP address on both the host and client ie. PC and phone.
Linux
Code:
$ sudo su
# echo 1 > /proc/sys/net/ipv4/ip_forward
# exit
$ ifconfig
[b]usb0[/b] Link encap:Ethernet HWaddr 1e:98:35:16:12:cd
inet addr:[b]192.168.42.170[/b] Bcast:192.168.42.255 Mask:255.255.255.0
inet6 addr: fe80::1c98:35ff:fe16:12cd/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:537 errors:0 dropped:0 overruns:0 frame:0
TX packets:671 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:55661 (55.6 KB) TX bytes:346260 (346.2 KB)
look for device usbX where X is the connected device number. e. if there is only one tethered device connected it would most likely be usb0.
grab the PC usbX devices IP prefixed with "inet addr:". in this example the address is 192.168.42.170.
if you do not see a usbX network device, you will have to setup RNDIS, which is outside the scope of this example howto.
Android
Code:
Apps -> Terminal Emulator
open terminal emulator.
Code:
$ su
# route add default gw [b]192.168.42.170[/b] dev usb0
# exit
$ exit
NB, substitute with the PC IP address you obtained earlier.
with these steps completed, the phone will send outgoing packets to the PC address then the PC will forward packets to its default gw (gateway).
my router at work (where i use this) is already forwarding for the example network class above so i do not have to go any further than this.
google play appears to work but downloading does not seem to actually happen. i tried leaving mobile data enabled with this method and it did not work, others may have success. i obviously do not have a wifi AP to connect to, so it still might be possible to connect to an AP and use this method to enable download in google play (but that seems a bit redundant if you are able to connect via wifi in the first place).
at this point try the browser and attempt to load any site. if it does not work then continue on with the remaining steps; you can either bridge the usbX and ethX device (or whatever your LAN device is), change the IP (on both PC and phone) of usbX to the same network class (as your LAN) or have the PC network translate on behalf of the phone (untested as i dont need it). below is an example of NAT (network address translation) for linux; for bridging or changing the IP addresses please use google for a howto.
Linux
Code:
$ vi nat_ethX.sh
use an editor and paste the follow code below into the script or type the three lines below manually (ignoring the first line).
Code:
#!/bin/sh
/sbin/iptables -F --table nat
/sbin/iptables -P FORWARD ACCEPT
/sbin/iptables --table nat -A POSTROUTING -o eth0 -j MASQUERADE
replace eth0 with the actual PC ethX network device name relevant to your LAN setup.
Code:
$ chmod 744 nat_ethX.sh
$ sudo ./nat_ethX.sh
change the permissions of the file and run it.
again this is untested, but your PC should now be sending packets from its own IP address on behalf of the phone which your router is already accepting.
Code:
iptables -F --table nat
to remove the NAT iptables rules
Wi-Fi Hotspot
Code:
Settings -> More... -> Tethering & portable hotspot -> Portable Wi-Fi hotspot
this will bring up the wifi network device with a static IP on the host and an automatically assigned IP address on the client ie. first phone and second phone (in this example).
on the second phone, connect to the newly created AP from the first phone.
as wifi is enabled on the second phone google play will actually download. you do not need to setup anything else on the second phone.
Android (first phone)
Code:
Apps -> Terminal Emulator
open terminal emulator.
Code:
$ su
# route add default gw [b]192.168.42.170[/b] dev usb0
if you enable the wifi hotspot on the first phone, you must once again reset the default gw in the route table.
Code:
$ su
# echo 1 > /proc/sys/net/ipv4/ip_forward
IP forwarding should have been automatically set when enabling the wifi hotspot feature. you should not have to do this step, it should not break anything if you do.
Code:
#!/system/bin/sh
/system/bin/iptables -F --table nat
/system/bin/iptables -P FORWARD ACCEPT
/system/bin/iptables --table nat -A POSTROUTING -o usb0 -j MASQUERADE
again you can probably route another way, but here i am using NAT once more as in my case, the wifi hotspot / AP device wl0.1 is set to another network class (192.168.43.0) from that of usb0 (192.168.42.0). like the example above, you can place this in a file and run it, or type the three lines manually (ignoring the first line).
Code:
iptables -F --table nat
to remove the NAT iptables rules
Terminal Emulator (extra info.)
Code:
$ ifconfig
$ iwconfig
you can check the wifi hotspot network device name and information, in my case it is wl0.1. use google for more information on these commands.
Code:
$ ip route show
is another way to see the route table, if the default route command does not print the table with the ROM you are using.

join ad hoc network

Hello all,
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 with this:
-------------------
[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:
result1:
-----------------
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
result2:
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:
in both android mobiles I typed :
--------------
[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
-------------------
for the first one I configure
[email protected]:/ # ifconfig wlan0 192.168.65.129
the second one:
[email protected]:/ # ifconfig wlan0 192.168.65.127
so the result of iwconfig wlan0:
in the first one: like result1
in the second android smartphone :like result2
and of course ,I can't ping from one to other.
in brief,it seems that in android smartphone I can create adhoc network but I can't join existing one.
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 my android mobiles,and only this method that it seems work,but it still something wrong that prevent android phone to join existing ad hoc network.

Nexus 5 - Android L wifi tethering fix

Thanks to @buraktamturk here
Here is solution for tethering (both usb and wireless).
Tether just as usual. Then disable tethering and re-enable it. (this step is important otherwise dhcp server is not started)
After doing that both your phone and computer will not connect internet, because of invalid routing table. (internal bug from l preview)
just connect to the phone shell with 'adb shell', or terminal software on android (connectbot or android terminal emulator will fine)
Code:
[email protected]:/ $ su
[email protected]:/ # ip route | grep rmnet0 | grep link
10.64.70.120/29 dev rmnet0 proto kernel scope link src 10.64.70.124
Note the gateway here (10.64.70.124), and set this default gateway. (and yes, my provider gives me nat'ed private ip addresses)
Code:
[email protected]:/ # route add default gw 10.64.70.124 dev rmnet0
Enjoy the tethering!

setting up Ethernet connection (progress report)

Hello, I'm attempting to setup up ethernet on my G920F using bobjgear usb 2.0 ethernet adapter.
Here is my progress:
1. Rooted with Xtrestolite 5.1.1, Vindicator kernel, busybox.
2. app to turn on eth0 is called "Ethernet Droid":
-assigned IP (within range) (192.168.1.67)
-assigned default gateway (192.168.1.254)
-assigned subnetmask (255.255.255.0)
-NOT assigned DNS
3. terminal emulator shows eth0 as UP with the IP assigned.
4. my ATT U-verse router shows a device connected with the assigned IP.
in terminal emulator when typing:
# netcfg eth0 dhcp
I get:
# action 'dhcp' failed (operation not permitted)
in terminal emulator when typing:
# ifconfig eth0
I get:
# eth0: ip 192.168.1.254 mask 255.255.255.0 flags [up broadcast running multicast]
in terminal emulator when typing:
# ping -c 4 192.168.1.254
I get:
# connect: Network is unreachable
-----------------------------------------
This is as far as I've been able to get, any further progress would be greatly appreciated, as I'm really trying to set up ethernet chromecast with a portable router for display out. A lot of people have complained of the lack of MHL and HDMI support which was really a shock to me when I found out...
I'm not a coder, nor an export on linux, so any help please keep the instructions simple and clear, thank you really truly.
sergeivich said:
# ping -c 4 192.168.1.254
I get:
# connect: Network is unreachable
Click to expand...
Click to collapse
I guess this is a Android 5.x bug or missing permission.
Please try the following:
1. su (in your terminal)
2. netcfg eth0 dhcp (this should work as superuser)
3. exit
4. ping your IP of your mobile phone ping -c4 192.168.1.XXX (this should work)
5. su
6. ping your gateway ip ping -c 4 192.168.1.YYY (this should work as superuser)
7. exit
8. ping your gateway ip ping -c 4 192.168.1.YYY (do you get now: android connect network is unreachable ?)
Until CM11 (Android 4.4.4) I could use my eth0 interface as normal user for everything. In oder to switch between wlan0 and eth0 you can use the ethernet-2.XX.apk. Some APPs absolutely want wlan0. For these APPs you could install one of the xposed framework modules HACK CONNECTIVITY SERVICE 1.4 or Fake Wifi Connection
BUT obviously since CM12 (Android 5.x) I have the same problem as you:
BUG/missing permissions? eth0 (USB->LAN) interface only usable as root user in terminal since CM12
When I try to ping my router ping 192.168.1.1 or any internet IP I get a android connect network is unreachable.
The only IP-adrress I can ping as normal user is my own IP-adress of the eth0 interface (for expample 192.168.1.XX).
After login as root with the su command in the terminal I can ping the router IP and every internet IP.
Even disabling the iptables filters/firewall did not help.
When I switch to the wlan0 interface I can ping everything with my normal user and the internet connection is available for every app.
My configuration:
S3 i9300, asix USB-LAN adapter, kernel: boeffla 4.0-alpha-11-CM12.1, cm-12.1-20150825-UNOFFICIAL-i9300.zip
Hello, any progress on the ethernet connectivity? Would any of the M or N roms support this?
Try this:
Hi
Have you tried this (for Lollipop):
Code:
ndc resolver setnetdns eth0 "" 8.8.8.8 8.8.4.4
I had the same problem as you and this solved the problem on Galaxy Note 4 with 5.1.1 (was able to ping 8.8.8.8 and 8.8.4.4 but not google.com. after typing this in the terminal, the ping worked !)
However, I am stuck at a step further: Even with this, it seems all apps do not recognize the internet connection through ethernet (no problem with WiFi).
I am pretty sure that it's not a matter of ConnectivityHackService or Fake Wifi (that I have installed by the way), since I have the problem for all the apps I was able to check (many).
Does anyone know how to solve this ?

[GUIDE] Tethering through VPN over USB-OTG-ACA Ethernet /w IPv6 Support

This is a guide for tethering over USB Ethernet adapter. The purpose of this is to reliably USB tether to any router, without the need for a USB port or stable USB/RNDIS support(Broadcom MIPS is particularly bad). USB-OTG-ACA means the phone is powered externally while also operating in host mode. I used a cheap micro-USB Y-cable for this that lets me plug in a power source, USB Ethernet adapter, and phone together. IPv6 is supported via masquerading, so you share public IPs with your phone(thus hiding devices behind it). In this example I tether to a VPN tun0 interface, but you can tether to and from any interface you want.
This guide is targeted to more advanced users, but I included a E5 Play kernel and the files required at the bottom of this post for those who wouldn't be able to try this otherwise.
The first step is to enable the kernel IPv6 NAT table, with iptables and masquerading support. To do this I used LSM Kernel. My device is the E5 Play, steps for other devices are a little different.
https://forum.xda-developers.com/moto-e5/development/kernel-lowspecmoto-kernel-v0-1a-t3882378
These need to be set in james_defconfig. You can also enable any necessary kernel modules for your Ethernet adapter here.
Code:
CONFIG_NF_NAT_IPV6=y
CONFIG_IP6_NF_TARGET_MASQUERADE=y
CONFIG_IP6_NF_NAT=y
I had to disable the WireGuard install script and use jury_rig.sh instead, as well as fix a minor typo in the build script(misspelled and erroneous compile command) and one of the source files (extra const declaration).
The next step is to disable the IPv4 DHCP client for the Ethernet adapter's interface eth0. After a little reverse engineering, I found this state was controlled by /data/misc/ethernet/ipconfig.txt, and there is already a tool I can use to generate configurations.
https://github.com/jhswartz/ipconfigstore
I just feed it an empty static assignment and DHCP is then disabled.
Code:
ipAssignment: STATIC
id: 0
Next was to cross-compile radvd to support RA for IPv6. Modern versions of OpenWRT support spoofing so you don't need this, but everything else requires you run a RA server from the gateway device. I needed to use android-ifaddrs to get around an unsupported feature in the NDK. The version I built expects the config to exist at /sdcard/radvd.conf.
Now comes the scripting to make everything work. I made an application for this, but you can also accomplish this with something like Tasker or even run it manually.
At boot:
*Launch radvd as a root daemon
*Start your VPN
*Delete the file /sdcard/tether.state
*Execute tether.sh as root
On Intent.ACTION_POWER_CONNECTED:
*Execute tether.sh as root
tether.state keeps the script from applying NAT rules more than once, so the connection is just restored when the script is re-ran.
Code:
#!/system/bin/sh
echo 'Waiting for tether interfaces'
for waitTime in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
do
if [ -d '/sys/class/net/eth0' ] && [ -d '/sys/class/net/tun0' ] ; then break ; fi
echo "$waitTime"
sleep 1
done
sleep 2
if [ -d '/sys/class/net/eth0' ] && [ -d '/sys/class/net/tun0' ]
then
echo 'Preparing tether interface'
ip link set dev eth0 down
ip link set dev eth0 mtu 1280
sysctl -w net.ipv6.conf.eth0.mtu=1280
sysctl -w net.ipv6.conf.eth0.autoconf=0
sysctl -w net.ipv6.conf.eth0.accept_ra=0
ip addr flush dev eth0
echo 'Setting IP addresses'
ip -6 addr add fd00::1/64 dev eth0 scope global
ndc interface setcfg eth0 192.168.42.129 24 up
echo 'Waiting for interface to come up'
for waitTime in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
do
if [ "$(cat /sys/class/net/eth0/operstate)" = 'up' ] ; then break ; fi
echo "$waitTime"
sleep 1
done
sleep 3
ip -6 route add fd00::/64 dev eth0 src fd00::1
echo 'Enabling IP forwarding'
ndc ipfwd enable tethering
echo 'Adding marked routes'
ndc network interface add 99 eth0
ndc network route add 99 eth0 192.168.42.0/24
ndc network route add 99 eth0 fd00::/64
ndc network route add 99 eth0 fe80::/64
if [ ! -f '/sdcard/tether.state' ]
then
echo 'Setting up NAT'
touch /sdcard/tether.state
ndc nat enable eth0 tun0 99
ndc ipfwd add eth0 tun0
ip6tables -t nat -N natctrl_nat_POSTROUTING
ip6tables -t nat -A POSTROUTING -j natctrl_nat_POSTROUTING
ip6tables -t nat -A natctrl_nat_POSTROUTING -o tun0 -j MASQUERADE
ip6tables -t filter -A natctrl_FORWARD -i tun0 -o eth0 -m state --state RELATED,ESTABLISHED -g natctrl_tether_counters
ip6tables -t filter -A natctrl_FORWARD -i eth0 -o tun0 -m state --state INVALID -j DROP
ip6tables -t filter -A natctrl_FORWARD -i eth0 -o tun0 -g natctrl_tether_counters
ip6tables -t filter -A natctrl_FORWARD -j DROP
fi
else
echo 'Skipping operation, USB not connected'
fi
eth0 is the Ethernet adapter and tun0 is the VPN interface. I also use a very similar script to do the same thing with RNDIS, you can setup all kinds of interesting tethering setups with these commands. If you want to run DHCP on the phone for use with a switch or cross-over cable or whatever, this command should work as root:
Code:
dnsmasq --keep-in-foreground --no-resolv --no-poll --dhcp-authoritative --dhcp-range=192.168.42.10,192.168.42.99,1h --dhcp-option=6,8.8.8.8,8.8.4.4 --dhcp-option-force=43,ANDROID_METERED --dhcp-leasefile=/sdcard/dnsmasq.leases --pid-file=/sdcard/dnsmasq.pid --listen-mark 0xf0063
Since this is a powered tethering setup, you probably want to use something to control charging:
https://play.google.com/store/apps/details?id=com.slash.batterychargelimit&hl=en&gl=US
On the router, set it's IP to 192.168.42.1, gateway to 192.168.42.129, DNS servers, and DHCP range to 192.168.42.10-192.168.42.99. Disable IPv6 support if it has it. Don't plug anything into the WAN (yellow) port, the phone connects to LAN.
Moto E5 Play kernel with IPv6 NAT support
https://drive.google.com/file/d/15IDtuuOn60bgw5FHVnoacexe2fjzuHcg/view?usp=sharing
ipconfig.txt, radvd, radvd.conf, tether.sh
https://drive.google.com/file/d/18YL4rYyF9tFu34WI_wzBLNtiUDp9U7_a/view?usp=sharing
I wrote an app to manage this, but it still needs a bit of work to handle custom configurations.
fddm said:
This is a guide for tethering over USB Ethernet adapter. The purpose of this is to reliably USB tether to any router, without the need for a USB port or stable USB/RNDIS support(Broadcom MIPS is particularly bad). USB-OTG-ACA means the phone is powered externally while also operating in host mode. I used a cheap micro-USB Y-cable for this that lets me plug in a power source, USB Ethernet adapter, and phone together. IPv6 is supported via masquerading, so you share public IPs with your phone(thus hiding devices behind it). In this example I tether to a VPN tun0 interface, but you can tether to and from any interface you want.
This guide is targeted to more advanced users, but I included a E5 Play kernel and the files required at the bottom of this post for those who wouldn't be able to try this otherwise.
The first step is to enable the kernel IPv6 NAT table, with iptables and masquerading support. To do this I used LSM Kernel. My device is the E5 Play, steps for other devices are a little different.
https://forum.xda-developers.com/moto-e5/development/kernel-lowspecmoto-kernel-v0-1a-t3882378
These need to be set in james_defconfig. You can also enable any necessary kernel modules for your Ethernet adapter here.
Code:
CONFIG_NF_NAT_IPV6=y
CONFIG_IP6_NF_TARGET_MASQUERADE=y
CONFIG_IP6_NF_NAT=y
I had to disable the WireGuard install script and use jury_rig.sh instead, as well as fix a minor typo in the build script(misspelled and erroneous compile command) and one of the source files (extra const declaration).
The next step is to disable the IPv4 DHCP client for the Ethernet adapter's interface eth0. After a little reverse engineering, I found this state was controlled by /data/misc/ethernet/ipconfig.txt, and there is already a tool I can use to generate configurations.
https://github.com/jhswartz/ipconfigstore
I just feed it an empty static assignment and DHCP is then disabled.
Code:
ipAssignment: STATIC
id: 0
Next was to cross-compile radvd to support RA for IPv6. Modern versions of OpenWRT support spoofing so you don't need this, but everything else requires you run a RA server from the gateway device. I needed to use android-ifaddrs to get around an unsupported feature in the NDK. The version I built expects the config to exist at /sdcard/radvd.conf.
Now comes the scripting to make everything work. I made an application for this, but you can also accomplish this with something like Tasker or even run it manually.
At boot:
*Launch radvd as a root daemon
*Start your VPN
*Delete the file /sdcard/tether.state
*Execute tether.sh as root
On Intent.ACTION_POWER_CONNECTED:
*Execute tether.sh as root
tether.state keeps the script from applying NAT rules more than once, so the connection is just restored when the script is re-ran.
Code:
#!/system/bin/sh
echo 'Waiting for tether interfaces'
for waitTime in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
do
if [ -d '/sys/class/net/eth0' ] && [ -d '/sys/class/net/tun0' ] ; then break ; fi
echo "$waitTime"
sleep 1
done
sleep 2
if [ -d '/sys/class/net/eth0' ] && [ -d '/sys/class/net/tun0' ]
then
echo 'Preparing tether interface'
ip link set dev eth0 down
ip link set dev eth0 mtu 1280
sysctl -w net.ipv6.conf.eth0.mtu=1280
sysctl -w net.ipv6.conf.eth0.autoconf=0
sysctl -w net.ipv6.conf.eth0.accept_ra=0
ip addr flush dev eth0
echo 'Setting IP addresses'
ip -6 addr add fd00::1/64 dev eth0 scope global
ndc interface setcfg eth0 192.168.42.129 24 up
echo 'Waiting for interface to come up'
for waitTime in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
do
if [ "$(cat /sys/class/net/eth0/operstate)" = 'up' ] ; then break ; fi
echo "$waitTime"
sleep 1
done
sleep 3
ip -6 route add fd00::/64 dev eth0 src fd00::1
echo 'Enabling IP forwarding'
ndc ipfwd enable tethering
echo 'Adding marked routes'
ndc network interface add 99 eth0
ndc network route add 99 eth0 192.168.42.0/24
ndc network route add 99 eth0 fd00::/64
ndc network route add 99 eth0 fe80::/64
if [ ! -f '/sdcard/tether.state' ]
then
echo 'Setting up NAT'
touch /sdcard/tether.state
ndc nat enable eth0 tun0 99
ndc ipfwd add eth0 tun0
ip6tables -t nat -N natctrl_nat_POSTROUTING
ip6tables -t nat -A POSTROUTING -j natctrl_nat_POSTROUTING
ip6tables -t nat -A natctrl_nat_POSTROUTING -o tun0 -j MASQUERADE
ip6tables -t filter -A natctrl_FORWARD -i tun0 -o eth0 -m state --state RELATED,ESTABLISHED -g natctrl_tether_counters
ip6tables -t filter -A natctrl_FORWARD -i eth0 -o tun0 -m state --state INVALID -j DROP
ip6tables -t filter -A natctrl_FORWARD -i eth0 -o tun0 -g natctrl_tether_counters
ip6tables -t filter -A natctrl_FORWARD -j DROP
fi
else
echo 'Skipping operation, USB not connected'
fi
eth0 is the Ethernet adapter and tun0 is the VPN interface. I also use a very similar script to do the same thing with RNDIS, you can setup all kinds of interesting tethering setups with these commands. If you want to run DHCP on the phone for use with a switch or cross-over cable or whatever, this command should work as root:
Code:
dnsmasq --keep-in-foreground --no-resolv --no-poll --dhcp-authoritative --dhcp-range=192.168.42.10,192.168.42.99,1h --dhcp-option=6,8.8.8.8,8.8.4.4 --dhcp-option-force=43,ANDROID_METERED --dhcp-leasefile=/sdcard/dnsmasq.leases --pid-file=/sdcard/dnsmasq.pid --listen-mark 0xf0063
Since this is a powered tethering setup, you probably want to use something to control charging:
https://play.google.com/store/apps/details?id=com.slash.batterychargelimit&hl=en&gl=US
On the router, set it's IP to 192.168.42.1, gateway to 192.168.42.129, DNS servers, and DHCP range to 192.168.42.10-192.168.42.99. Disable IPv6 support if it has it. Don't plug anything into the WAN (yellow) port, the phone connects to LAN.
Moto E5 Play kernel with IPv6 NAT support
https://drive.google.com/file/d/15IDtuuOn60bgw5FHVnoacexe2fjzuHcg/view?usp=sharing
ipconfig.txt, radvd, radvd.conf, tether.sh
https://drive.google.com/file/d/18YL4rYyF9tFu34WI_wzBLNtiUDp9U7_a/view?usp=sharing
I wrote an app to manage this, but it still needs a bit of work to handle custom configurations.
Click to expand...
Click to collapse
For those who don't have a kernel with the network modules you've mentioned, but want to get ipv6 working (thinking of Tmobile) and have access to openwrt router, would adding the mentioned ip6tables command work?
In my router, I added something like this,
ip6tables -t mangle -I POSTROUTING -o usb0 -j HL --hl-set 65
but ipv6 connection didn't work. If I remove that line from the router firewall, then ipv6 connection works but it counts as tethered.
aznxwill said:
For those who don't have a kernel with the network modules you've mentioned, but want to get ipv6 working (thinking of Tmobile) and have access to openwrt router, would adding the mentioned ip6tables command work?
In my router, I added something like this,
ip6tables -t mangle -I POSTROUTING -o usb0 -j HL --hl-set 65
but ipv6 connection didn't work. If I remove that line from the router firewall, then ipv6 connection works but it counts as tethered.
Click to expand...
Click to collapse
One option is to use your phone's native tether and set up IPv6 nat on your router. This will make your iptables rule work and only requires provisioning and dun bypasses on the phone. The downside is your tethered traffic will go through a separate IPv6 address from your phone, so it's more risky.
The other option is to proxy, but getting UDP support is a real hurdle. Ideas are porting Shadowsocks or one of those Socks5 proxies written in Go. Adding UDP support to microsocks is also possible, but way more work. You'd use the Shadowsocks client or transocks-wong on the router to serve clients with no knowledge of the proxy.
Edit: also, what phone/rom/router are you working with?
fddm said:
One option is to use your phone's native tether and set up IPv6 nat on your router. This will make your iptables rule work and only requires provisioning and dun bypasses on the phone. The downside is your tethered traffic will go through a separate IPv6 address from your phone, so it's more risky.
The other option is to proxy, but getting UDP support is a real hurdle. Ideas are porting Shadowsocks or one of those Socks5 proxies written in Go. Adding UDP support to microsocks is also possible, but way more work. You'd use the Shadowsocks client or transocks-wong on the router to serve clients with no knowledge of the proxy.
Edit: also, what phone/rom/router are you working with?
Click to expand...
Click to collapse
I'm working with OnePlus 8 (phone) + GL.iNET MT-1300 (router) on TMO network.
I am able to get USB tethering to work with the router for IPv4. My setup is as follows:
Phone (USB) <---> MT-1300 (router) <---> clients (PC/phones/TVs)
For IPv4, I added the following line to router firewall:
iptables -t mangle -I POSTROUTING -o usb0 -j TTL --ttl-set 65
Click to expand...
Click to collapse
Currently trying to figure out IPv6...
This is the guide to enable nat6 on openwrt:
NAT66 and IPv6 masquerading
NAT66 and IPv6 masquerading This article relies on the following: * Accessing web interface / command-line interface * Managing configs / packages / services / logs Introduction * This how-to describes the method for setting up NAT66 aka NAT6 with IPv6 masquerading on your OpenWrt...
openwrt.org
Make sure usb0 is bridged to wan, not lan. Then your iptables rule will work.

Categories

Resources