1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
from pyroute2 import NDB
from pyroute2.common import uifname
with NDB() as ndb:
# dummy, bridge and bond interfaces are created in the
# same way
#
# uifname() function is used here only to generate a
# unique name of the interface for the regression testing,
# you can pick up any name
#
ifname = uifname()
(
ndb.interfaces.create(kind='dummy', ifname=ifname, state='up')
.set('state', 'up')
.set('address', '00:11:22:33:44:55')
.commit()
)
print(ndb.interfaces[ifname].show('json'))
(
ndb.interfaces[ifname]
.remove()
.commit()
)
|