Page MenuHomeVyOS Platform

WAN Load Balancing Issues
Open, NormalPublicBUG

Description

The document https://docs.vyos.io/en/1.5/configuration/loadbalancing/wan.html states that there are two environment variables available for scripts. However, I tried using WLB_INTERFACE_NAME in a script and the script read WLB_INTERFACE_NAME as blank.

The document indicates that you only need to provide the full path if the script is not in /config/scripts, however, if you only provide the name it errors stating the script does not exist even though it is in /config/scripts.

Ping tests fail on interfaces that are not the selected default gateway. An oder version of the document provided above states that static routes should be provided for the targets. This is an issue because it means that when the interface for the static route is down no device can reach that IP though it's available through another interface. A solution is to setup local route policies for each WAN interface. This ensures that if the source specified is the the IP on that WAN it the traffic will leave that gateway.

set protocols static table 102 route 0.0.0.0/0 dhcp-interface bond0.102
set policy local-route rule 102 source address 192.168.1.0/24
set policy local-route rule 102 set table 102

There are two issues with this setup.

  1. There is no option to select the interface IP or subnet for the source address from DHCP like you can set the next-hop to use the dhcp interfaces provided next-hop.
  2. The ping tests for wan load balance do not set the source IP for the interface being tested. I created the following script and have a copy for each wan interface to run the ping sourcing the dhcp assigned IP. If the ping tests fails it also releases and renews the DHCP lease. This is a good option to have for DHCP interfaces outside of wan load balancing where issues can arise that will not bounce the port on VyOS router so detection needs to happen another way.
#!/bin/bash

WLB_INTERFACE_NAME='bond0.101'
WLB_ICMP_COUNT='4'
WLB_TEST_HOSTS=(1.0.0.1 1.1.1.1 4.2.2.1 4.2.2.2 4.2.2.3 4.2.2.4 8.8.4.4 8.8.8.8)

WLB_INTERFACE_IP="$(ip -4 addr show dev "${WLB_INTERFACE_NAME}" | awk '$1 == "inet" && $2 ~ /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\/([0-9]|[12][0-9]|3[0-2])$/ && /dynamic/ {print $2}' | cut -d/ -f1 | head -1)"

WLB_TESTS_FUN ()
{
    WLB_TEST_HOST_ICMP_EXIT_CODES=()
    if [ "${#WLB_TEST_HOSTS[@]}" -gt '0' ]
      then
        for WLB_TEST_HOST in ${WLB_TEST_HOSTS[@]}
          do
            /usr/bin/ping -q ${WLB_TEST_HOST} -I ${WLB_INTERFACE_IP} -c ${WLB_ICMP_COUNT}
            WLB_TEST_HOST_ICMP_EXIT_CODE="$?"
            if [ "${WLB_TEST_HOST_ICMP_EXIT_CODE}" -gt '0' ]
              then
                WLB_TEST_HOST_ICMP_EXIT_CODES=(${WLB_TEST_HOST_ICMP_EXIT_CODES[@]} ${WLB_TEST_HOST_ICMP_EXIT_CODE})
            fi
        done
    fi
}

WLB_TESTS_FUN

if [ "${#WLB_TEST_HOSTS[@]}" -gt "${#WLB_TEST_HOST_ICMP_EXIT_CODES[@]}" ]
  then
    sleep 10
    exit 0
  else
        # Release the current DHCP lease.
        /sbin/dhclient -r "${WLB_INTERFACE_NAME}"
        sleep 5

        # Request a new DHCP lease.
        /sbin/dhclient "${WLB_INTERFACE_NAME}"
        sleep 15

        # DHCP may have assigned a different address, so refresh it.
        WLB_INTERFACE_IP="$(ip -4 addr show dev "${WLB_INTERFACE_NAME}" | awk '$1 == "inet" && $2 ~ /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\/([0-9]|[12][0-9]|3[0-2])$/ && /dynamic/ {print $2}' | cut -d/ -f1 | head -1)"

        # Test again using the renewed DHCP address.
    WLB_TESTS_FUN
fi

sleep 10

if [ "${#WLB_TEST_HOSTS[@]}" -gt "${#WLB_TEST_HOST_ICMP_EXIT_CODES[@]}" ]
  then
    exit 0
  else
    exit 1
fi

Details

Version
VyOS 2026.08.22-0013-rolling
Is it a breaking change?
Behavior change
Issue type
Bug (incorrect behavior)

Event Timeline

Also, the Last Interface Success and Last Interface Failure times are misleading. The following indicates that the last time the interface passed tests was 1 day, 3:30:28.663652 ago. I imagine that the actual "Last Interface Success" was seconds or minutes ago. Either the time shown should be changed to be accurate for the label or the label should be updated to accurate describe the time shown.

Interface: bond0.102
Status: active
Last Status Change: 2026-08-29 22:01:18
Last Interface Success: 1 day, 3:30:28.663652
Last Interface Failure: N/A
Interface Failures: 0
Viacheslav triaged this task as Normal priority.Mon, Aug 31, 2:13 PM