USB Tethering: Difference between revisions
No edit summary |
|||
Line 27: | Line 27: | ||
= Manually = | = Manually = | ||
If you don't use SXMO, you should follow the following instructions. | If you don't use SXMO or GNOME, you should follow the following instructions. | ||
To make USB Tethering to work, you'll have to repeat these instructions every time your system reboots. | To make USB Tethering to work, you'll have to repeat these instructions every time your system reboots. | ||
Revision as of 19:18, 13 February 2023
This is a guide for using the mobile data or wifi of a postmarketOS device through USB on your host device. For the inverse see the USB Internet page if you need to use the USB connection to get internet from your host into the postmarketOS device.
Automatically (SXMO)
Open menu "Networks", select menu "Add a USB Hotspot", you'll be prompt to set a profile name (e.g. USB Tethering).
Activate the newly created interface (i.e. )USB Tethering by selecting it.
Your computer should receive internet traffic from your postmarketOS device automatically.
Automatically (GNOME)
1. Connect your phone over USB to your desktop.
2. On the phone, open Settings
3. Go to the Network panel tab.
4. You should see 1 wired connection at the top, tab the edit settings button (gear).
5. An old panel opens which doesn't fit your screen (use Phosh Mobile Settings to enable scale-to-fit for this panel only, it will be shown in the list of active apps).
6. Go to the IPv4 tab.
7. Select 'Shared to other computers' and tab the Apply button in the right corner.
Manually
If you don't use SXMO or GNOME, you should follow the following instructions. To make USB Tethering to work, you'll have to repeat these instructions every time your system reboots.
On the postmarketOS device
On the postmarketOS device side the firewall needs to be configured to perform NAT between the USB interface and it's default gateway. The default gateway can be either the WiFi or the modem in the device.
First enable ip forwarding between the interfaces:
# sysctl net.ipv4.ip_forward=1
Then adjust the firewall configuration to NAT between the USB interface and the other interfaces
# nft add table inet nat
# nft 'add chain inet nat postrouting { type nat hook postrouting priority 100 ; }'
# nft add rule inet nat postrouting iifname "usb*" masquerade
The default nftables configuration in postmarketOS already has the other rules setup to make USB tethering work.
On the host side
Plug the postmarketOS device into your PC or laptop and run a DHCP client against the USB interface that shows up. It's also possible to use a static IP configuration.
address 172.16.42.2
netmask 255.255.255.0
gateway 172.16.42.1
If your host has automatically done DHCP on the USB interfaces, as is common on most Linux distributions. The only thing required is setting the default gateway to the USB interface since the DHCP server on the postmarketOS device does not set the default gateway.
remove the existing default route if you have one
# ip route del default
Add a default route through the postmarketOS device
# ip route add default via 172.16.42.1
See also
- pmaports!3819 USB tethering support