How to get the BSSID of the current WiFi connection?

In some cases, you need to retrieve the BSSID of the current WiFi connection. One example would be to know whether or not you’ve connected directly to the WiFi Mesh Extenter’s access point, instead of the WiFi Router’s access point. Given that such cases are rare, the NetworkManager GUI does not provide this information. Retrieving it is however an easy task.

Run the following command to get the name of your WiFi device:

$ iw dev
phy#0
	Unnamed/non-netdev interface
		wdev 0x2
		addr 24:c5:24:e5:24:a0
		type P2P-device
		txpower 0.00 dBm
	Interface wlp4s0
		ifindex 3
		wdev 0x1
		addr 24:c5:24:e5:24:a0
		type managed
		channel 36 (5180 MHz), width: 80 MHz, center1: 5210 MHz
		txpower 22.00 dBm
		multicast TXQ:
			qsz-byt qsz-pkt	flows	drops	marks	overlmt	hashcol	tx-bytes tx-packets
			0       0       0       0       0       0       0       0        0

Once you know the name of your WiFi device (wlp3s0 in our example), run the following to check the details of the WiFi connection:

$ iw dev wlp3s0 link
Connected to fc:fc:fc:fc:fc:fc (on wlp3s0)
	SSID: HomeSweetHome
	freq: 5180
	RX: 122584813 bytes (85251 packets)
	TX: 1856399 bytes (13331 packets)
	signal: -46 dBm
	rx bitrate: 780.0 MBit/s VHT-MCS 8 80MHz short GI VHT-NSS 2
	tx bitrate: 650.0 MBit/s VHT-MCS 7 80MHz short GI VHT-NSS 2

	bss flags:      short-slot-time
	dtim period:    1
	beacon int:     100

This returns the BSSID of our current connection. The BSSID in our example is fc:fc:fc:fc:fc:fc