Netplan Event Support

Asked by Chris Wyse

Hi,

We're working on software that needs to update the network configuration on the fly. The system runs on Linux and uses systemd-networkd. We're trying to determine the best way to control the network devices on the system.

An initial suggestion was made to make the application the 'source of truth' and it would rewrite the systemd-networkd configuration files. I'd much prefer to modify a yaml file - netplan seems like a better method (for multiple reasons).

My question is about the event support. It looks like netplan uses some scripting (ifupd.d/ifdown.d) to handle network events. I'd like some type of API. For instance, I'd like my application to subscribe to netplan network interface events. I'm wondering if anything is available or in the works.

Regardless, what's the conventional wisdom on the best way to write an application the controls multiple network interfaces?

Thanks.

Chris Wyse

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu nplan Edit question
Assignee:
No assignee Edit question
Solved by:
Chris Wyse
Solved:
Last query:
Last reply:
Revision history for this message
actionparsnip (andrew-woodhead666) said :
#1

You can update the netplan files and run:

sudo netplan apply

You could also use the 'ip' and 'route' commands to set network paramaters on the fly but they will be lost at reboot unless you populate the netplan configuration files. If you are using 16.04 then you will need to use the /etc/network/interfaces file to set IP addressing that will survive a reboot.

Revision history for this message
actionparsnip (andrew-woodhead666) said :
#2

What is the output of:

lsb_release -a; uname -a

Thanks

Revision history for this message
Chris Wyse (wysec) said :
#3

Hi - Thanks for your responses.

We create the Linux distribution with the Yocto build system, so there is no lsb_release file. It will be running on an embedded Intel Atom core on a high end router.

Regarding the netplan apply, we could certainly have the application write out a new configuration, then call netplan apply. My question was really more about what's the best way to do it. For example, the program that we're writing will need to dynamically reconfigure ports. One ideal situation would be to link with the netplan library (-lnetplan if there were a library). Then the application might make API calls similar to the following:
   netplan_configure_port(...)
   netplan_apply()

Another critical API call might be:
   netplan_subscribe_port(ifup_callback, ifdown_callback, ...)

This avoids running a bash or python shell, and tightly integrates the code with netplan.

So I'm wondering what other people are doing for these types of applications, and looking for suggestions.

Revision history for this message
actionparsnip (andrew-woodhead666) said :
#4

What is the output of:

cat /etc/issue

Thanks

Revision history for this message
actionparsnip (andrew-woodhead666) said :
#5

This is Ubuntu support only. I suggest you post elsewhere. There are distribution agnostic forums. This is not one of them. Sorry

Revision history for this message
Chris Wyse (wysec) said :
#6

OK. I thought this was a general netplan forum, not Ubuntu specific. I knew I was on the Ubuntu site, but Canonical seems to own/maintain the package.

Not sure what forum is available. Probably better off using systemd until this gets more mature.

Thanks for your help.

Revision history for this message
actionparsnip (andrew-woodhead666) said :
#7

This is specifically Ubuntu. I'm sure there will be a netplan forum somewhere