Skip to content

Instantly share code, notes, and snippets.

@cnf
Created February 9, 2016 18:02
Show Gist options
  • Save cnf/5fbb673a3bc27f9b0d28 to your computer and use it in GitHub Desktop.
Save cnf/5fbb673a3bc27f9b0d28 to your computer and use it in GitHub Desktop.
#!/bin/sh
# Frank Rosquin <frank.rosquin@gmail.com>
MAC=$1
echo "Calculating ipv6 for $MAC"
LEAD=`echo $MAC|awk -F':' '{ print $1}'`
FIXED=`echo $MAC|awk -F':' '{ print tolower($2":"$3":"$4":"$5":"$6)}'`
# TODO: TOGGLE this
SIGNIF=`printf "%02x" $((0x$LEAD | 0x02))`
echo $SIGNIF
# SIGNIF=`printf "%02x" $((0x$SIGNIF ^ 0x02))`
NMAC="$SIGNIF:$FIXED"
echo $SIGNIF
LEAD=`echo $NMAC|awk -F':' '{ print $1$2":"$3}'`
END=`echo $NMAC|awk -F':' '{ print $4":"$5$6}'`
echo "Connect to: fe80::${LEAD}ff:fe${END}%<device>"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment