0

I want to add a Linux system to the white list of a WiFi mobile hotspot running on Android. Doing hostnamectl returns, amongst other information, a Static hostname, an Icon name, a Machine ID, and a Boot ID. Which of these is the right one?

I got the MAC address of the wlan0 interface by doing ip addr in the terminal and added it, together with the Static hostname, to the white list, but the connection fails. Signal strength is very good and the WPA2 password is correct.

PS.: On a Windows 10 machine, you get the corresponding name by doing hostname in the command line or looking it up in Settings > System > About under "Device name".

5
  • Look at the network logs with the terminal command: sudo journalctl -b 0 -u NetworkManager. Also do: service NetworkManager status. Commented Oct 12, 2024 at 17:23
  • @waltinator Hi, the first command prints a load of text from a log file and the second one state changes to the WiFi adapter, but there is no explanation. Are you suggesting that the hostname in the NetworkManager logs is indeed the required name? What about Icon name? Commented Oct 12, 2024 at 19:13
  • You can get the MAC address from ip link and match on that. Commented Oct 12, 2024 at 19:40
  • @waltinator Hi, thanks for your help! Feel free to formulate an answer, so I can accept it Commented Oct 13, 2024 at 16:00
  • Also posted on Ubuntu.SE: askubuntu.com/q/1529769/331791 Commented Oct 14, 2024 at 6:00

2 Answers 2

0

You can get the MAC address from ip link and match on that.

Read man ip ip-link.

1
  • Thanks a lot for this information! Commented Oct 14, 2024 at 17:05
0

In the output of hostnamectl:

  • Static hostname would be the name the system might use in its DHCP request, if configured to disclose any name at all.
  • Icon name is just a generic desktop icon name, compatible with the freedesktop.org Icon Naming Specification, to depict the system's role/form factor. For example, it might be computer-server, computer-desktop or computer-laptop. It should not be used as a form of host identification anywhere.
  • Machine ID and Boot ID are basically internal identifiers to uniquely refer to a particular installed OS and its specific boot instance. I don't think there's even a standard way to pass these to a WiFi hotspot.

I would guess that the hotspot will probably use the WiFi MAC address for the actual access control, and the hostname just as a convenient human-readable label for it.

Note that newer Linux distributions will tend to randomize their WiFi MAC addresses for privacy reasons, unless you specifically disable that feature (either for a particular wireless network, or universally). If such randomization is in effect, it will make connections to a WiFi hotspot that uses MAC address whitelisting very difficult.

To disable MAC address randomization when using NetworkManager, you can use a command like:

nmcli connection modify <connection name> 802-11-wireless.mac-address-randomization never nmcli connection modify <connection name> 802-11-wireless.cloned-mac-address permanent 

After these commands, the specified NetworkManager connection entry will be configured to always use the permanent MAC address of the WiFi interface in that particular wireless network.

The first command means "stop randomizing the MAC address", the second "don't keep using the last randomized address, but explicitly revert to using the wireless interface's permanent MAC address."

10
  • Hi, I tried the commands, but they both return Error: unknown connection 'wlan0'. What am I doing wrong? Commented Oct 14, 2024 at 17:59
  • ...also, what is the difference between these two commands and are both required or does either one suffice? Commented Oct 14, 2024 at 18:53
  • You are specifying the name of the network interface, not the name of the NetworkManager connection object. For WiFi networks, the default name for the connection object is usually the ESSID/name of the wireless network. For the explanation of the commands, see my edit. Commented Oct 14, 2024 at 19:35
  • Thanks for the addendum. And sorry again, but are you saying that I should specify the name of the network interface and not the name of the NetworkManager connection object or vice versa? English isn't my first language and I'm not sure about the semantics, i.e. whether "You are specifying..." here is supposed to be a directive for what I need to do or a description of what I've been doing wrong. Are you saying that one has to use the hotspot's SSID for the connection name? Commented Oct 14, 2024 at 20:23
  • That was a description. wlan0 would typically be a network interface name, and it is not the right thing here. You'll want to specify the name of the connection, which can be whatever you set it to... but usually when you create a WiFi connection, it would default to (connection name = hotspot SSID) unless you had specifically set a different name. Commented Oct 14, 2024 at 22:45

You must log in to answer this question.