#!/usr/bin/env bash set -eu if [[ -n "${TINC_DEBUG+1}" ]]; then set -x fi SCRIPT_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd) source "$SCRIPT_DIR/lib/core.bash" source "$SCRIPT_DIR/lib/cidr.bash" source "$SCRIPT_DIR/lib/dhcp.bash" source "$SCRIPT_DIR/lib/ip.bash" source "$SCRIPT_DIR/lib/mac.bash" source "$SCRIPT_DIR/lib/route.bash" #disable_ipv6_privacy() { # local interface=$1 # if [[ "$OSTYPE" == "linux-gnu" ]]; then # sysctl -w "net.ipv6.conf.${interface}.use_tempaddr=0" # elif [[ "$OSTYPE" == "openbsd"* ]]; then # ifconfig "${interface}" -autoconfprivacy # elif has sysctl; then # sysctl -w net.inet6.ip6.use_tempaddr=0 # fi #} [ -z "${INTERFACE:-}" ] && die "no INTERFACE environment variable set" MAC_ADDRESS_FILE="${SCRIPT_DIR}/tinc-macaddr" LOCAL_HOOK_FILE="${SCRIPT_DIR}/tinc-up.local" TINCRC="${SCRIPT_DIR}/tincrc" MAC_ADDRESS="" SUBNET="" DHCP="yes" ULA_IP6_TEMPLATE="fdc0:4992:6a6d:a:%x%x:%x%x::1" PUBLIC_IP6_PREFIX="2a01:4f8:210:31fd" PUBLIC_IP6_TEMPLATE="$PUBLIC_IP6_PREFIX:1:%x%x:%x%x:1" source "${TINCRC}" || true if [ -z "$MAC_ADDRESS" ]; then echo "${MAC_ADDRESS_FILE} does not exists. Generate it with ./tinc-generate-mac..." "$DIR/tinc-generate-mac" source "$TINCRC" fi set_mac "$INTERFACE" "$MAC_ADDRESS" public_ip6="$(format_ip6_from_mac $PUBLIC_IP6_TEMPLATE $MAC_ADDRESS)" ula_ip6="$(format_ip6_from_mac $ULA_IP6_TEMPLATE $MAC_ADDRESS)" add_ip6 "$INTERFACE" "$public_ip6" "80" add_ip6 "$INTERFACE" "$ula_ip6" "64" add_route6 "$INTERFACE" "fc00::" "fe80::3" "7" add_route6 "$INTERFACE" "$PUBLIC_IP6_PREFIX::" "fe80::3" "64" if [ -n "$SUBNET" ]; then IFS=' ' read ip netmask <<< "$SUBNET" [ -z "$ip" ] && die "no ip set in SUBNET" [ -z "$netmask" ] && die "no netmask set in SUBNET" add_ip4 "$INTERFACE" "$ip" "$netmask" fi if [ "${DHCP,,}" = "yes" ]; then start_dhcp "$INTERFACE" fi [ -x "${SCRIPT_DIR}/tinc-up.local" ] && "${SCRIPT_DIR}/tinc-up.local" || true