8

My question is somehow related to this question: hostapd doesent work anymore

I have a fresh Raspbian Stretch system and then install hostapd via sudo apt-get install hostapd there are no error messages during installation, but afterwards if I want to see the services status, I can see, that it is masked.

pi@raspberrypi:~ $ sudo service hostapd status
● hostapd.service
  Loaded: masked (/dev/null; bad)
  Active: inactive (dead)

I know that I can use sudo systemctl unmask hostapd to remove the masking, but my question is, why it is masking the service? Also journalctl and /varlog/syslog have noting in their logs.

I have a lot of Pis which I orchestrate via Ansible and since about one week, the hostapd-installation and configuration is not working correctly because of the masking. But I do not want to modify my playbooks for something that more or less looks like a behavior which normally should not be there.

Stefan Wegener
  • 297
  • 1
  • 2
  • 12

2 Answers2

17

Just from the installation with sudo apt install hostapd there is nothing configured for the service. hostapd has no default setup so it doesn't make sense to start the service without it. To avoid possible confusion I suppose the package manager has decided to mask the service on installation. Just disable it is not enough to be on the save side because a disabled service can always be started manually or by another service.

You have first to configure it by creating the file /etc/hostapd/hostapd.conf and reference to it in /etc/default/hostapd with option DAEMON_CONF="/etc/hostapd/hostapd.conf".

Only if you have done all of this it is meaningful to

rpi ~$ sudo systemctl unmask hostapd.service
rpi ~$ sudo systemctl enable hostapd.service

and reboot.

Ingo
  • 42,961
  • 20
  • 87
  • 207
3

As of Debian Buster with hostapd (2:2.7+git20190128+0c1e29f-6+deb10u3), there is a new configuration method which requires that the service be masked.

In the past, one would uncomment the #DAEMON_CONF="" line in /etc/defaults/hostapd to point to the proper config. The comment block in that same file says this config method is now depreciated. Instead one should add a hostapd myconfig.conf line to the appropriate interface directly in /etc/network/interfaces*.

If you unmask the hostapd service and use the new configuration method, then everything breaks because hostapds are spawned from both the networking and hostapd services and they fight each other to control the same interface.