sharing mobile data through usb tethering
#1
Hello,

I am able to connect to the pinephone through USB from my laptop, but then I have no internet connexion
from my laptop.

The mobile data on the pinephone is enabled. Within a ssh session I can ping google as an example.

What am i missing ?

Also, I noticed that my FAI is only giving me an ipv6 address :

Code:
wwan0: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST>  mtu 1500
        inet6 2a04:cec0:10c8:f8e:5c88:c307:fa17:d9e2  prefixlen 64  scopeid 0x0<global>
        unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  txqueuelen 1000  (UNSPEC)
        RX packets 257  bytes 35979 (35.1 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 274  bytes 27084 (26.4 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
  Reply
#2
Some carriers control/or block tethering
      LINUX = CHOICES
         **BCnAZ**
               Idea
   Donate to $upport
your favorite OS Team
  Reply
#3
A script to try
Code:
#!/bin/bash
# Share the  internet connection from wwan0 through usb0

case "$1" in
    start)
ip link set usb0 up
ip a add 192.168.99.1/24 dev usb0
iptables --table nat --append POSTROUTING --out-interface wwan0 -j MASQUERADE
iptables --append FORWARD --in-interface usb0 -j ACCEPT
echo 1 > /proc/sys/net/ipv4/ip_forward
echo "Set your PC's networking to"
echo "192.168.99.0/24"
echo "gateway 192.168.99.1"
echo "dns 192.168.99.1"   
;;
    stop)
echo 0 > /proc/sys/net/ipv4/ip_forward
ip link set usb0 down
iptables --table nat --delete POSTROUTING --out-interface wwan0 -j MASQUERADE
;;
    *)
echo "To start or stop sharing script usage: $0 {start|stop}"
;;
esac


Might need little changes. Easy to turn into touch friendly yad gui. Easy script to gui examples https://puri.sm/posts/easy-librem-5-app-...creenshot/ && https://puri.sm/posts/easy-librem-5-app-...he-screen/ Please improve and share.
  Reply
#4
Thanks for yous answeer.

I will try the script you provided, but I doubt it will work because the forward iptable rules operates on the ipv4 stack
whereas my wwan interface has only a ipv6 address. I do not think they can communicate, as far as I understand.
  Reply
#5
(02-10-2022, 09:39 AM)deb75 Wrote: Thanks for yous answeer.

I will try the script you provided, but I doubt it will work because the forward iptable rules operates on the ipv4 stack
whereas my wwan interface has only a ipv6 address. I do not think they can communicate, as far as I understand.

Did the  script work? ipv6  wwan address should not be of concern.
  Reply
#6
(02-25-2022, 12:57 AM)vusra Wrote:
(02-10-2022, 09:39 AM)deb75 Wrote: Thanks for yous answeer.

I will try the script you provided, but I doubt it will work because the forward iptable rules operates on the ipv4 stack
whereas my wwan interface has only a ipv6 address. I do not think they can communicate, as far as I understand.

Did the  script work? ipv6  wwan address should not be of concern.

Hi,

Yes it worked.

I endded up by performing an ipv6 nat :

Code:
#!/bin/sh
PATH='/sbin'

if [ "x$1" != "xusb0"] || [ "x$2" != "xup" ];
then
    return 0
fi

sysctl -w net.ipv6.conf.usb0.accept_ra=2
sysctl -w net.ipv6.conf.usb0.autoconf=1

# Allow all incoming traffic from local area network interface.
ip6tables -t filter -A INPUT -i usb0 -m conntrack --ctstate NEW -j ACCEPT

# Enable access traffic, from the firewall to the LAN network
ip6tables -t filter -A OUTPUT -o usb0 -m conntrack --ctstate NEW -j ACCEPT

# Forward packages from the internal network (usb0) to the internet (wwan0).
ip6tables -t filter -A FORWARD -i usb0 -o wwan0 -m conntrack --ctstate NEW -j ACCEPT

# Masquerade packets going into the internet (wwan0).
ip6tables -t nat -A POSTROUTING -o wwan0 -j MASQUERADE

# Allow ssh from usb0
ip6tables -t filter -A INPUT -i usb0 -p tcp --dport 22 -m conntrack --ctstate NEW -j ACCEPT

Also, I set up radvd : (/etc/radvd.conf)

Code:
interface usb0 {
        AdvSendAdvert on;
        MinRtrAdvInterval 3;
        MaxRtrAdvInterval 10;
        prefix fd00:2016:22:dec::/64 {
                AdvOnLink on;
                AdvAutonomous on;
                AdvRouterAddr on;
        };
};

The prefix above is the ULA (Unique Local Address) ipv6 of the usb0 interface.

There should be a better way as one of the ipv6 goal is to eliminate the need of network address translation (nat).
  Reply
#7
ipv6 is a privacy  calamity. Avoid it while you can.   Create a  .conf file in /etc/NetworkManager/conf.d/   comprising  of
Code:
[connection]
ipv6.ip6-privacy=2
 
to pseudo randomize your ipv6 mac.  Our community  should  create a list of   mobian configuration changes to improve privacy.
  Reply
#8
I haven't done it on the Pinephone yet, but on all my other Linux systems I've disabled IPv6 in the kernel. In /etc/default/grub you should find a line similar to the following though it may have other options:

Code:
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"

Add ipv6.disable=1 to that line:

Code:
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash ipv6.disable=1"

Run sudo update-grub, reboot, and no more IPv6. I have not found a need for IPv6 to be active on my router or any of my desktop or laptop computers but don't know if it would affect cellular data on the phone. (I don't use cellular data so that doesn't affect me.)
  Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Amberol Mobile Music player(flatpak) biketool 0 57 06-19-2022, 07:16 AM
Last Post: biketool
  DNS Problems with Mobile Data arno_nuehm 27 4,107 05-16-2022, 04:14 PM
Last Post: henrythemouse
  Cellular data is working! drh 0 154 05-15-2022, 09:02 AM
Last Post: drh
  Mobile internet via cellular network mostly not working Anna 17 2,250 02-28-2022, 02:51 PM
Last Post: TRS-80
  Reskinning Apps for Mobile biketool 6 761 12-05-2021, 02:30 PM
Last Post: biketool
  Mobile network mode setting not saved Zebulon Walton 3 1,313 12-05-2021, 12:12 AM
Last Post: bcnaz
  gnome podcasts on debian repo, dino-mobile user641 3 1,419 09-11-2021, 12:04 AM
Last Post: user641
  mobile data on mobian not working synaption 10 3,165 08-29-2021, 07:22 AM
Last Post: bcnaz
  need my usb tethering back HLing 12 4,114 08-02-2021, 10:13 AM
Last Post: biketool
  Pinephone in Canada using Shaw mobile provider RRman 0 766 06-19-2021, 06:35 PM
Last Post: RRman

Forum Jump:


Users browsing this thread: 1 Guest(s)