I think you need to remove "-v" at the end of line 75, otherwise it won't get connected. You can also simply remove the whole "grep -v 172.16.24.1" at the end.
IFACE=$(ip route show to match 172.16.24.1 2>/dev/null| grep -i 172.16.24.1 | cut -d ' ' -f3 | grep -v 172.16.24.1)