пятница, 26 февраля 2016 г.

upgrade-routeros script

I have developed "upgrade-routeros" perl script for safe and client-friendly graceful upgrade (or reboot) of RouterOS on ASBR and BRAS MikroTik routers.

It solves some problems automatically, which required manual work before.
  • BGP route updates don't propagate instantly. If we just upgrade the software by rebooting an ASBR, the traffic would be blackholed or looped for several minutes. To solve this problem, we need to disable BGP peers and wait for route propagation. Then we may safely reboot the router as the traffic is not directed to it any more. The new script waits for 5 mintes to let the network converge.
  • PPPoE sessions should be terminated gracefully. Otherwise cheap CPEs may hang or stop reconnecting automatically. To solve this problem, the script gracefully disconnects PPPoE users before rebooting the BRAS. To avoid new PPPoE sessions it sets max-sessions=1. To avoid disturbing the users too much it waits for the sessions to be at least 2 hours old. To avoid hammering the radius server the sessions are disconnected one per second. PPPoE servers are disabled after disconnecting all users (but one) to allow one more reboot for firmware upgrade.
This allows quite graceful software upgrade, provided that the network has at least N+1 redundancy in ASBR and BRAS.

After upgrade the script checks if the upgrade was successful, upgrades routerboard firmware if needed, then re-enables BGP peers and/or PPPoE servers.

The script uses MikroTik::API perl module.