1

Note: this question has changed while investigating problem to stay up to date.

Note 2: This question is invalid, the described problem is gone. Askubuntu prevents me from deleting it.

Here is my /etc/netplan/01.yaml config on my new 18.04 headless server. The file describes two of my hardware interfaces i may use:

network:
  version: 2
  renderer: networkd
  ethernets:
    enp2s0:
      optional: true
      dhcp4: yes
  wifis:
    wlx0013eff10948:
      access-points:
        "the-network":
          password: "the-password"
      dhcp4: yes

The problem is that Wifi connection sometimes can die. Or there is no connectivity at boot time. The same conditions are for Ethernet interface.

How can i tweak my system to adapt routing table and and etc to these changes? For now, it seems that any hardware change breaks system's "default gateway".

As a result, i can have one or both my interfaces with an assigned IP addresses without working ping in my system. And there is not problem with access point or router behind cable - my setup just cannot survive "changes" and switches..

ifconfig summary

docker0
  (br)

enp2s0 
    (no inet)
lo

tun0

   (openvpn - there is  client daemon that needs to be connected to my VPN)

wlx0013eff10948
    (inet 192.168.1.x) = shows as connected, but internet is not working

Less relevant information

wlx0013eff10948 is rtl8192cu USB dongle. I only installed linux-generic-hwe-18.04 for it to appear and work (tested with wicd-curses). As it turns out, there is no problem with WIFI - just the way system handles the lost wifi (or cable) connection.

Sometimes i can see this output appearing in machine's tty:

[ 232.2332] rtlwifi: AP off, try to reconnect now

Exactly at the state when i don't have wifi cable and wifi connection has died, but should be re-established. Which is not happening

enter image description here

Croll
  • 639
  • 1
    ah... turn off VPN and see if wi-fi works then... the question keeps changing here... – heynnema Mar 14 '19 at 20:58
  • i had to rewrite the question – Croll Mar 14 '19 at 21:28
  • Did you get it working? What did you do? You should see Delete right underneath your question. – heynnema Mar 15 '19 at 00:00
  • Actually, I was asking about your comment "This question is invalid, the described problem is gone. Askubuntu prevents me from deleting it.". How/why is the problem gone? Why can't you delete your question? Don't you see delete next to "share/edit/close/flag" under your question? – heynnema Mar 17 '19 at 19:33
  • Check the update :) The problem has gone itself (reconnection started to work properly for wifi). Although it turns to be impossible to set priority for ethernet over wifi in latest ubuntu LTS (which is really bad), this question still must be deleted. Maybe i will rewrite the question and add answer later. – Croll Mar 17 '19 at 19:46
  • I would suggest taking out your "Note 2" and the delete error image, adding an "Update #n" at the end, with any final thoughts that might be useful to the casual reader sometime in the future. – heynnema Mar 17 '19 at 19:53

1 Answers1

1

Try...

An optional device is not required for booting. Normally, networkd will wait some time for device to become configured before proceeding with booting. However, if a device is marked as optional, networkd will not wait for it. This is only supported by networkd, and the default is false.

Source: https://netplan.io/reference

network:
  version: 2
  renderer: networkd
  ethernets:
    enp2s0:
      dhcp4: yes
      dhcp4-overrides:    # possibly not functional yet
        route-metric: 100 # possibly not functional yet
      optional: true
  wifis:
    wlx0013xxx:
      access-points:
        "the-network":
          password: "the-password"
      dhcp4: true
      dhcp4-overrides:    # possibly not functional yet
        route-metric: 200 # possibly not functional yet

sudo netplan generate

sudo netplan apply

heynnema
  • 70,711
  • 1
    Is there a way to change route metrics through netplan so ethernet is preferred whenever a wired connection is present? – gmt42 Mar 14 '19 at 20:24
  • @gmt42 yes, see https://netplan.io/examples See the update to my answer. – heynnema Mar 14 '19 at 20:28
  • @gmt42 in netplan 0.95, where is dhcp-overrides.route-metric: x section support in syntax (still yaml file version 2), but it is not released yet and will render real file invalid. This was a pain to discover – Croll Mar 14 '19 at 20:28
  • The real problem, as it turns out, is that when i am on wifi, wifi connection to the AP dies after some (idle) time and reconnection is not happening. This feels much more troubling to my server right now. – Croll Mar 14 '19 at 20:29
  • @Croll Note that systemd-networkd does not natively support wifi, so you need wpasupplicant installed if you let the networkd renderer handle wifi. – heynnema Mar 14 '19 at 20:37
  • @heynnema It would be interesting to see that work. If dhcp-overrides.route-metric: doesn't work as Croll said ... then perhaps it is his only option. – gmt42 Mar 14 '19 at 20:41
  • @heynnema I use wifi dongle which is not natively supported but installing package linux-generic-hwe-18.04 and rebooting made it work without wpasupplicant. I tested first by wicd-curses gui and connected to my network, when added wifis to netplan. – Croll Mar 14 '19 at 20:45
  • @Croll if you had to install a driver for wi-fi, it may have an "option" parameter like keepalive or ping that could be set? Do a modinfo to find out. – heynnema Mar 14 '19 at 20:48
  • with wireless-tools's iwconfig i can't even set power off for this dongle (to disable powersaving). It seems that it is a rare weak chip and works bad because of low signal from AP. I don't see any netplanish way to control anything related to wifi. I can't even test if i am actually connected. My machine loses connection after some short time, both ethernet or wifi. :( – Croll Mar 14 '19 at 20:53
  • @Croll do sudo lshw -C network and see what driver it's using, then do modinfo driver_name to look for optional parameters.... and giggle... stop unplugging the ethernet cable... or get a better dongle... :-) – heynnema Mar 14 '19 at 20:55
  • I can't upgrade now. Thanks for hint, it shows my chip is rtl8192cu. Updated question with ifconfig. – Croll Mar 14 '19 at 20:59
  • @Croll what did modinfo say? – heynnema Mar 14 '19 at 21:01
  • Realtek 8192C 802.11n USB by Larry Finger,Ziv Huang and Realtek. – Croll Mar 14 '19 at 21:06
  • @Croll didn't it show the option parameters that are available to tweak the driver? – heynnema Mar 14 '19 at 21:07
  • debug_level (0-5), debug_mask (number), swenc (default 0, 1 for sofware crypto) – Croll Mar 14 '19 at 21:09