M BUZZ CRAZE NEWS
// general

How to automatically bring up CAN interface in Ubuntu 17.10

By Joseph Russell

In previous versions of Ubuntu I have been using this script to automatically bring up an network interface for a USB to CAN bridge device, whenever the device is plugged in:

$ cat /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback
allow-hotplug can0
iface can0 can static bitrate 250000 up /sbin/ip link set $IFACE down up /sbin/ifconfig $IFACE txqueuelen 20000 up /sbin/ip link set $IFACE type can bitrate 250000 restart-ms 10 up /sbin/ip link set $IFACE up

This script does not work any more because Ubuntu 17.10 is not using ifupdown and consequently /etc/network/interfaces file is no longer used. My question is, how do I rewrite this script using the new netplan configuration system?

In particular, what is critical for functioning of my script above is the line allow-hotplug can0 which detects when the can0 interface becomes available (shortly after plugging the device into USB port). Can I do this using the new configuration system?

2 Reset to default

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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