5

I've switch my Rpi 4B (with raspbian) to ubuntu server since will be used as a portable WLAN web-server. My main objective is to set up an hotspot to access the local websites in the raspi.

I got experience with the raspbian way to set up the hotspot: https://www.raspberrypi.org/documentation/configuration/wireless/access-point.md

I tried this in the my new ubuntu server OS and can't make it work.

Hostapd service logs shows:

Mar 18 16:25:49 ubuntu systemd[1]: Starting Advanced IEEE 802.11 AP and IEEE 802.1X/WPA/WPA2/EAP Authenticator...
Mar 18 16:25:49 ubuntu hostapd[1388]: Configuration file: /etc/hostapd/hostapd.conf
Mar 18 16:25:49 ubuntu hostapd[1388]: wlan0: interface state UNINITIALIZED->COUNTRY_UPDATE
Mar 18 16:25:49 ubuntu systemd[1]: Started Advanced IEEE 802.11 AP and IEEE 802.1X/WPA/WPA2/EAP Authenticator.

And my dnsmasq logs:

Mar 18 16:25:49 ubuntu systemd[1]: Starting dnsmasq - A lightweight DHCP and caching DNS server...
Mar 18 16:25:49 ubuntu dnsmasq[1393]: dnsmasq: syntax check OK.
Mar 18 16:25:49 ubuntu dnsmasq[1460]: dnsmasq: unknown interface wlan0
Mar 18 16:25:49 ubuntu dnsmasq[1460]: unknown interface wlan0
Mar 18 16:25:49 ubuntu dnsmasq[1460]: FAILED to start up
Mar 18 16:25:49 ubuntu systemd[1]: dnsmasq.service: Control process exited, code=exited status=2
Mar 18 16:25:49 ubuntu systemd[1]: dnsmasq.service: Failed with result 'exit-code'.
Mar 18 16:25:49 ubuntu systemd[1]: Failed to start dnsmasq - A lightweight DHCP and caching DNS server.

WHAT I HAVE TRIED:

I've started the wlan0 interface with: sudo ifconfig wlan0 up, after this I restart dnsmasq and hostapd service and then the hotspot service start just fine. But when I reboot the device wlan0 doesn't start automatically.

One more thing. If I connect the raspi with a wifi dongle (in wlan1 using netplan) to a router and I start as before wlan0 the Hotspot doesn't work either.

Seba
  • 53
  • 1
  • 1
  • 4

2 Answers2

5

Ubuntu Server uses Netplan to manage its connections.

To create an access point using Netplan, you can do the following:

1. Install Network Manager

sudo apt update
sudo apt install network-manager

2. Disable cloud-init

sudo bash -c "echo 'network: {config: disabled}' > /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg"

3. Create a Netplan configuration

sudo nano /etc/netplan/10-my-config.yaml

Then add the following configuration:

network:
  version: 2
  renderer: NetworkManager
  ethernets:
    eth0:
      dhcp4: true
      optional: true
  wifis:
    wlan0:
      dhcp4: true
      optional: true
      access-points:
        "Raspberry":
          password: "your password here"
          mode: ap

You can change the access point name "Raspberry" and the password to your liking.

Then save the file using CTRL+X.

4. Apply the Netplan configuration

Finally, use use the following commands to apply your new configuration:

sudo netplan generate
sudo netplan apply

A new wireless access point should be created. It has DHCP and DNS enabled by default, and if the Pi has internet access over Ethernet, it'll be shared over the WiFi hotspot as well.


For more information about the configuration used in the YAML file, check out the Netplan Reference.

tttapa
  • 931
  • 4
  • 7
  • So, all what I did was unnecessary? Should I delete all and remove hostapd? – Seba Mar 18 '20 at 20:13
  • @Seba yes, as far as I know, you don't need `hostapd`. I don't have it installed on my RPi 3B+ running Ubuntu Server 18.04, and the access point works just fine without it. – tttapa Mar 18 '20 at 20:34
  • @tttapa How do you configure your access point? I just want WPA2 AES to be allowed. Mine lets me auth with regular old WPA. What about port forwarding? Static IP assignment? – Allenph Aug 25 '20 at 06:50
  • I'm getting ```$ netplan generate ERROR: wlan0: Raspberry: networkd does not support this wifi mode``` on my Raspberry Pi 4. Does it only work on specific hardware? – ChrisB Jan 23 '22 at 03:55
1

The tutorial you linked is for Raspbian which uses dhcpcd as its network manager.

Ubuntu Server uses systemd-networkd with a yaml front end.

You COULD install network-manager (or dhcpcd for that matter) but you would be better to configure systemd-networkd.

See Access point as WiFi router/repeater, optional with bridge

(I have not tried this myself)

PS making a Server an Access Point seems unnecessary - you would be better to use your router.

Milliways
  • 54,718
  • 26
  • 92
  • 182