Skip to content

Instantly share code, notes, and snippets.

@mapi68
Last active November 14, 2023 05:18
Show Gist options
  • Save mapi68/f6159b3d936afdbead2bf6ce39214bac to your computer and use it in GitHub Desktop.
Save mapi68/f6159b3d936afdbead2bf6ce39214bac to your computer and use it in GitHub Desktop.
This Bash script prompts the user to input a MAC address and then converts it into an IPv6 address using a custom function
#!/bin/bash
tput clear
echo
echo "********************* Hello $USER! *********************"
echo
echo "Please paste MAC address that you want to convert into IPv6:"
read A
ipv6() {
IFS=':'; set $1; unset IFS
echo
echo "IPv6 address is: fe80::$(printf %02x $((0x$1 ^ 2)))$2:${3}ff:fe$4:$5$6"
echo
}
ipv6 $A
echo
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment