Tuesday, December 18, 2018

VeeamPN - Setting Up a Persistent Route

When setting up VeeamPN gateway devices, the route back to the hub is not automatically created on the VeeamPN gateway appliance when the hub is not deployed in Microsoft Azure.

https://helpcenter.veeam.com/docs/veeampn/userguide/add_route.html?ver=10

Here Veeam shows how you can manually add the route, but once the appliance is restarted the route needs to be added again manually.

Thanks to linuxconfig.org, I found the steps to automatically execute a shell script at startup.

https://linuxconfig.org/how-to-automatically-execute-shell-script-at-startup-boot-on-systemd-linux


1. Create a system startup script - /etc/systemd/system/customroute.service
This service is run after the veeam-vpn-svc.service runs.


2. chmod 664 /etc/systemd/system/customroute.service

3. Create a custom shell script - /usr/local/bin/customroute.sh
The script loops through the output of route -n, looking for the tun0 device which is the established VeeamPN VPN tunnel back to the VeeamPN Hub appliance.  Once that is there, it adds the route with the route add command, and also prints the route -n output to the /root/routeprint.txt file.



4. chmod 744 /usr/local/bin/customroute.sh

5. systemctl daemon-reload

6. systemctl enable customeroute.service

7. restart the veeampn gateway - shutdown -r now