Ubuntu – Block connections to open WiFi networks

network-managernetworkingwireless

My users are using Ubuntu on corporate laptops. They don't have sudo permissions. IT security policy deny connections to open WiFi networks. How to setup Network Manager to deny connections to that networks and permit connections only to encrypted wireless networks?

Users will connect to random wifi. I don't want to restrict connections only to known wifi networks.

Best Answer

There is a directory /etc/network/if-up.d. Scripts in this directory are runs when new connection are established. I write script that checks connection mode of wifi network and if it's Open or WEP connection is dropped.

#!/bin/bash

encryption=$(wpa_cli status | grep pairwise_cipher | cut -d "=" -f 2)
wifiname=$(wpa_cli status | grep -w ssid | cut -d "=" -f 2)
interface=$(wpa_cli status | grep interface | cut -d " " -f 3 | tr -d "'")

if [[ $encryption == WEP* ]]; then
    nmcli device disconnect $interface
fi
if [[ $encryption == NONE ]]; then
    nmcli device disconnect $interface
fi