add tinc-generate-mac tinc-generate-macc

This commit is contained in:
Jörg Thalheim 2014-12-25 21:47:07 +01:00
parent 4d8885b590
commit 4e57a1ceb6
2 changed files with 22 additions and 1 deletions

2
.gitignore vendored
View File

@ -1,4 +1,4 @@
rsa_key.priv
ecdsa_key.priv
tinc-up
tinc.conf
tinc-macaddr

21
tinc-generate-mac Executable file
View File

@ -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