How to get interface names from kernel using pyroute2 IPDB function?

12 views
Skip to first unread message

rishi narian

unread,
Feb 13, 2018, 5:00:11 PM2/13/18
to pyroute2-dev

Hello all,


I would like to fetch the interface names (like eth0..etc) which are configured in kernel using pyroute2 and IPDB functions.


import pyroute2

ipdb=pyroute2.IPDB()
   print ipdb.interfaces


The above code is displaying full information. But I would need only the interfaces names.


Desired Output as:

eth0 eth1 ...


I don't want to use IPRoute() function to fetch. I want to use IPDB to fetch the information.


Thanks

rishi

Peter Saveliev

unread,
Feb 13, 2018, 5:48:45 PM2/13/18
to rishi narian, pyroute2-dev

from pyroute2 import IPDB

with IPDB() as ipdb:
    print(" ".join(ipdb.by_name.keys()))

--
You received this message because you are subscribed to the Google Groups "pyroute2-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyroute2-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages