Python的pyroute2网络模块
Pyroute2是纯python的netlink库,只需要python标准库不需要其他第三方的库。 最常用的是监控事件,例如监控磁盘空间事件: from pyroute2 import DQuotSocket with DQuotSocket() as ds: for message in ds.get(): print(message) 或者监控IP路由 from pyroute2 import IPRoute with IPRoute() as ipr: # With IPRoute objects you have to call bind() manually ipr.bind() for message in ipr.get(): print(message) 1. IPRoute配置网络 from pyroute2 import IPRoute ipr = IPRoute() # create an interface ipr.link('add', ifname='brx', kind='bridge') # lookup the index dev = ip...