diff options
author | Guillaume Mazoyer <respawneral@gmail.com> | 2014-12-13 00:26:52 +0100 |
---|---|---|
committer | Guillaume Mazoyer <respawneral@gmail.com> | 2014-12-13 00:26:52 +0100 |
commit | 21cb7dd8a0fa4a87481506f08732865f763b94d4 (patch) | |
tree | 3912a4dd7ecd17b367a4cf2ff6a27320b232dadb /routers/cisco.php | |
parent | 464ae23f92b5056cc1dc1bf7bf701a58187447c3 (diff) |
Fix traceroute for Cisco when using 'source'.
On Cisco, when using traceroute 'source' option with a FQDN, you
need to explicitly specify if you want an IPv4 or an IPv6
traceroute. To fix this we try to resolve the given FQDN and then
pass the IPv4 or IPv6 address instead of the FQDN
Also make sure that the FQDN is used in the issued command. Do not
use the resolved IP anymore.
Diffstat (limited to 'routers/cisco.php')
-rw-r--r-- | routers/cisco.php | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/routers/cisco.php b/routers/cisco.php index 5a135c0..20592b6 100644 --- a/routers/cisco.php +++ b/routers/cisco.php @@ -44,8 +44,23 @@ final class Cisco extends Router { $traceroute = null; if (match_ipv4($destination) || match_ipv6($destination) || - match_fqdn($destination)) { + (match_fqdn($destination) && !$this->has_source_interface_id())) { $traceroute = 'traceroute '.$destination; + } else if (match_fqdn($destination)) { + $fqdn = $destination; + $destination = fqdn_to_ip_address($fqdn); + + if (!$destination) { + throw new Exception('No A or AAAA record found for '.$fqdn); + } + + if (match_ipv4($destination)) { + $traceroute = 'traceroute ip '.$fqdn; + } else if (match_ipv6($destination)) { + $traceroute = 'traceroute ip6 '.$fqdn; + } else { + throw new Exception('The parameter does not resolve to an IPv4/IPv6 address.'); + } } else { throw new Exception('The parameter is not an IPv4/IPv6 address or a FQDN.'); } |