2

Is there a way to configure netplan programmatically using a coding language (e.g. c or c++)?

What I mean is calling api functions instead of writing /etc/netplan/config.yaml and calling sudo netplan apply.

hudac
  • 2,584
  • 6
  • 34
  • 57
  • You could always write your own API that manipulates `/etc/netplan/config.yaml` and calls `sudo netplan apply`. – h0r53 Jan 13 '21 at 15:19

1 Answers1

2

netplan can be accessed via d-bus (ubuntu manpage: https://manpages.ubuntu.com/manpages/hirsute/man8/netplan-dbus.8.html).

The idea is to connect your program to the d-bus and invoke the commands there.

Note that this requires root privileges and if you haven't programmed with a c++ d-bus lib this might take some time to understand everything (at least it took me some time ;) ). I would recommend d-feet if you want to check out the structure of the netplan d-bus interface.

molicious
  • 86
  • 1
  • 8