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
.
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
.
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.