diff options
author | Ludovic Pouzenc <ludovic@pouzenc.fr> | 2016-08-28 09:26:50 +0200 |
---|---|---|
committer | Ludovic Pouzenc <ludovic@pouzenc.fr> | 2016-08-28 09:26:50 +0200 |
commit | 6fef3e053a834570e94e921552b69a4aff2a0230 (patch) | |
tree | e98511a059ee69ea4d9a6668280a3cd080f9b532 /misc | |
parent | 524c912d70cf0e33b1d4441081e36ead774d97dc (diff) | |
download | chd_gestion-6fef3e053a834570e94e921552b69a4aff2a0230.zip chd_gestion-6fef3e053a834570e94e921552b69a4aff2a0230.tar.gz chd_gestion-6fef3e053a834570e94e921552b69a4aff2a0230.tar.bz2 |
misc scripts: ssh-rt.sh derivate fe80 link-local IP from other IP(4/6) or mac
This is used for remote upgrade OpenWRT routers accross our net
Diffstat (limited to 'misc')
-rwxr-xr-x | misc/ssh-rt.sh | 37 |
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 |