def _get_my_primary_interface():
gateways = ni.gateways()
assert 'default' in gateways, \
("No default gateway on host/container, "
"cannot determine primary interface")
default_gw_index = gateways['default'].keys()[0]
# gateways[default_gw_index] has the format (example):
# [('10.15.32.1', 'en0', True)]
interface_name = gateways[default_gw_index][0][1]
return interface_name
评论列表
文章目录