meta data for this page
  •  

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
howto:networking [2021/02/22 13:00]
spaetz
howto:networking [2021/05/03 14:53] (current)
spaetz
Line 1: Line 1:
-===== Networking HowTos =====+~~NOTOC~~{{METATOC 2-5}} 
 +====== Networking HowTos ​======
  
-=== Configure ​Mobile Data ===+===== Using Mobile Data =====
  
 If your correct provider settings do not show up in Settings >> Mobile >> Mobile Data >> Access Points, you can add a new one with the [+] button. If your correct provider settings do not show up in Settings >> Mobile >> Mobile Data >> Access Points, you can add a new one with the [+] button.
-Add a network name and your APN, e.g. Name: //3 internet// ​ APN: //​three.co.uk//​. The correct settings depend on your provider.+Add a network name and your APN, e.g. Name: //3 internet// ​ APN: //​three.co.uk//​. The correct settings depend on your provider. If mobile data does not work, make sure that the "​mobile data" toggle is turned on (this happens more often than you would think).
  
-==== Connection sharing/​Tethering ​====+===== Connecting to the Mobian device =====
  
-=== Sharing mobile data through wifi hotspot ​===+==== Connect to a running SSH server ====
  
-Run and create new hotspot connections with SSID `Pinephone` and Password `HotspotPassword`:​ +This section explains how to connect to your Mobian ​device ​using a ssh server that you have installed on it. You should [[howto:​security#​using-ssh-with-a-key-instead-of-password|protect]] ​your ssh server to not allow logins via the numeric password if you want to remain safe. 
-   +
-  sudo nmcli device ​wifi hotspot ifname wlan0 con-name Hotspot ssid Pinephone  ​password ​HotspotPassword +
-   +
-Stop the hotspot from NetworkManager. To restart ​your hotspot you can use the 3 dots menu "​Connect ​to hidden network"​+
  
-{{:​hotspot2.png?​direct&​200|}} {{:​hotspot3.png?​direct&​200|}} {{:​hotspot4.png?​direct&​200|}} {{:​hotspot1.png?​direct&​200|}}+=== via Wifi ====
  
 +If your pinephone is connected to your local Wifi and you have an SSH server running, try to access it with `ssh mobian@mobian`. If that does not work out (e.g. because your network assigned the device a different hostname, you will need to find out the hostname/IP address to connect to.
  
-=== Sharing internet from your PC via USB ===+=== via USB-C cable connected to another computer ​===
  
-Set up ip-forwarding on your PC and configure your USB ethernet ​device'​s ​IP:+It's possible to connect to Mobian with a similar end result as using ''​adb shell''​ with an Android device, but using the USB-C connection ​and SSH instead. When connecting a Mobian ​device ​to a Linux computer via the USB-C connection, a network interface is made available to the computer, and utilizing udev and NetworkManager an IP address is assigned to both. This allows connecting to Mobian via a hardwired SSH session, instead of having to rely on wifi (which may not be 100% reliable). These instructions are written with the PinePhone as the sample device, and Linux Mint as the host computer OS, but should work for other devices/​OSes as well.
  
-  ​echo 1 | sudo tee /​proc/​sys/​net/​ipv4/​ip_forward +  - Connect the PinePhone to the computer with a USB-C cable. 
-  sudo iptables ​-A POSTROUTING ​-t nat  -10.0.0.0/24 -j MASQUERADE +  ​- ​Once connected, the system should create a network interface via NetworkManager. Learn the IP by issueing `sudo ip address show dev usb0` and looking for the IP address in the range of 10.66.0.XX (or install the graphical WhatIP tool). ​ 
-  ​sudo iptables ​-P FORWARD ACCEPT +  - A connected Linux Desktop will automatically create a USB network connection. 
-  ​sudo ip addr add dev $USB_INTERFACE ​10.0.0.1/24+  ​- Once complete, it should be possible to SSH into Mobian at the IP address ​10.66.0.XX using the username ''​mobian'',​ and the password ''​1234'':​ 
 +    * <​code>​ssh mobian@10.66.0.1</code>
  
-where you should replace ''​$USB_INTERFACE''​ by the name of your interface (e.g ''​enp7s0u1c2''​ or ''​usb0''​) +== Network overlap with 10.0.0.0/8 ==
- +
-You might need to set the correct DNS server in ''/​etc/​resolv.conf'':​ +
-  search $LOCAL_DOMAIN +
-  nameserver $LOCAL_DNS_IP +
- +
-where you should replace ''​$LOCAL_DOMAIN''​ by your local domain (e.g ''​local''​) +
-and ''​$LOCAL_DNS_IP''​ by a valid DNS server (e.g ''​192.168.1.1''​ or ''​9.9.9.9''​) +
- +
-===== Firewall ===== +
- +
-By default, Mobian has no listening services on any internet port and a firewall is not necessary. However when you install services, such as openssh, web servers and whatever, you might want to lock down your device using a firewall. +
- +
-Mobian can use any firewall that is supported by Debian. Debian is currently introducing nftables and fades out iptables, but the latter still works (using nftables under the hood). One easy to use firewall is the uncomplicated firewall (UFW). It can be installed with ''​sudo apt install ufw''​ and can be enabled on a terminal with ''​sudo ufw enable''​. Be careful though, when doing this over a SSH connection, you will lock yourself out :). +
-On my Mobian I got an error message ''​ip6tables-restore v1.8.7 (nf_tables):​ Couldn'​t load match `rt':​No such file or directory''​ but the firewall still worked (verified by ''​sudo ufw status''​ and ''​sudo ufw status verbose''​) +
- +
-Other useful commands are "ufw allow ssh" (check /​etc/​ufw/​applications.d/​ which applications are possible) or manually allow ports. +
- +
-If you prefer graphical apps, the package gufw allows to configure the firewall via a graphical application. +
- +
-===== Network overlap with 10.0.0.0/​8 ​====+
  
 When connecting a Mobian device to a computer via USB-C, Mobian is configured to use the IP address 10.66.0.1, in the subnet 10.0.0.0/8. This can cause an issue if Mobian is also connected to a wifi network which utilizes a subnet within the same 10.0.0.0/8 subnet. The configuration of the USB connection //could// be changed to use a different or smaller subnet, //or// a more specific route can be configured for the wifi connection to account for this special case. Here is how to add a persistent more specific route. When connecting a Mobian device to a computer via USB-C, Mobian is configured to use the IP address 10.66.0.1, in the subnet 10.0.0.0/8. This can cause an issue if Mobian is also connected to a wifi network which utilizes a subnet within the same 10.0.0.0/8 subnet. The configuration of the USB connection //could// be changed to use a different or smaller subnet, //or// a more specific route can be configured for the wifi connection to account for this special case. Here is how to add a persistent more specific route.
Line 73: Line 52:
 10.45.89.128/​25 via 192.168.0.1 dev wlan0 proto static metric 25  10.45.89.128/​25 via 192.168.0.1 dev wlan0 proto static metric 25 
 192.168.0.0/​24 dev wlan0 proto kernel scope link src 192.168.0.101 metric 25</​code>​ 192.168.0.0/​24 dev wlan0 proto kernel scope link src 192.168.0.101 metric 25</​code>​
 +
 +===== Connection sharing/​Tethering =====
 +
 +It is possible to share your phone'​s mobile data with another device. Either create a wifi hotspot that others connect to, or use a USB cable to forward data.
 +
 +==== Sharing mobile data through wifi hotspot ====
 +
 +Visit the settings -> Wifi. The "3 dot" menu will offer a "​Create WiFi Hotspot..."​ entry, which is all that you should need to create a hotspot. Unfortunately in gnome-control-center 3.36, there is still [[https://​gitlab.gnome.org/​GNOME/​gnome-control-center/​-/​issues/​965|a bug]] which requires you to go back to the bluetooth page (just enter it and leave it immediately again) and back to the Wifi section until it becomes enabled.
 +  ​
 +Stop the hotspot from the Wifi page in the settings app.
 +{{:​hotspot_screen.png?​direct&​300|}}
 +
 +== Hotspot: The geeky way ==
 +The geeky way to use the terminal to create a new hotspot connection with SSID `Pinephone` and Password `HotspotPassword` is:
 +  ​
 +  sudo nmcli device wifi hotspot ifname wlan0 con-name Hotspot ssid Pinephone ​ password HotspotPassword
 +
 +
 +==== Sharing internet from your PC via USB ====
 +
 +Set up ip-forwarding on your PC and configure your USB ethernet device'​s IP:
 +
 +  echo 1 | sudo tee /​proc/​sys/​net/​ipv4/​ip_forward
 +  sudo iptables -A POSTROUTING -t nat  -s 10.0.0.0/24 -j MASQUERADE
 +  sudo iptables -P FORWARD ACCEPT
 +  sudo ip addr add dev $USB_INTERFACE 10.0.0.1/24
 +
 +where you should replace ''​$USB_INTERFACE''​ by the name of your interface (e.g ''​enp7s0u1c2''​ or ''​usb0''​)
 +
 +You might need to set the correct DNS server in ''/​etc/​resolv.conf'':​
 +  search $LOCAL_DOMAIN
 +  nameserver $LOCAL_DNS_IP
 +
 +where you should replace ''​$LOCAL_DOMAIN''​ by your local domain (e.g ''​local''​)
 +and ''​$LOCAL_DNS_IP''​ by a valid DNS server (e.g ''​192.168.1.1''​ or ''​9.9.9.9''​)
 +
 +===== Firewall =====
 +
 +By default, Mobian has no listening services on any internet port and a firewall is not necessary. However when you install services, such as openssh, web servers and whatever, you might want to lock down your device using a firewall.
 +
 +Mobian can use any firewall that is supported by Debian. Debian is currently introducing nftables and fades out iptables, but the latter still works (using nftables under the hood). One easy to use firewall is the uncomplicated firewall (UFW). It can be installed with ''​sudo apt install ufw''​ and can be enabled on a terminal with ''​sudo ufw enable''​. Be careful though, when doing this over a SSH connection, you will lock yourself out :).
 +
 +On my Mobian I got an error message ''​ip6tables-restore v1.8.7 (nf_tables):​ Couldn'​t load match `rt':​No such file or directory'',​ which is most likely due to the not included kernel module (CONFIG_NFT_RT) but the firewall still worked fine.
 +
 +Useful status output can be gathered by ''​sudo ufw status''​ and ''​sudo ufw status verbose''​. Other useful commands are "ufw allow ssh" (check /​etc/​ufw/​applications.d/​ which applications are possible) or manually allow ports.
 +
 +NOTE: If you prefer graphical apps, the package gufw allows to configure the firewall via a graphical application. However, it requires to have the "​x11-xserver-utils"​ package installed (or [[https://​bugs.debian.org/​cgi-bin/​bugreport.cgi?​bug=864603|it will crash]]), as it makes use of the "​xhost"​ program in order to allow root to display any application on the screen.
  
 ===== VPN ===== ===== VPN =====
Line 85: Line 111:
  
 Note: If there are still problems, it has been [[https://​gitlab.com/​mobian1/​issues/​-/​issues/​60|reported]] that the IPv6 configuration in wireguard can cause trouble and needs to be removed (see same issue linked to earlier). (//Please update if this changes//) Note: If there are still problems, it has been [[https://​gitlab.com/​mobian1/​issues/​-/​issues/​60|reported]] that the IPv6 configuration in wireguard can cause trouble and needs to be removed (see same issue linked to earlier). (//Please update if this changes//)
 +
 +== Alternative Wireguard method ==
 +
 +If for some reason the method above, involving network-manager,​ appears to complex and/or doesnt work, one can install Wireguard and have it always-on using a non-network-manager method:
 +
 +
 +1/ generate a pair of keys using wg genkey, and create a /​etc/​wireguard/​wg0.conf (with umask 077 in the folder)
 +
 +<​code>​
 +[Interface] ​
 +PrivateKey = xxxx (private_key)
 +[Peer]
 +PublicKey = yyyy (public_key)
 +EndPoint = x.y.z.a:​port
 +AllowedIPs = 0.0.0.0/0
 +</​code>​
 +
 +2/ using systemd, activate the interface using
 +<​code>​
 +sudo systemctl enable wg-quick@wg0
 +</​code>​
 +
 +Should work for routing all communications from interfaces configured through network-manager
  
 == Always-On VPN == == Always-On VPN ==
  
-VPN functionality will be added to Gnome-Control-Center in the future, but for now you can configure this via ''​nmcli''​. This guide will explain how to import an OpenVPN connection, and then configure other connections to require it as a "​secondary"​.+VPN functionality will be added to Gnome-Control-Center in the future, but for now you can configure this via ''​nmcli''​. This guide will explain how to import an OpenVPN connection, and then configure other connections to require it as a "​secondary"​. ​(see the always great Arch wiki for [[https://​wiki.archlinux.org/​index.php/​NetworkManager#​Automatically_connect_to_VPN|more]] on this)
  
 1. Add OpenVPN support for NetworkManager by running ''​sudo apt install network-manager-openvpn''​. 1. Add OpenVPN support for NetworkManager by running ''​sudo apt install network-manager-openvpn''​.