diff --git a/tinc/subnet-up.tmpl b/tinc/subnet-up.tmpl index 6f4969f..a805943 100644 --- a/tinc/subnet-up.tmpl +++ b/tinc/subnet-up.tmpl @@ -1,20 +1,17 @@ #!/bin/ash echo "Route up: \$SUBNET weight \$WEIGHT via \$NODE (\$REMOTEADDRESS:\$REMOTEPORT)" nonMACChars=`echo \$SUBNET | tr -d "[:digit:]" | tr -d [:ABCDEFabcdef]` -macFile="/tmp/tinc_peer_mac_\$NODE" +date=`date -u` + if [ -z "\$nonMACChars" ]; then # This subnet is a MAC - echo "\$SUBNET" > \$macFile + echo "\$NODE mac \$SUBNET \$WEIGHT \$REMOTEADDRESS:\$REMOTEPORT \$date" > /tmp/tinc_peer_mac_\$NODE_\$SUBNET else + # This subnet is an IP address if echo "\$SUBNET" | grep -q -E ".+/32\$"; then - # This subnet is likely an IP address, add it to the ARP table - if test -f "\$macFile"; then - mac=`cat \$macFile` - address=`echo "\$SUBNET" | cut -d '/' -f 1` - echo "Mapping \$address <=> \$mac in ARP table" - arp -s "\$address" "\$mac" - else - echo "[WARNING] No MAC known for node \$NODE, can't route \$SUBNET. This is only a problem if this is a remote route." - fi + address=`echo "\$SUBNET" | cut -d '/' -f 1` + echo "\$NODE ip \$SUBNET \$WEIGHT \$REMOTEADDRESS:\$REMOTEPORT \$date" > /tmp/tinc_peer_mac_\$NODE_\$address fi fi + +./check-node