Skip to content
Peter V. Saveliev edited this page Mar 23, 2020 · 3 revisions
>>> ndb.addresses.dump()                                                                                                                                                                                                                  
('localhost', 0, 2, 8, 128, 254, 1, '127.0.0.1', '127.0.0.1', 'lo', None, None, None, 128)
('localhost', 0, 2, 24, 128, 0, 3, '10.4.0.10', '10.4.0.10', 'eth0', '10.4.0.255', None, None, 128)
('localhost', 0, 2, 24, 0, 0, 4, '192.168.122.68', '192.168.122.68', 'eth1', '192.168.122.255', None, None, 0)
('localhost', 0, 10, 128, 128, 254, 1, '::1', '', None, None, None, None, 128)
('localhost', 0, 10, 64, 128, 253, 3, 'fe80::5054:ff:fe22:a1b7', '', None, None, None, None, 128)
('localhost', 0, 10, 64, 128, 253, 4, 'fe80::5054:ff:fef7:2994', '', None, None, None, None, 128)

>>> ndb.interfaces.dump()                                                                                                                                                                                                                 
('localhost', 0, 0, 772, 1, 65609, 0, '00:00:00:00:00:00', '00:00:00:00:00:00', 'lo', 65536, None, 'noqueue', None, 1000, 0, None, None, None, 0, None, 0, 1, 1, 1, 0, None, None, 0, 65535, 65536, 0, 0, 'up', None, None)
('localhost', 0, 0, 769, 2, 128, 0, '00:00:00:00:00:00', '00:00:00:00:00:00', 'ip6tnl0', 1452, 0, 'noop', None, 1000, 0, None, None, None, 0, None, 0, 1, 1, 1, 0, None, None, 0, 65535, 65536, 0, 0, 'down', 'ip6tnl', None)
('localhost', 0, 0, 1, 3, 69699, 0, '52:54:00:22:a1:b7', 'ff:ff:ff:ff:ff:ff', 'eth0', 1500, None, 'pfifo_fast', None, 1000, 0, None, None, None, 0, None, 0, 1, 1, 1, 2, None, None, 0, 65535, 65536, 1, 1, 'up', None, None)
('localhost', 0, 0, 1, 4, 69699, 0, '52:54:00:f7:29:94', 'ff:ff:ff:ff:ff:ff', 'eth1', 1500, None, 'pfifo_fast', None, 1000, 0, None, None, None, 0, None, 0, 1, 1, 1, 2, None, None, 0, 65535, 65536, 1, 1, 'up', None, None)
('localhost', 0, 0, 1, 6, 4098, 0, 'c6:ac:a4:93:30:2b', 'ff:ff:ff:ff:ff:ff', 'br0', 1500, None, 'noop', None, 1000, 0, None, None, None, 0, None, 0, 1, 1, 0, 1, None, None, 0, 65535, 65536, 0, 1, 'down', 'bridge', None)
('localhost', 0, 0, 1, 7, 5122, 0, 'ce:12:07:b1:e0:89', 'ff:ff:ff:ff:ff:ff', 'bond0', 1500, None, 'noop', None, 1000, 0, None, None, None, 0, None, 0, 16, 16, 0, 1, None, None, 0, 65535, 65536, 0, 1, 'down', 'bond', None)
('localhost', 0, 0, 1, 1044, 130, 0, 'e6:47:13:82:30:9a', 'ff:ff:ff:ff:ff:ff', 'dummy0', 1500, None, 'noop', None, 1000, 0, None, None, None, 0, None, 0, 1, 1, 1, 0, None, None, 0, 65535, 65536, 0, 0, 'down', 'dummy', None)
('localhost', 0, 0, 778, 578, 128, 0, '00:00:00:00:08:00', '00:00:00:00:c4:00', 'gre0', 1476, 0, 'noop', None, 1000, 0, None, None, None, 0, None, 0, 1, 1, 1, 0, None, None, 0, 65535, 65536, 0, 0, 'down', 'gre', None)
('localhost', 0, 0, 1, 579, 4098, 0, '00:00:00:00:00:00', 'ff:ff:ff:ff:ff:ff', 'gretap0', 1462, 0, 'noop', None, 1000, 0, None, None, None, 0, None, 0, 1, 1, 1, 0, None, None, 0, 65535, 65536, 0, 0, 'down', 'gretap', None)
('localhost', 0, 0, 1, 580, 4098, 0, '00:00:00:00:00:00', 'ff:ff:ff:ff:ff:ff', 'erspan0', 1450, 0, 'noop', None, 1000, 0, None, None, None, 0, None, 0, 1, 1, 1, 0, None, None, 0, 65535, 65536, 0, 0, 'down', 'erspan', None)
('localhost', 0, 0, 823, 587, 128, 0, '00:00:00:00:00:00', '00:00:00:00:00:00', 'ip6gre0', 1448, 0, 'noop', None, 1000, 0, None, None, None, 0, None, 0, 1, 1, 1, 0, None, None, 0, 65535, 65536, 0, 0, 'down', 'ip6gre', None)
('localhost', 0, 0, 768, 142, 128, 0, '00:00:00:00:08:00', '00:00:00:00:c4:00', 'ip_vti0', 1480, 0, 'noop', None, 1000, 0, None, None, None, 0, None, 0, 1, 1, 1, 0, None, None, 0, 65535, 65536, 0, 0, 'down', 'vti', None)
('localhost', 0, 0, 769, 145, 128, 0, '00:00:00:00:00:00', '00:00:00:00:00:00', 'ip6_vti0', 1332, 0, 'noop', None, 1000, 0, None, None, None, 0, None, 0, 1, 1, 1, 0, None, None, 0, 65535, 65536, 0, 0, 'down', 'vti6', None)

>>> (ndb
     .addresses
     .dump()
     .join(ndb.interfaces.dump(),
           condition=lambda l, r: l.index == r.index,
           prefix='r_')
     .select('r_ifname', 'address', 'prefixlen'))
('lo', '127.0.0.1', 8)
('eth0', '10.4.0.10', 24)
('eth1', '192.168.122.68', 24)
('lo', '::1', 128)
('eth0', 'fe80::5054:ff:fe22:a1b7', 64)
('eth1', 'fe80::5054:ff:fef7:2994', 64)

>>> (ndb
     .addresses
     .dump()
     .join(ndb.interfaces.dump(),
           condition=lambda l, r: l.index == r.index,
           prefix='r_')
     .select('r_ifname', 'address', 'prefixlen')
     .format('json'))
[
    {
        "address": "127.0.0.1",
        "prefixlen": 8,
        "r_ifname": "lo"
    },
    {
        "address": "10.4.0.10",
        "prefixlen": 24,
        "r_ifname": "eth0"
    },
    {
        "address": "192.168.122.68",
        "prefixlen": 24,
        "r_ifname": "eth1"
    },
    {
        "address": "::1",
        "prefixlen": 128,
        "r_ifname": "lo"
    },
    {
        "address": "fe80::5054:ff:fe22:a1b7",
        "prefixlen": 64,
        "r_ifname": "eth0"
    },
    {
        "address": "fe80::5054:ff:fef7:2994",
        "prefixlen": 64,
        "r_ifname": "eth1"
    }
]
Clone this wiki locally