Configuring a Ubiquiti EdgeRouter to automatically update static route for KPN IPTV platform [updated]

This guide explains how to automatically update the static route for KPN IPTV platform

) Install script to automatically update static route (updated to work correctly with firmware 1.9.1)

sudo vbash -c 'cat > /config/scripts/tvroute.sh' << EOF
#!/bin/vbash
 
# configured static route target
CUR_IP=\$(cat /config/config.boot | grep 213.75.112.0/21 -A1 | grep next-hop | awk '{ print \$2}');
 
# static route target
NEW_IP=\$(cat /var/run/dhclient_eth0.4_lease | grep new_routers | awk -F= '{print \$2}' | tr -d \');
 
if [ "\$CUR_IP" = "\$NEW_IP" ]; then
   echo Addresses the same
   exit 1;
fi
 
source /opt/vyatta/etc/functions/script-template
 
configure
delete protocols static route 213.75.112.0/21 next-hop \$CUR_IP
set protocols static route 213.75.112.0/21 next-hop \$NEW_IP
commit
save
exit
 
restart igmp-proxy
EOF

 

) Make the script executable

sudo chmod +x /config/scripts/tvroute.sh

 

) Add the script to the task scheduler to automatically check/update the static route

configure
set system task-scheduler task updateIPTVroute executable path /config/scripts/tvroute.sh
set system task-scheduler task updateIPTVroute interval 5m
commit
save
exit

 

Now wait 5 minutes or run the script manually