Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save webworker01/da709cd7ed0a06cc409b3c46d18795fb to your computer and use it in GitHub Desktop.

Select an option

Save webworker01/da709cd7ed0a06cc409b3c46d18795fb to your computer and use it in GitHub Desktop.

Revisions

  1. @austinjp austinjp revised this gist Aug 5, 2018. 1 changed file with 18 additions and 2 deletions.
    20 changes: 18 additions & 2 deletions wifi-on-ubuntu-server-18.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,16 @@
    # Wifi on Ubuntu 18 _server_

    ## TLDR

    1. Install `wpasupplicant`
    1. Turn on wifi radios: `sudo nmcli radio wifi on`
    1. Check your devices are recognised even if they're not "managed": `sudo iwconfig`
    1. Check your wifi (here called "wlp3s0") is capable of detecting nearby routers: `sudo iwlist wlp3s0 scan`
    1. Configure `netplan` by dropping a file called `01-netcfg.yml` into `/etc/netplan/` or edit existing file there. See example below.
    1. `netplan try`, `netplan generate`, `netplan apply`.

    # The backstory

    I want to run Ubuntu *server* 18 on my laptop. This by default does not use X windows, so there is no desktop environment. It also by default does not enable wifi. Servers don't usually need wifi and desktop environments, right?

    Anyway, I want _both_ wifi and a desktop environment. I actually tried Ubuntu desktop with Gnome on this T420, but Firefox crashed several times, locking up the whole machine. Since I want the laptop to emulate a server environment for development I thought screw it, let's install Ubuntu server on here and just add a light desktop environment.
    @@ -101,8 +114,11 @@ network:
    wlp3s0:
    dhcp4: yes
    access-points:
    my-router-name:
    password: <wifi password here in plain text>
    "my-router-name":
    password: "<wifi password here in plain text>"
    "some-other-router":
    password: "plain-text-password"
    "Public Hotspot With No Password": {}
    ```
    Do not be distracted by `/etc/network/interfaces`! Mine looks like this, note what the comments say, and note that there is nothing else in apart from the comments, i.e. it does nothing:
  2. @austinjp austinjp revised this gist Jul 1, 2018. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions wifi-on-ubuntu-server-18.md
    Original file line number Diff line number Diff line change
    @@ -8,6 +8,7 @@ Outstanding items:

    * Add other wifi networks
    * Switch between networks
    * Get `nmtui` to display and switch between wifi networks

    ## Install Ubuntu

  3. @austinjp austinjp revised this gist Jul 1, 2018. 1 changed file with 10 additions and 2 deletions.
    12 changes: 10 additions & 2 deletions wifi-on-ubuntu-server-18.md
    Original file line number Diff line number Diff line change
    @@ -41,10 +41,18 @@ Added to this, `netplan` is also used. See [netplan.io](netplan.io)

    Also required, apparently, is `wpasupplicant`.

    Turn on wifi radios:

    ```
    $ sudo nmcli radio wifi on
    $ sudo nmcli radio wifi
    enabled
    ```

    Check your devices are all recognised, even if they're not currently being "managed":

    ```
    $ iwconfig
    $ sudo iwconfig
    lo no wireless extensions.
    enp0s25 no wireless extensions.
    @@ -64,7 +72,7 @@ wlp3s0 IEEE 802.11 ESSID:"my-router-name"
    Check your wifi is capable of detecting nearby routers:

    ```
    $ iwlist wlp3s0 scan
    $ sudo iwlist wlp3s0 scan
    wlp3s0 Scan completed :
    Cell 01 - Address: 70:4F:57:3F:78:87
    Channel:1
  4. @austinjp austinjp created this gist Jul 1, 2018.
    175 changes: 175 additions & 0 deletions wifi-on-ubuntu-server-18.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,175 @@
    I want to run Ubuntu *server* 18 on my laptop. This by default does not use X windows, so there is no desktop environment. It also by default does not enable wifi. Servers don't usually need wifi and desktop environments, right?

    Anyway, I want _both_ wifi and a desktop environment. I actually tried Ubuntu desktop with Gnome on this T420, but Firefox crashed several times, locking up the whole machine. Since I want the laptop to emulate a server environment for development I thought screw it, let's install Ubuntu server on here and just add a light desktop environment.

    ## TODO

    Outstanding items:

    * Add other wifi networks
    * Switch between networks

    ## Install Ubuntu

    I'm using a Lenovo ThinkPad T420. On a Windows machine, I followed the instructions on the Ubuntu website for creating a bootable USB stick.

    On the T420 I had to go into the bios and move USB up the list so it would boot from the stick.

    Installation of Ubuntu was smooth, all went perfectly well.

    ## Install desktop environment

    There are plenty of choices, mine was:

    ```
    sudo apt install xubuntu-desktop
    ```

    ## Wifi Networks device not managed

    Imagine my delight when I first log into an X window session and realise that the laptop is not connected to the wifi/internet.

    ## Get wifi working

    This is based on a pretty poor understanding of what's going on. Here's what I guesstimate to be the situation.

    As of Ubuntu 17, networking is managed by either of two approaches: `NetworkManager` or `networkd`.

    Added to this, `netplan` is also used. See [netplan.io](netplan.io)

    `netplan` reads YAML config files and generates config files for `NetworkManager` or `networkd`, depending on your preferences.

    Also required, apparently, is `wpasupplicant`.

    Check your devices are all recognised, even if they're not currently being "managed":

    ```
    $ iwconfig
    lo no wireless extensions.
    enp0s25 no wireless extensions.
    wlp3s0 IEEE 802.11 ESSID:"my-router-name"
    Mode:Managed Frequency:2.412 GHz Access Point: 71:5F:58:2F:79:97
    Bit Rate=58.5 Mb/s Tx-Power=15 dBm
    Retry short limit:7 RTS thr:off Fragment thr:off
    Power Management:off
    Link Quality=50/70 Signal level=-60 dBm
    Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
    Tx excessive retries:12 Invalid misc:59 Missed beacon:0
    ```

    `wlp3s0` is the wifi device in my laptop. If yours doesn't appear.... good luck with that. Maybe try `ifconfig up wlp3s0`

    Check your wifi is capable of detecting nearby routers:

    ```
    $ iwlist wlp3s0 scan
    wlp3s0 Scan completed :
    Cell 01 - Address: 70:4F:57:3F:78:87
    Channel:1
    Frequency:2.412 GHz (Channel 1)
    Quality=50/70 Signal level=-60 dBm
    Encryption key:on
    ESSID:"my-router-name"
    ...
    <lots more - output trimmed for brevity>
    ```

    Again, if your output is different here, good luck!

    Configure netplan:

    My `/etc/netplan/01-netcfg.yml` looks like this, note that it renders config files for `networkd`:

    ```yaml
    # This file describes the network interfaces available on your system
    # For more information, see netplan(5).
    network:
    version: 2
    renderer: networkd
    wifis:
    wlp3s0:
    dhcp4: yes
    access-points:
    my-router-name:
    password: <wifi password here in plain text>
    ```
    Do not be distracted by `/etc/network/interfaces`! Mine looks like this, note what the comments say, and note that there is nothing else in apart from the comments, i.e. it does nothing:

    ```
    # ifupdown has been replaced by netplan(5) on this system. See
    # /etc/netplan for current configuration.
    # To re-enable ifupdown on this system, you can run:
    # sudo apt install ifupdown
    ```
    `ifupdown` is not on my system.
    Running this seemed to get things working:
    ```
    sudo su -
    netplan apply
    service network-manager restart
    ```
    This is confusing. The `netplan` config file renders for `networkd` yet restarting the `network-manager` seems to apply the netplan changes to NetworkManager.
    At some point I think I also restarted the `wpa_supplicant` service:
    ```
    sudo su -
    service wpa_supplicant restart
    ```
    As of now the wifi is working perfectly. I have not yet rebooted. I notice that the wifi indicator panel in XFCE still says "WiFi Networks device not managed", but I think that's because it's checking with `NetworkManager`, which is not being used.
    ## Other nonsense
    Much random stabbing in the dark was involved, including the following, I have little idea if these were necessary but this is what Google led me to do:
    ```
    rfkill unblock wifi
    systemctl disable systemd-networkd-wait-online.service
    systemctl mask systemd-networkd-wait-online.service
    ```
    Useful stuff for debugging:
    ```
    root@at420:~# service netplan-wpa@wlp3s0 status
    [email protected] - WPA supplicant for netplan wlp3s0
    Loaded: loaded (/lib/systemd/system/[email protected]; indirect; vendor preset: enabled)
    Active: active (running) since Sat 2018-06-30 11:41:10 BST; 32min ago
    Main PID: 2971 (wpa_supplicant)
    Tasks: 1 (limit: 4390)
    CGroup: /system.slice/system-netplan\x2dwpa.slice/netplan-[email protected]
    └─2971 /sbin/wpa_supplicant -c /run/netplan/wpa-wlp3s0.conf -iwlp3s0

    Jun 30 11:41:10 t420 systemd[1]: Started WPA supplicant for netplan wlp3s0.
    Jun 30 11:41:10 t420 wpa_supplicant[2971]: Successfully initialized wpa_supplicant
    Jun 30 11:41:14 t420 wpa_supplicant[2971]: wlp3s0: SME: Trying to authenticate with 71:5F:58:2F:79:97 (SSID='<my wifi>' freq=2412 MHz)
    Jun 30 11:41:14 t420 wpa_supplicant[2971]: wlp3s0: Trying to associate with 71:5F:58:2F:79:97 (SSID='<my wifi>' freq=2412 MHz)
    Jun 30 11:41:14 t420 wpa_supplicant[2971]: wlp3s0: Associated with 71:5F:58:2F:79:97
    Jun 30 11:41:14 t420 wpa_supplicant[2971]: wlp3s0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0
    Jun 30 11:41:14 t420 wpa_supplicant[2971]: wlp3s0: WPA: Key negotiation completed with 71:5F:58:2F:79:97 [PTK=CCMP GTK=TKIP]
    Jun 30 11:41:14 t420 wpa_supplicant[2971]: wlp3s0: CTRL-EVENT-CONNECTED - Connection to 71:5F:58:2F:79:97 completed [id=0 id_str=]
    ```
    ```
    service wpa_supplicant status
    ● wpa_supplicant.service - WPA supplicant
    Loaded: loaded (/lib/systemd/system/wpa_supplicant.service; enabled; vendor preset: enabled)
    Active: active (running) since Sat 2018-06-30 11:27:51 BST; 49min ago
    Main PID: 1135 (wpa_supplicant)
    Tasks: 1 (limit: 4390)
    CGroup: /system.slice/wpa_supplicant.service
    └─1135 /sbin/wpa_supplicant -u -s -O /run/wpa_supplicant

    Jun 30 11:27:50 t420 systemd[1]: Starting WPA supplicant...
    Jun 30 11:27:51 t420 wpa_supplicant[1135]: Successfully initialized wpa_supplicant
    Jun 30 11:27:51 t420 systemd[1]: Started WPA supplicant.
    ```