Programster's Blog

Tutorials focusing on Linux, programming, and open-source

Create A WiFi Access Point Using Netplan

Check features of wifi dongle with iw

sudo apt-get install iw 
iw list

In the output there will be "Supported interface modes" and we just need to make sure it includes AP

...
    Available Antennas: TX 0 RX 0
    Supported interface modes:
         * IBSS
         * managed
         * AP
         * AP/VLAN
         * monitor
         * mesh point
         * P2P-client
         * P2P-GO
    Band 1:
...

Get Network Interface Names

Use the following command to find the name of your network interfaces. You need to make a note of your ethernet connection which should be something like eth0 or enp2s0, and your wifi interface which should appear as something like wlan0 or wlx10feed21c74a

ip -o link show | awk -F': ' '{print $2}'

Setting Up The Bridge

We've now set up the wifi network so that it can be accessed, but now we need to make it bridged against our ethernet connection so that people who connect to our computers wifi access point can then connect out to the internet, by "crossing the bridge" to the ethernet connection.

sudo apt-get install bridge-utils -y

Setting Up Netplan

You should already have a netplan configuration under /etc/netplan. Move the file(s) to have the .bak extension to "disable" them when we restart the networking later.

Now create our new netplan configuration file:

sudo vim /etc/netplan/01-network-with-wifi-access-point.yaml

If you use the .yml file extension instead of the .yaml file extension, then netplan silently ignores your configuration file and you will be wondering why things aren't working!

Fill it with the following content, changing the name of the wifi and ethernet interfaces as appropriate, along with the password. Also, you may wish to change the 5 to 2.4 if you wish to change the band.

network:
  version: 2
  renderer: NetworkManager
  ethernets:
    enp2s0:
      dhcp4: true
      optional: true
  wifis:
    wlx0013eff111a9:
      dhcp4: true
      optional: true
      access-points:
        "mySsidName":
          password: "MY_AWESOME_PASSWORD_HERE"
          mode: ap
          band: 5GHz

Be sure to change enp2s0, wlx0013eff111a9, and MY_AWESOME_PASSWORD_HERE, as appropriate.

Now run the following command to check that the configuration files are valid:

sudo netplan generate

If that came back without errors, you can apply the change with:

sudo netplan apply
Last updated: 20th June 2021
First published: 18th June 2021