detailed how to or example needed to setup an access point using netplan

As headline stated: I am looking for instructions on how to setup an access point using netplan, including setting up a bridge between eth0 and wlan0. DHCP Server would be my router, to which the system is connected via eth0. I am running Ubuntu Server 18.04. (I used to be able to do it following examples using ifupdown and hostapd, but now I need to stay with netplan..)

  • What packages need to be installed for this?
  • Beside setting up a yaml file, what needs to be done?
  • where is the bridge (i.e.br0) defined?
  • where are credentails like ssid and password set?
  • Could you share an example yaml file (i.e. with eth0 wlan0) for the above scenario? (I need a solution without using iptables, as this can not be used in my system)

As I am far from being an expert, the more detailed the instructions, the better....


Solution 1:

I got it to work with the help of these links: 1, 2, 3, 4

This is the sequence, which worked for me (WiFi in n-Mode, static IP):

  • Install hostapd: apt-get update, apt-get install hostapd
  • unmask & enable it: sudo systemctl unmask hostapd, sudo systemctl enable hostapd
  • create /etc/hostapd/hostapd.conf and cut&paste:
# the interface used by the AP
interface=wlan0
driver=nl80211
# "g" simply means 2.4GHz band
hw_mode=g
# the channel to use
channel=1
# limit the frequencies used to those allowed in the country
ieee80211d=1
# the country code
country_code=DE
# 802.11n support
ieee80211n=1
# QoS support
wmm_enabled=1
# the name of the AP
ssid=yourSSID
macaddr_acl=0
# 1=wpa, 2=wep, 3=both
auth_algs=1
ignore_broadcast_ssid=0
# WPA2 only
wpa=2
wpa_passphrase=yourpassphrase
wpa_key_mgmt=WPA-PSK
#wpa_pairwise=TKIP
rsn_pairwise=CCMP
  • Edit the file /etc/default/hostapd and modify the line of DAEMON_CONF like this: DAEMON_CONF="/etc/hostapd/hostapd.conf"

(Testing to verify is AP is visible i.e. on phone: sudo service hostapd start; then sudo service hostapd stop again to continue setup)

  • cut&paste this into `/etc/netplan/network.yaml file (no tabs, just spaces, follow indentation exactly - yaml is picky...):
network:
  version: 2
  renderer: networkd
  ethernets:
    # My Ethernet adapter
    eth0:
      # For some reason it seems I must specify at least something here.
      dhcp4: no
    # My Wi-Fi adapter
    wlan0:
      dhcp4: no
  bridges:
    br0:
      interfaces:
        - eth0
        - wlan0
      # Using a static IP for this box.
      addresses:
        - 192.168.1.xxx/24
      gateway4: 192.168.1.x
      nameservers:
        addresses: [1.1.1.1,1.0.0.1]
  • Apply the new configuration: sudo netplan generate,sudo netplan apply