Dual WAN DynDNS

Home Page Forums Network Management ZeroShell Dual WAN DynDNS

This topic contains 1 reply, has 0 voices, and was last updated by  dgoiko 4 years, 4 months ago.

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #44090

    dgoiko
    Member

    Hello.

    I was wondering if there’s a way to configure two DynDNSs on my zeroshell and make them travel through different WAN interfaces in the load balancer.

    The dyndnsclient has the -interface option, so this shouldn’t be hard to achieve, however, I cannot find the option in zeroshell. Am I missing something?

    By the way, I found this script, but I believe this will only worl with PPPoE or any other way which puts the public IP directly into the interface:


    # Bash script: DynDNS-Cron
    # Script para resolver dos DynDNS distintos, uno por cada interfaz.
    #!/bin/sh
    . /etc/kerbynet.conf
    INTERFACE="$1"
    HOSTNAME="$2"
    AUTH="$3"
    INTERVAL="$4"

    ERROR="/tmp/dyndns.$INTERFACE.err"
    RESULT="/tmp/dyndns.$INTERFACE.out"
    LAST_IP="X"

    while true ; do
    sleep $INTERVAL
    NEW_IP=`ip addr show $INTERFACE 2> /dev/null | grep inet | awk '{ sub(///, " ") ; print $2 }'`
    if [ -n "$NEW_IP" -a "$NEW_IP" != "$LAST_IP" ]; then
    DNS_IP=`host $HOSTNAME 2> /dev/null | cut -d" " -f4`
    if [ "$NEW_IP" != "$DNS_IP" ]; then
    logger -t DDNS "DynDNS change required for internet $INTERFACE ($HOSTNAME)"
    logger -t DDNS "==> new ip: $NEW_IP - old ip: $DNS_IP"
    if wget -q -t 3 -w 20 if wget -t 3 -w 20 -o "$ERROR" -O "$RESULT" "http://${AUTH}@members.dyndns.org/nic/update?hostname=${HOSTNAME}&myip=${NEW_IP}&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG"; then
    logger -t DDNS "==> `cat $RESULT`"
    else
    logger -t DDNS "ERROR:"
    grep -v " => " "$ERROR" | logger -t DDNS
    fi
    sleep 60
    fi
    else
    LAST_IP="$NEW_IP"
    fi
    done

    By the way, by executing this command I could get the correct it to place into $LAST_IP:

     curl -s checkip.dyndns.org | cut -d ' ' -f 6 | cut -d '< ' -f 1 

    however, I'm not able to tell curl the interface it will go out by, so the IP will belong to a random interface.

    Keep in mind that both dyndns use the same service, so I cannot make a firewall rule to send the traffic to checkip.dyndns.org using one interface because i'm going to need it to go by the other interface later

    [edit2]
    I gave it some thought and found out that I can get the resolved IP for checkip.dyndns.org using:

     ping -c1 -t1 -W0 checkip.dyndns.org 2>&1 | tr -d '():' | awk '/^PING/{print $3}'

    I only have to add a balancing rule that redirects the traffic to that IP, do the check and then disable the rule. Does anyone know how to correctly making such a rule in zeroshell and make it appear in the webgui, just in case some rule is forgot behind.

    This would be the description of the rule if 216.146.43.70 is resolved for checkip.dyndns.org:

     MARK all opt -- in * out * 0.0.0.0/0 -> 216.146.43.70 MARK set 0x65
Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.