lixonet-ee/tinc/subnet-up.tmpl

21 lines
757 B
Cheetah
Raw Normal View History

2020-04-28 00:17:03 +00:00
#!/bin/ash
2023-04-12 21:36:42 -06:00
echo "Route up: \$SUBNET weight \$WEIGHT via \$NODE (\$REMOTEADDRESS:\$REMOTEPORT)"
2023-04-12 22:36:15 -06:00
nonMACChars=`echo \$SUBNET | tr -d "[:digit:]" | tr -d [:ABCDEFabcdef]`
2023-04-12 22:28:42 -06:00
macFile="/tmp/tinc_peer_mac_\$NODE"
if [ -z "\$nonMACChars" ]; then
# This subnet is a MAC
echo "\$SUBNET" > \$macFile
else
2023-04-12 22:46:39 -06:00
if echo "\$SUBNET" | grep -q -E ".+/32\$"; then
2023-04-12 22:41:29 -06:00
# This subnet is likely an IP address, add it to the ARP table
if test -f "\$macFile"; then
mac=`cat \$macFile`
2023-04-12 22:46:39 -06:00
address=`echo "\$SUBNET" | cut -d '/' -f 1`
echo "Mapping \$address <=> \$mac in ARP table"
arp -s "\$address" "\$mac"
2023-04-12 22:41:29 -06:00
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
2023-04-12 22:33:08 -06:00
fi
2023-04-12 22:28:42 -06:00
fi