User-defined WAN load-balancing health-check scripts are executed without any interface context. Unlike WAN hook scripts, they do not receive the interface name via environment variables, making it impossible to write a generic health-check script that can identify the interface being tested.
configuration
set load-balancing wan interface-health eth0 failure-count '3' set load-balancing wan interface-health eth0 nexthop '10.0.2.2' set load-balancing wan interface-health eth0 success-count '3' set load-balancing wan interface-health eth0 test 11 target '10.0.2.2' set load-balancing wan interface-health eth0 test 11 test-script '/config/scripts/wanlb-hc.sh' set load-balancing wan interface-health eth0 test 11 type 'user-defined' set load-balancing wan interface-health eth1 failure-count '3' set load-balancing wan interface-health eth1 nexthop '10.0.3.2' set load-balancing wan interface-health eth1 success-count '3' set load-balancing wan interface-health eth1 test 12 target '10.0.3.2' set load-balancing wan interface-health eth1 test 12 test-script '/config/scripts/wanlb-hc.sh' set load-balancing wan interface-health eth1 test 12 type 'user-defined' set load-balancing wan rule 10 inbound-interface 'eth2' set load-balancing wan rule 10 interface eth0 weight '1' set load-balancing wan rule 10 interface eth1 weight '1' set load-balancing wan rule 10 protocol 'all' set load-balancing wan sticky-connections inbound
health check script
#!/bin/bash printenv > /tmp/vars.out
script output
vyos@vyos:~$ cat /tmp/vars.out PWD=/ SYSTEMD_EXEC_PID=2362 LANG=en_US.UTF-8 INVOCATION_ID=371db7ffcdd9464b886a46f330e78fc9 SHLVL=1 JOURNAL_STREAM=9:9660 PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin _=/usr/bin/printenv