What is the netplan equivalent to this interfaces.d config?

Trying to setup a CANBUS interface on Ubuntu Server for a 3D Printer. All the instructions are for Raspberry Pi OS which still uses interfaces.d so I need the netplan equivalent of the following as I am completely lost. Plenty of information online about simple eth static/dhcp but can’t find anything specific about this. I would rather not simply install net-tools if I can avoid it.

allow-hotplug can0
iface can0 can static
  bitrate 500000
  up ifconfig $IFACE txqueuelen 128

I think I have figured out how to add this CANBUS interface but I have a different problem first. netplan apply does not seem to be working at all. Yet it produces no errors. So I test with the simplest thing…

Ubuntu 22.04.3

I edit /etc/netplan/00-installer-config.yaml adding optional: true to both interfaces.

# This is the network config written by 'subiquity'
network:
  ethernets:
    enp2s0:
      dhcp4: true
      optional: true
    enp3s0:
      dhcp4: true
      optional: true
  version: 2

netplan --debug apply

** (generate:2996): DEBUG: 01:14:58.624: starting new processing pass
** (generate:2996): DEBUG: 01:14:58.624: We have some netdefs, pass them through a final round of validation
** (generate:2996): DEBUG: 01:14:58.624: enp2s0: setting default backend to 1
** (generate:2996): DEBUG: 01:14:58.624: Configuration is valid
** (generate:2996): DEBUG: 01:14:58.624: enp3s0: setting default backend to 1
** (generate:2996): DEBUG: 01:14:58.624: Configuration is valid
** (generate:2996): DEBUG: 01:14:58.625: Generating output files..
** (generate:2996): DEBUG: 01:14:58.625: openvswitch: definition enp2s0 is not for us (backend 1)
** (generate:2996): DEBUG: 01:14:58.625: NetworkManager: definition enp2s0 is not for us (backend 1)
** (generate:2996): DEBUG: 01:14:58.625: openvswitch: definition enp3s0 is not for us (backend 1)
** (generate:2996): DEBUG: 01:14:58.625: NetworkManager: definition enp3s0 is not for us (backend 1)
DEBUG:netplan generated networkd configuration changed, reloading networkd
** (process:2994): DEBUG: 01:14:59.102: starting new processing pass
** (process:2994): DEBUG: 01:14:59.103: We have some netdefs, pass them through a final round of validation
** (process:2994): DEBUG: 01:14:59.103: enp2s0: setting default backend to 1
** (process:2994): DEBUG: 01:14:59.103: Configuration is valid
** (process:2994): DEBUG: 01:14:59.103: enp3s0: setting default backend to 1
** (process:2994): DEBUG: 01:14:59.103: Configuration is valid
DEBUG:Merged config:
b''
DEBUG:no netplan generated NM configuration exists
** (process:2994): DEBUG: 01:14:59.122: starting new processing pass
** (process:2994): DEBUG: 01:14:59.122: We have some netdefs, pass them through a final round of validation
** (process:2994): DEBUG: 01:14:59.122: enp2s0: setting default backend to 1
** (process:2994): DEBUG: 01:14:59.122: Configuration is valid
** (process:2994): DEBUG: 01:14:59.122: enp3s0: setting default backend to 1
** (process:2994): DEBUG: 01:14:59.122: Configuration is valid
DEBUG:Merged config:
b''
DEBUG:Link changes: {}
DEBUG:netplan triggering .link rules for lo
DEBUG:netplan triggering .link rules for enp2s0
DEBUG:netplan triggering .link rules for enp3s0
** (process:2994): DEBUG: 01:14:59.420: starting new processing pass
** (process:2994): DEBUG: 01:14:59.420: We have some netdefs, pass them through a final round of validation
** (process:2994): DEBUG: 01:14:59.420: enp2s0: setting default backend to 1
** (process:2994): DEBUG: 01:14:59.420: Configuration is valid
** (process:2994): DEBUG: 01:14:59.420: enp3s0: setting default backend to 1
** (process:2994): DEBUG: 01:14:59.420: Configuration is valid
** (process:2994): DEBUG: 01:14:59.421: starting new processing pass
** (process:2994): DEBUG: 01:14:59.421: We have some netdefs, pass them through a final round of validation
** (process:2994): DEBUG: 01:14:59.421: enp2s0: setting default backend to 1
** (process:2994): DEBUG: 01:14:59.421: Configuration is valid
** (process:2994): DEBUG: 01:14:59.421: enp3s0: setting default backend to 1
** (process:2994): DEBUG: 01:14:59.421: Configuration is valid
DEBUG:Merged config:
b''

Yet when I reboot I still get Waiting for network to be configured when linux is booting and I have to wait for it to timeout still because enp2s0 is not connected.
Not to mention I also have /etc/systemd/network/80-can.network and /etc/netplan/80-can.network and it just completely ignores them. I feel like I am missing something really stupid.

IDX LINK   TYPE     OPERATIONAL SETUP      
  1 lo     loopback carrier     unmanaged
  2 enp2s0 ether    no-carrier  configuring
  3 enp3s0 ether    routable    configured 

3 links listed.

Edit: I am really struggling to not just install Debian to avoid these ‘fixing something that isn’t broken’ type of issues Canonical is notorious for doing.

I still don’t know why the optional parameter does not work. I’ll just systemctl mask systemd-networkd-wait-online.service I guess.
This is the answer to my original question. Just having a full conversation with myself I guess. At least it is documented somewhere.

sudo nano /etc/udev/rules.d/99-persistent-network.rules

SUBSYSTEM==“net”, ACTION==“change|add”, KERNEL==“can0” ATTR{tx_queue_len}=“128”

save exit

sudo nano /etc/systemd/network/80-can0.network

[Match]
Name=can0

[CAN]
BitRate=500K

save exit

Then reboot

You are supposed to be able to…
sudo nano /etc/systemd/network/80-can0.link

[Match]
Name=can0

[Link]
TransmitQueueLength=128

… but for some reason it does not work. May be a bug or not fully implemented yet in the version Ubuntu is currently serving.

1 Like