Page MenuHomePhabricator

Create generic abstraction for configuring interfaces e.g. IP address
Closed, ResolvedPublicFEATURE REQUEST


Right now there is no generic way in configuring an interface IP address from within a Python script.

The only occurance right now is in

def add_addr(intf, addr):
  # see
  ret =['ip a a dev ' + intf + ' ' + addr + ' &>/dev/null'], shell=True)
  sl.syslog(sl.LOG_NOTICE, "ip a a dev " + intf + " " + addr)

def del_addr(intf, addr):
  ret =['ip a d dev ' + intf + ' ' + addr + ' &>/dev/null'], shell=True)
  sl.syslog(sl.LOG_NOTICE, "ip a d dev " + intf + " " + addr)

We need to make this available in the generic vyos python library or a proper 3rd party library to be reusable from within multiple scripts.


  • add IPv4/IPv6 interface address
  • remove IPv4/IPv6 interface address
  • add DHCP/DHCPv6 interface address
  • remove DHCP/DHCPv6 interface address
  • add interface description /sys/class/net/eth0/ifalias


Difficulty level
Hard (possibly days)
Why the issue appeared?
Will be filled on close
Is it a breaking change?
Behavior change

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes
Dmitry added a subscriber: Dmitry.Aug 26 2019, 6:49 PM
c-po added a comment.Aug 28 2019, 8:53 AM

Pyroute2 states:

One of the major issues with IPDB is its memory footprint. It proved not to be suitable for environments with thousands of routes or neighbours. Being a design issue, it could not be fixed, so a new module was started, NDB, that aims to replace IPDB. IPDB is still more feature rich, but NDB is already more fast and stable.

IPDB is the yet most feature complete interface. NDB (which is only available in recent versions installed through e.g. pip) is only supported for "developers" as it lacks a lot of features and the documentation is not really a helper.

Which way to go? Continue on our own abstraction?

Out own implementation should at least support:

  • a general interface class
    • capable of talking to sysfs for ARP manipulation stuff
    • add interface addresses, dhcp and dhcpv6
    • pass options to dhcp client
    • create vif-s and vif interfaces
    • support transactions (less system I/O and configuration changes)
  • a derived bridge class from the generic interface class
    • to add/delete bridges
    • add/remove bridge members
    • change bridge port stp values
    • configure bridge parameters
  • a derived bond class from the generic interface class
    • to add/delete bonds
    • add remove bond members
    • change bond modes/hash
c-po added a comment.Aug 28 2019, 9:00 AM

@hagbard during some tests with the bridge interface ( I noticed the following:

  • Interface.add_dhcpv4() works (I would call it dhcp anyway as this is the standard)
  • Interface.del_dhcpv4() does not remove the dhclient process
  • Interface.add_dhcpv6() does not spawn a new dhclientv6 process.

I tend to not spawn processes by hand as you do I rather use start-stop-daemon for it and also for removal see:

c-po added a comment.Aug 31 2019, 11:14 AM

DHCP + DHCPv6 working now in bridge interface.

c-po claimed this task.Aug 31 2019, 11:14 AM
c-po raised the priority of this task from Normal to High.
c-po set Is it a breaking change? to Behavior change.

@c-po sorry was camping in a remote area without cell coverage. What's the way we go then? I'll look tomorrow, eventually Tuesday next week into the dhcp stuff.

c-po added a comment.Sep 1 2019, 8:03 AM

@hagbard not a problem. Looks like we now go the "our own lib" way as pyroute2 has some flaws. DHCP is already fix and I continue improve the script and remove redundant code before it will be extended to support VLAN/bonding.

c-po closed this task as Resolved.Sep 4 2019, 2:39 PM
c-po moved this task from Need Triage to Finished on the VyOS 1.3 Equuleus board.Oct 13 2019, 3:08 PM