sudo apt install ssh -y
sudo systemctl enable ssh
sudo systemctl start sshThis wasn't needed for the mini, but on the Pi you will need to enable and start resolved.service
sudo systemctl start systemd-resolved.service
sudo systemctl enable systemd-resolved.service-
Create a file at
/etc/NetworkManager/system-connections/cmes-hotspot.nmconnectionwith the below info.Note: If you are configuring for the Pi you will need to replace
wlo1withwlan0[connection] id=cmes-hotspot type=wifi interface-name=wlo1 [ipv4] method=shared address1=192.168.4.1/24 [ipv6] method=disabled [wifi] ssid=CMES mode=ap [wifi-security] key-mgmt=wpa-psk psk=pionthefly pmf=1 # For Android devices proto=wpa
-
Set the owner and permissions
sudo chown root:root /etc/NetworkManager/system-connections/cmes-hotspot.nmconnection sudo chmod 600 /etc/NetworkManager/system-connections/cmes-hotspot.nmconnection
-
Generate and apply new netplan config
sudo netplan generate sudo netplan apply
-
Confirm cmes-hostpot is active
cmes@cmes-U59:~$ nmcli con show --active NAME UUID TYPE DEVICE cmes-hotspot d2ab13be-53e1-3ab9-82c4-fd41fb10684e wifi wlo1
Run the following commands to configure firewall
-
Allow access from hotspot clients.
- for mini:
sudo ufw allow in on wlo1 - for pi:
sudo ufw allow in on wlan0
- for mini:
-
Allow ssh
sudo ufw allow ssh -
Allow hotspot clients access CMES site
sudo ufw allow proto tcp from 192.168.4.0/24 to 192.168.4.1 port 80 -
Allow clients connecting from the ethernet connection
- for mini:
sudo ufw allow in on enp1s0sudo ufw allow in on enp2s0
- for pi:
sudo ufw allow in eth0
- for mini:
-
Deny access to internet for hotspot clients
sudo ufw deny proto any from 192.168.4.0/24 to 0.0.0.0/0 -
Enable the firewall in runtime
sudo ufw enable
- Create mysql defaults file
/root/.mysql_defaultswith the below content. Update with the root password for mysql.[client] user= root password=[password]
- set
sudo chown root:root .mysql_defaults
- Place
wifi_switcher.shscript on the mini. - Set the owner and permissions
sudo chown root:root wifi_switcher.sh sudo chmod 755 wifi_switcher.sh
- Run the script with required flags. You can run
wifi_switcher.sh -hfor help.
- Create a file
/etc/systemd/system/wifi_reset.servicewith the below content[Unit] Description=Reset wifi network Requires=multi-user.target After=multi-user.target [Service] Type=oneshot ExecStartPre=sleep 5 ExecStart=/var/www/html/CMES-Pi/wifi_switcher.sh -d [Install] WantedBy=multi-user.target
- Set the permissions and ownership
sudo chown root:root /etc/systemd/system/wifi_reset.service sudo chmod 644 /etc/systemd/system/wifi_reset.service
- Reload the systemd daemon to reread the system files
sudo systemctl daemon-reload - Enable the service
sudo systemctl enable wifi_reset.service