diff --git a/.gitignore b/.gitignore index 0c98643..0b20416 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ rsa_key.priv ecdsa_key.priv -tinc-up tinc.conf +tinc-macaddr diff --git a/tinc-generate-mac b/tinc-generate-mac new file mode 100755 index 0000000..c094dfd --- /dev/null +++ b/tinc-generate-mac @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +set -eu + +DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd) +MACADDR_FILE="$DIR/tinc-macaddr" +if [ -e "$MACADDR_FILE" ]; then + echo "Skip generating MAC: '$MACADDR_FILE' does already exists." + exit 1 +else + # Locally Administered Address Ranges: + #x2-xx-xx-xx-xx-xx + #x6-xx-xx-xx-xx-xx + #xA-xx-xx-xx-xx-xx + #xE-xx-xx-xx-xx-xx + # Replacing x with any hex value. + printf '02:1F:%02X:%02X:%02X:%02X\n' \ + $[RANDOM%256] $[RANDOM%256] $[RANDOM%256] $[RANDOM%256] \ + > "$MACADDR_FILE" +fi +cat $MACADDR_FILE