netplan - add a mobile hotspot connect

I am using the following netplan config to connect to my home wifi:

network: version: 2 renderer: networkd wifis: wlp3s0: dhcp4: yes dhcp6: no access-points: "HOME-WIFI-01": password: "mysupersecretwifikey"

How do I now add the option to connect to my mobile phone hotspot? Would I have to create another netplan .yaml file, or would I be able to add something in the wifis: section of the above file?

Just to be clear, I'm not using NetworkManager, and I want to add a netplan for my mobile phone hotspot (so that when I'm on the road, I can connect my laptop to the Internet via my mobile phone's hotspot).

2 Answers

The config files I'm using are completely arbitrary and can be named whatever. Make a new file for your phone like this: Copy and paste into a file and name it phoneHotSpot.yaml

network: version: 2 renderer: networkd wifis: wlp3s0: dhcp4: yes dhcp6: no access-points: "<yourPhonesSSID>": password: "yourphonesridiculouslylongbutratherambigiouslysecurepassword"

make a NEW directory to store config files describing each connection profile. This way the file directory will act as a menu of options to pick from which can be copied to the folder netplan configures from.

 # cd /etc/netplan # mkdir -p lib

then keep a different .yaml file for each connection you want the system to control for you. organize these however you wish and just make profiles that apply to you.

 /etc/netplan/lib/homeWiFi.yaml /etc/netplan/lib/workwifi.yaml /etc/netplan/lib/PhoneHotSpot.yaml /etc/netplan/lib/ethernet.yaml /etc/netplan/lib/homewifiasaccesspoint.yaml

and keep just the "active" ones in your /etc/netplan folder

 /etc/netplan/<--active .yaml files here

Copy the following into your .bash_aliases file and you can switch back and forth with a single command. You will have to do this for each user who logs into shell (converting this into a standalone command is beyond my scope here)

Want to connect to the phone? From the command, type # connecthomeBack on home wifi? Type # connectphone

connecthome() { # --> overwrite the existing configuration with homeWiFi.yaml sudo cp /etc/netplan/lib/homeWiFi.yaml /etc/netplan/netplan.yaml # --> alert your system to the changes sudo netplan generate sudo netplan apply } connectphone() { # --> overwrite the existing configuration with phoneHotSpot.yaml sudo cp /etc/netplan/lib/phoneHotSpot.yaml /etc/netplan/netplan.yaml # --> update your system to the changes sudo netplan generate sudo netplan apply }

It is possible to add information about multiple APs under the access-points: key for a given interface. Because you are not using NetworkManager, the ability to manage selection of the AP used at runtime will be limited. If you need roaming wireless support, NetworkManager is the recommended backend for these interfaces.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like