[LINUX] To connect to WIFI that is restricted by MAC address with CentOS (NetworkManager).

Problems encountered

In an attempt to prepare a (closed) wireless LAN for testing, I prepared a general wireless LAN access point and kept the WiFi SSID private. I prepared a DHCP server for Linux and assigned an IP address only to the hardware address (MAC address) registered in advance.

I tried to connect to it via DHCP on a Linux (CentOS) machine via WiFi.

  1. First, check the MAC address of the DHCP client with ʻifconfig or ʻip addr on the Linux machine you want to connect to.
  2. Set the DHCP server so that the IP address etc. is assigned to the MAC address of the client. (For the connection settings for stealth SSID, refer to this article)
  3. On the client machine, set the wireless LAN settings (SSID, WPA2 passphrase, etc.) and connect.

However, in step 3, the DHCP server did not assign an IP address, etc., and the connection failed.


The cause was that ** MAC address randomization ** was enabled by default in NetworkManager. Since the DHCP client queries the DHCP server using an appropriate MAC address, the DHCP server considers it an invalid request and completely ignores it.


Since this environment is a test network and never goes out to the outside world, there is little risk of collecting MAC addresses, so we disabled MAC address randomization.

Execution example

An execution example including the connection method to the stealth SSID in Reference article is as follows. [[Connection name]], [[Interface name]] , [[Destination SSID]], [[WPA2 Passphrase]] must actually be matched.

Execution example

# nmcli c add type wifi con-name [[wlan0a]] ifname [[wlan0]] ssid [[ACTUAL-SSID-NAME]]
# nmcli con modify [[wlan0a]] wifi-sec.key-mgmt wpa-psk
# nmcli con modify [[wlan0a]] wifi-sec.psk [[ACTUAL-WPA2-PASSPHASE]]
# nmcli con modify [[wlan0a]] wifi.mac-address-randomization never
# nmcli con up [[wlan0a]]
# nmcli con show [[wlan0a]]

Recommended Posts

To connect to WIFI that is restricted by MAC address with CentOS (NetworkManager).
Connect to centos6 on virtualbox with ssh connection from Mac
[Cyberduck] How to exchange files on Linux (CentOS7) started by VirtualBox with mac using GUI
Generate a password that is easy to remember with apg
The story that the private key is set to 600 with chmod
How to start Apache by specifying httpd.conf with systemd (CentOS7, CentOS8)
Volume that html extracted by PyQuery is troubled with xml
Connect to BigQuery with Python
Connect to Wikipedia with Python
Connect to Postgresql with GO