From 98c72afe7246149e4cf9262da39e0a24ad62a9ad Mon Sep 17 00:00:00 2001 From: Paul Larson Date: Fri, 13 Sep 2019 12:37:39 -0500 Subject: Attempt to get the gateway ip address for the interface and ping it before ARPing for available IPs to use in gateway_ping_test --- bin/gateway_ping_test | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'bin') diff --git a/bin/gateway_ping_test b/bin/gateway_ping_test index 914792c..7bac0f8 100755 --- a/bin/gateway_ping_test +++ b/bin/gateway_ping_test @@ -133,6 +133,18 @@ def get_host_to_ping(interface=None, verbose=False, default=None): stderr=subprocess.STDOUT) except subprocess.CalledProcessError: pass + # Try to get the gateway address for the interface from networkctl + cmd = 'networkctl status --no-pager --no-legend {}'.format(interface) + try: + output = subprocess.check_output(cmd, shell=True) + for line in output.decode(sys.stdout.encoding).splitlines(): + key, val = line.strip().split(':', maxsplit=1) + if key == "Gateway": + subprocess.check_output(["ping", "-q", "-c", "1", val], + stderr=subprocess.STDOUT) + break + except subprocess.CalledProcessError: + pass ARP_POPULATE_TRIES = 10 num_tries = 0 while num_tries < ARP_POPULATE_TRIES: -- cgit v1.2.3