summaryrefslogtreecommitdiff
path: root/routers
diff options
context:
space:
mode:
authorGuillaume Mazoyer <respawneral@gmail.com>2014-08-06 01:14:32 +0200
committerGuillaume Mazoyer <respawneral@gmail.com>2014-08-06 01:14:32 +0200
commit8dc54b79e3125c1e59e9066afdcf0da8dcf5db8f (patch)
treec1d1b51c4be4e450226dcff25ca4d3cc752bee3e /routers
parent62026ca49b5bff063a06e3b49864947e65cea426 (diff)
Add ping/traceroute for FQDN on BIRD and Quagga.
Basically this can work with all Linux boxes. It gets A and AAAA records from DNS and decide if it can uses IPv6 or IPv4 to ping or to traceroute. IPv6 is always preferred of course.
Diffstat (limited to 'routers')
-rw-r--r--routers/bird.php24
-rw-r--r--routers/quagga.php24
2 files changed, 48 insertions, 0 deletions
diff --git a/routers/bird.php b/routers/bird.php
index 420cd42..a9fec59 100644
--- a/routers/bird.php
+++ b/routers/bird.php
@@ -67,6 +67,18 @@ final class Bird extends Router {
$commands[] = 'ping -A -c 10 '.$parameters;
} else if (match_ipv6($parameters)) {
$commands[] = 'ping6 -A -c 10 '.$parameters;
+ } else if (match_fqdn($parameters)) {
+ $ip_address = fqdn_to_ip_address($parameters);
+
+ if (!$ip_address) {
+ throw new Exception('No A or AAAA record found for '.$parameters);
+ }
+
+ if (match_ipv4($ip_address)) {
+ $commands[] = 'ping -A -c 10 '.$parameters;
+ } else if (match_ipv6($ip_address)) {
+ $commands[] = 'ping6 -A -c 10 '.$parameters;
+ }
} else {
throw new Exception('The parameter is not an IPv4/IPv6 address.');
}
@@ -77,6 +89,18 @@ final class Bird extends Router {
$commands[] = 'traceroute -4 -A -q1 -N32 -w1 -m15 '.$parameters;
} else if (match_ipv6($parameters)) {
$commands[] = 'traceroute -6 -A -q1 -N32 -w1 -m15 '.$parameters;
+ } else if (match_fqdn($parameters)) {
+ $ip_address = fqdn_to_ip_address($parameters);
+
+ if (!$ip_address) {
+ throw new Exception('No A or AAAA record found for '.$parameters);
+ }
+
+ if (match_ipv4($ip_address)) {
+ $commands[] = 'traceroute -4 -A -q1 -N32 -w1 -m15 '.$parameters;
+ } else if (match_ipv6($ip_address)) {
+ $commands[] = 'traceroute -6 -A -q1 -N32 -w1 -m15 '.$parameters;
+ }
} else {
throw new Exception('The parameter is not an IPv4/IPv6 address.');
}
diff --git a/routers/quagga.php b/routers/quagga.php
index 9f6426d..642ff4e 100644
--- a/routers/quagga.php
+++ b/routers/quagga.php
@@ -62,6 +62,18 @@ final class Quagga extends Router {
$commands[] = 'ping -A -c 10 '.$parameters;
} else if (match_ipv6($parameters)) {
$commands[] = 'ping6 -A -c 10 '.$parameters;
+ } else if (match_fqdn($parameters)) {
+ $ip_address = fqdn_to_ip_address($parameters);
+
+ if (!$ip_address) {
+ throw new Exception('No A or AAAA record found for '.$parameters);
+ }
+
+ if (match_ipv4($ip_address)) {
+ $commands[] = 'ping -A -c 10 '.$parameters;
+ } else if (match_ipv6($ip_address)) {
+ $commands[] = 'ping6 -A -c 10 '.$parameters;
+ }
} else {
throw new Exception('The parameter is not an IPv4/IPv6 address.');
}
@@ -72,6 +84,18 @@ final class Quagga extends Router {
$commands[] = 'traceroute -4 -A -q1 -N32 -w1 -m15 '.$parameters;
} else if (match_ipv6($parameters)) {
$commands[] = 'traceroute -6 -A -q1 -N32 -w1 -m15 '.$parameters;
+ } else if (match_fqdn($parameters)) {
+ $ip_address = fqdn_to_ip_address($parameters);
+
+ if (!$ip_address) {
+ throw new Exception('No A or AAAA record found for '.$parameters);
+ }
+
+ if (match_ipv4($ip_address)) {
+ $commands[] = 'traceroute -4 -A -q1 -N32 -w1 -m15 '.$parameters;
+ } else if (match_ipv6($ip_address)) {
+ $commands[] = 'traceroute -6 -A -q1 -N32 -w1 -m15 '.$parameters;
+ }
} else {
throw new Exception('The parameter is not an IPv4/IPv6 address.');
}