[Linux] How to connect to wireless WPA2 with Netplan

by moondaddi on 2018-12-10


Netplan is the utility for easily configuring networking on a linux system. Ubuntu 17.10 starts including the netplan by default instead of deprecated ifupdown.

How to connect

Check the network interface

$ ifconfig -a

Configure *.yaml

Make new file with any name *.yaml in /etc/netplan You can make as many configuration files as you want. In that case, *.yaml files will be applied by alphbetically.

  version: 2
    renderer: networkd
    ethernets:  # this is for lan
        addresses: []
        dhcp4: true
    wifis:  # this is for wlan
      wlp3s0:  # wlan interface
        access-points: "SSID":  # your SSID
          password: "PASWORD"  # your PASSWORD
        dhcp4: no
        dhcp6: true
        addresses: []  # set the static IP
        gateway4:  # gateway
          addresses: [,,]

How to check wlan interface

$ iwconfig

Generate conf

The configuration files /etc/netplan/*.yaml needs to be generated before applying to system. The .conf files will be generated in `/run/netplan/.conf` which shadow completely YAML files.

$ sudo netplan --debug generate

Apply the generated conf

$ sudo netplan apply


Netplan reference page (https://netplan.io/reference)