Until a better solution is put together by Purism, you can share your internet connection (4G or ethernet) via the WiFi hotspot of the Librem 5, here is how I do it:
==> This post is now obsolete <==
==> WiFi hotspot now completely works on Byzantium <==
If your 3G or 4G or ethernet connection is working on your L5- Go to ‘Settings’ > ‘Wi-Fi’
- Hit the 3 dot button on the top right corner
- ‘Turn On Wi-Fi hotspot’
- Choose name and password
- Hit the ‘Turn On’ button
That’s it, nothing more to do
Make sure:
- if 3G/4G, ‘Mobile data’ must be ON, in Mobile settings
- no orange exclamation mark is shown in the signal icon
- no icon with 2 arrows and a cross, signaling the L5 is not connected to network
==> The following is now obsolete <==
==> The following is now obsolete <==
First activate your hotspot
Obsolete - Forwarding - The manual way
You have to get the network address of your hotspot withip r
You should have a line with dev wlan0 (if your hotspot use wlan0)
10.42.0.0/24 dev wlan0 proto kernel scope link src 10.42.0.1 metric 600
To activate the forwarding, with the wlan0 IP (here 10.42.0.0/24) :
sudo sysctl net.ipv4.ip_forward=1
sudo iptables-legacy -t nat -A POSTROUTING -s 10.42.0.0/24 ! -d 10.42.0.0/24 -j MASQUERADE
To disable:
sudo sysctl net.ipv4.ip_forward=0
sudo iptables-legacy -t nat -D POSTROUTING 1
The 1 after POSTROUTING corresponds to the rule number which can be listed with
sudo iptables-legacy -n -t nat --list --line-numbers | grep MASQUERADE
1 MASQUERADE all – 10.42.0.0/24 !10.42.0.0/24
Obsolete - Forwarding - The semi-automatic scripted way
I made a script to activate or deactivate the IPv4 forwarding from the WAN to the WIFI when hotspot is activatedBE AWARE the script is not perfect, it badly handles the MASQUERADE rules if you have already configured one, consider it an simple ease-of-use until the good solution is available
Create a file in /home/purism/ named hotspot_bridge.sh containing the following code
#!/bin/bash ERROR="\e[31mError\e[0m:" # Default interface for Wifi hotspot dev_net_wifi=wlan0 # Check if activating or deactivating verif=$(sudo iptables-legacy -n -t nat --list | grep MASQUERADE) if [ "${verif}" != "" ] ; then # MASCARADE rule present, deactivate forwarding sudo sysctl net.ipv4.ip_forward=0 sudo iptables-legacy -t nat -D POSTROUTING 1 [ -e /usr/share/applications/hotspot_bridge.desktop ] && sudo sed -i 's/network-wireless-signal-excellent-symbolic.svg/network-wireless-disabled-symbolic.svg/' /usr/share/applications/hotspot_bridge.desktop exit 0 fi # MASCARADE rule not present, try to activate forwarding # Checking the icon if [ -e /usr/share/applications/hotspot_bridge.desktop ] ; then # Wrong icon, putting the right one verif=$(grep network-wireless-signal-excellent-symbolic.svg /usr/share/applications/hotspot_bridge.desktop) [ "${verif}" != "" ] && sudo sed -i 's/network-wireless-signal-excellent-symbolic.svg/network-wireless-disabled-symbolic.svg/' /usr/share/applications/hotspot_bridge.desktop fi # Check if WiFi interface is available verif=$(ip link | grep "${dev_net_wifi}") if [ "${verif}" == "" ] ; then echo -e "$ERROR Network interface '${dev_net_wifi}' not found" # Searching for an other wlan (taking first one) dev_net_wifi=$(echo -e "${list_interface}" | grep -m1 wlan | awk '{ print $1 }') [ "${dev_net_wifi}" == "" ] && echo -e "$ERROR No wlan interface found" && exit 1 echo "=> WLAN interface found : ${dev_net_wifi}" fi # Searching available route verif=$(ip r | grep ^default) [ "${verif}" == "" ] && echo -e "$ERROR No default route found on network interfaces" && exit 1 # Getting IP of WiFi hotspot ip_wifi=$(ip r | grep -v ^default | grep -m1 "${dev_net_wifi}" | awk '{ print $1 }') [ "${ip_wifi}" == "" ] && echo -e "$ERROR Could not determine WiFi IP for interface ${dev_net_wifi}" && exit 1 # Activating the forwarding sudo sysctl net.ipv4.ip_forward=1 [ $? -ne 0 ] && echo -e "$ERROR Unable to activate forwarding" && exit 1 sudo iptables-legacy -t nat -A POSTROUTING -s "${ip_wifi}" ! -d "${ip_wifi}" -j MASQUERADE if [ $? -ne 0 ] ; then sudo sysctl net.ipv4.ip_forward=0 echo -e "$ERROR Unable to add POSTROUTING iptables rule" exit 1 fi [ -e /usr/share/applications/hotspot_bridge.desktop ] && sudo sed -i 's/network-wireless-disabled-symbolic.svg/network-wireless-signal-excellent-symbolic.svg/' /usr/share/applications/hotspot_bridge.desktop exit 0
After copy/paste and save, add the execute rights:
chmod +x hotspot_bridge.sh
First execution will activate the forwarding between interfaces
Second execution will deactivate the forwarding
If you want to confirm in what state you are, you can execute the following command, 1 = on, 0 = off
cat /proc/sys/net/ipv4/ip_forward
Icon shortcut
You can also create the following shortcut /usr/share/applications/hotspot_bridge.desktop using the script, it will add a Wifi icon called “Hotspot bridge”
[Desktop Entry] Type=Application Name=Hotspot bridge GenericName=Hotspot bridge Comment=Enable or disable bridge beteween network interface and hotspot Icon=/usr/share/icons/Adwaita/scalable/status/network-wireless-disabled-symbolic.svg Exec=/home/purism/hotspot_bridge.sh Terminal=true Categories=network; Keywords=bridge;network;hotspot;wifi;
First tap will activate the forwarding between interfaces and the icon will change to an active WiFi picture
Second tap will deactivate the forwarding and the icon will change to a deactivated WiFi picture
I tried it with success when the Librem5 is connected with 4G or is connected with an ethernet cable
My laptop connected to the Librem 5 hotspot add access to Internet, nothing special to do on it
Let me know if it worked for you, or not
Or if you see some improvements to make !
Obsolete - Forwarding - The full-automatic scripted way
Here, an other solution from Loki, where the forwarding is triggered when hotspot is activated