summaryrefslogtreecommitdiff
path: root/misc/ssh-rt.sh
diff options
context:
space:
mode:
Diffstat (limited to 'misc/ssh-rt.sh')
-rwxr-xr-xmisc/ssh-rt.sh37
1 files changed, 37 insertions, 0 deletions
diff --git a/misc/ssh-rt.sh b/misc/ssh-rt.sh
new file mode 100755
index 0000000..b26e2aa
--- /dev/null
+++ b/misc/ssh-rt.sh
@@ -0,0 +1,37 @@
+#!/bin/bash
+echo "$@" | awk --non-decimal-data '
+BEGIN { iface="eth1"; exitcode=1; }
+
+/^172\./ {
+ print "L IPv6 de management des routeurs n est pas fonction de L IPv4 en 172";
+}
+
+/^185\.131\.4([01])\.([0-9]{1,3})$/ {
+ match($0, /^185\.131\.4([01])\.([0-9]{1,3})$/, arr);
+ printf "ssh root@fe80::%x:%x%%%s\n", arr[1], lshift(arr[2],8), iface;
+ exitcode=0;
+}
+
+/^2a03:a0a0:([0-9a-f]{0,4}:[0-9a-f]{0,4}):?:?.*$/ {
+ match($0, /^2a03:a0a0:([0-9a-f]{0,4}:[0-9a-f]{0,4}):?:?.*$/, arr);
+ printf "ssh root@fe80::%s%%%s\n", arr[1], iface;
+ exitcode=0;
+}
+
+/^..:..:..:..:..:..$/ {
+ match($0, /(..):(..):(..):(..):(..):(..)/, arr);
+ printf "ssh root@fe80::%x:%x:%x:%x%%%s\n",
+ or(lshift(xor("0x" arr[1], 2), 8), "0x" arr[2]),
+ or(lshift("0x" arr[3], 8), "0xff"),
+ or("0xfe00", "0x" arr[4]),
+ or(lshift("0x" arr[5],8),"0x" arr[6]),
+ iface;
+ exitcode=0;
+}
+
+END { exit exitcode; }
+'
+
+if [ $? -ne 0 ]
+then echo "Usage : $0 (<ip4pub>|<ip6pub>|<mac>)"
+fi