Guest User

Untitled

a guest
Dec 18th, 2018
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.44 KB | None | 0 0
  1. # Wifi on Ubuntu 18 _server_
  2.  
  3. ## TLDR
  4.  
  5. 1. Install `wpasupplicant`
  6. 1. Turn on wifi radios: `sudo nmcli radio wifi on`
  7. 1. Check your devices are recognised even if they're not "managed": `sudo iwconfig`
  8. 1. Check your wifi (here called "wlp3s0") is capable of detecting nearby routers: `sudo iwlist wlp3s0 scan`
  9. 1. Configure `netplan` by dropping a file called `01-netcfg.yml` into `/etc/netplan/` or edit existing file there. See example below.
  10. 1. `netplan try`, `netplan generate`, `netplan apply`.
  11.  
  12. # The backstory
  13.  
  14. 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?
  15.  
  16. 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.
  17.  
  18. ## TODO
  19.  
  20. Outstanding items:
  21.  
  22. * Add other wifi networks
  23. * Switch between networks
  24. * Get `nmtui` to display and switch between wifi networks
  25.  
  26. ## Install Ubuntu
  27.  
  28. 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.
  29.  
  30. On the T420 I had to go into the bios and move USB up the list so it would boot from the stick.
  31.  
  32. Installation of Ubuntu was smooth, all went perfectly well.
  33.  
  34. ## Install desktop environment
  35.  
  36. There are plenty of choices, mine was:
  37.  
  38. ```
  39. sudo apt install xubuntu-desktop
  40. ```
  41.  
  42. ## Wifi Networks device not managed
  43.  
  44. Imagine my delight when I first log into an X window session and realise that the laptop is not connected to the wifi/internet.
  45.  
  46. ## Get wifi working
  47.  
  48. This is based on a pretty poor understanding of what's going on. Here's what I guesstimate to be the situation.
  49.  
  50. As of Ubuntu 17, networking is managed by either of two approaches: `NetworkManager` or `networkd`.
  51.  
  52. Added to this, `netplan` is also used. See [netplan.io](netplan.io)
  53.  
  54. `netplan` reads YAML config files and generates config files for `NetworkManager` or `networkd`, depending on your preferences.
  55.  
  56. Also required, apparently, is `wpasupplicant`.
  57.  
  58. Turn on wifi radios:
  59.  
  60. ```
  61. $ sudo nmcli radio wifi on
  62. $ sudo nmcli radio wifi
  63. enabled
  64. ```
  65.  
  66. Check your devices are all recognised, even if they're not currently being "managed":
  67.  
  68. ```
  69. $ sudo iwconfig
  70. lo no wireless extensions.
  71.  
  72. enp0s25 no wireless extensions.
  73.  
  74. wlp3s0 IEEE 802.11 ESSID:"my-router-name"
  75. Mode:Managed Frequency:2.412 GHz Access Point: 71:5F:58:2F:79:97
  76. Bit Rate=58.5 Mb/s Tx-Power=15 dBm
  77. Retry short limit:7 RTS thr:off Fragment thr:off
  78. Power Management:off
  79. Link Quality=50/70 Signal level=-60 dBm
  80. Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
  81. Tx excessive retries:12 Invalid misc:59 Missed beacon:0
  82. ```
  83.  
  84. `wlp3s0` is the wifi device in my laptop. If yours doesn't appear.... good luck with that. Maybe try `ifconfig up wlp3s0`
  85.  
  86. Check your wifi is capable of detecting nearby routers:
  87.  
  88. ```
  89. $ sudo iwlist wlp3s0 scan
  90. wlp3s0 Scan completed :
  91. Cell 01 - Address: 70:4F:57:3F:78:87
  92. Channel:1
  93. Frequency:2.412 GHz (Channel 1)
  94. Quality=50/70 Signal level=-60 dBm
  95. Encryption key:on
  96. ESSID:"my-router-name"
  97. ...
  98. <lots more - output trimmed for brevity>
  99. ```
  100.  
  101. Again, if your output is different here, good luck!
  102.  
  103. Configure netplan:
  104.  
  105. My `/etc/netplan/01-netcfg.yml` looks like this, note that it renders config files for `networkd`:
  106.  
  107. ```yaml
  108. # This file describes the network interfaces available on your system
  109. # For more information, see netplan(5).
  110. network:
  111. version: 2
  112. renderer: networkd
  113. wifis:
  114. wlp3s0:
  115. dhcp4: yes
  116. access-points:
  117. "my-router-name":
  118. password: "<wifi password here in plain text>"
  119. "some-other-router":
  120. password: "plain-text-password"
  121. "Public Hotspot With No Password": {}
  122. ```
  123.  
  124. 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:
  125.  
  126. ```
  127. # ifupdown has been replaced by netplan(5) on this system. See
  128. # /etc/netplan for current configuration.
  129. # To re-enable ifupdown on this system, you can run:
  130. # sudo apt install ifupdown
  131. ```
  132.  
  133. `ifupdown` is not on my system.
  134.  
  135. Running this seemed to get things working:
  136.  
  137. ```
  138. sudo su -
  139. netplan apply
  140. service network-manager restart
  141. ```
  142.  
  143. This is confusing. The `netplan` config file renders for `networkd` yet restarting the `network-manager` seems to apply the netplan changes to NetworkManager.
  144.  
  145. At some point I think I also restarted the `wpa_supplicant` service:
  146.  
  147. ```
  148. sudo su -
  149. service wpa_supplicant restart
  150. ```
  151.  
  152. 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.
  153.  
  154.  
  155. ## Other nonsense
  156.  
  157. 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:
  158.  
  159. ```
  160. rfkill unblock wifi
  161. systemctl disable systemd-networkd-wait-online.service
  162. systemctl mask systemd-networkd-wait-online.service
  163. ```
  164.  
  165. Useful stuff for debugging:
  166.  
  167. ```
  168. root@at420:~# service netplan-wpa@wlp3s0 status
  169. ● netplan-wpa@wlp3s0.service - WPA supplicant for netplan wlp3s0
  170. Loaded: loaded (/lib/systemd/system/netplan-wpa@.service; indirect; vendor preset: enabled)
  171. Active: active (running) since Sat 2018-06-30 11:41:10 BST; 32min ago
  172. Main PID: 2971 (wpa_supplicant)
  173. Tasks: 1 (limit: 4390)
  174. CGroup: /system.slice/system-netplan\x2dwpa.slice/netplan-wpa@wlp3s0.service
  175. └─2971 /sbin/wpa_supplicant -c /run/netplan/wpa-wlp3s0.conf -iwlp3s0
  176.  
  177. Jun 30 11:41:10 t420 systemd[1]: Started WPA supplicant for netplan wlp3s0.
  178. Jun 30 11:41:10 t420 wpa_supplicant[2971]: Successfully initialized wpa_supplicant
  179. 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)
  180. 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)
  181. Jun 30 11:41:14 t420 wpa_supplicant[2971]: wlp3s0: Associated with 71:5F:58:2F:79:97
  182. Jun 30 11:41:14 t420 wpa_supplicant[2971]: wlp3s0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0
  183. 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]
  184. 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=]
  185. ```
  186.  
  187. ```
  188. service wpa_supplicant status
  189. ● wpa_supplicant.service - WPA supplicant
  190. Loaded: loaded (/lib/systemd/system/wpa_supplicant.service; enabled; vendor preset: enabled)
  191. Active: active (running) since Sat 2018-06-30 11:27:51 BST; 49min ago
  192. Main PID: 1135 (wpa_supplicant)
  193. Tasks: 1 (limit: 4390)
  194. CGroup: /system.slice/wpa_supplicant.service
  195. └─1135 /sbin/wpa_supplicant -u -s -O /run/wpa_supplicant
  196.  
  197. Jun 30 11:27:50 t420 systemd[1]: Starting WPA supplicant...
  198. Jun 30 11:27:51 t420 wpa_supplicant[1135]: Successfully initialized wpa_supplicant
  199. Jun 30 11:27:51 t420 systemd[1]: Started WPA supplicant.
  200. ```
Add Comment
Please, Sign In to add comment