2

There is a similar question here :

Netplan - Ethernet when available, wifi when not. Reconnect if needed

But it has been down-voted, and the OP indicates it is obsolete. There is a long conversation with no clear outcome so I'm hoping for a consolidation/update to that question

AND

I want to assign a static IP through both options.

2

This is much easier with static IPs than with dhcp, because all you need to do is declare the route metrics for each interface and when the ethernet has no carrier, networkd will not bring the routes up. E.g.:

network:
  version: 2
  renderer: networkd
  ethernets:
    enp2s0:
      addresses: [192.168.15.2/24]
      routes:
        - to: 0.0.0.0/0
          via: 192.168.15.1
          metric: 100
      nameservers:
        search: [mydomain, otherdomain]
        addresses: [192.168.15.1]
  wifis:
    wlx0013eff10948:
      access-points:
        "the-network":
          password: "the-password"
      addresses: [192.168.15.2/24]
      routes:
        - to: 0.0.0.0/0
          via: 192.168.15.1
          metric: 200
      nameservers:
        search: [mydomain, otherdomain]
        addresses: [192.168.15.1]

After running netplan apply, networkctl should then show output like:

$ networkctl 
IDX LINK      TYPE     OPERATIONAL SETUP     
  1 lo        loopback carrier     unmanaged 
  2 enp0s31f6 ether    no-carrier  configuring
  3 wlp82s0   wlan     routable    configured

3 links listed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.