Unlike original ifupdown, all interface configuration is moved to external python modules. That includes inet, inet6 and dhcp configurations.
Addon modules are a nice way to add additional functionality to ifupdown2. Typically a new addon module will include support for a new network interface configuration which is not already supported by existing ifupdown2 addon modules.
ifupdown2 addon modules are written in python. python-ifupdown2 package comes with default addon modules. All addon modules are installed under /usr/share/ifupdownaddons directory.
The center of the universe for an addon module is the ‘class iface’ object exported by the python-ifupdown2 package.
The iface object is modeled after an iface entry in the user provided network configuration file (eg. /etc/network/interfaces). For more details see the api reference for the iface class.
ifupdown2 dynamically loads a python addon module. It expects the addon module to implement a few methods.
all addon modules must inherit from moduleBase class
the module must implement a class by the same name
the network interface object (class iface) and the operation to be performed is passed to the modules. Operation can be any of ‘pre-up’, ‘up’, ‘post-up’, ‘pre-down’, ‘down’, ‘post-down’, ‘query-check’, ‘query-running’. The module can choose to support a subset or all operations. In cases when the operation is query-check, the module must compare between the given and running state and return the checked state of the object in queryobjcur passed as argument to the run menthod.
python-ifupdown2 package also installs ifupdownaddons python package that contains helper modules for all addon modules.
see example address handling module /usr/share/ifupdownaddons/address.py