moneron

LTE APN change

Sep 7th, 2020 (edited)
665
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. #LTE APN Change script
  2. #Written by t.me/moneron
  3. #Discuss in t.me/mikrotikclub
  4. #This script requires read, write, test, policy policies
  5.  
  6. #flag variable declaration
  7. :global laststate;
  8.  
  9. #local variables set (change values with your apn names)
  10. :local passthroughAPNname apn-passthrough;
  11. :local nonpassthroughAPNname default;
  12. :local currentstate [/interface ethernet get [find default-name=ether1] running];
  13.  
  14. #Fill global variables if empty
  15. if (($laststate != true) and ($laststate != false)) do={
  16. :set laststate false;
  17. };
  18. #Change APN profile if laststate and currentstate are different
  19. if ($laststate != $currentstate) do={
  20. if ($currentstate = false) do={
  21. if ([/interface lte get lte1 apn-profiles] = $passthroughAPNname) do={
  22. :log warning "Changing LTE to non-passthrough mode, please wait..."
  23. /interface lte set lte1 apn-profiles=$nonpassthroughAPNname;
  24. :do {:nothing} while=([/interface lte get lte1 running] = false);
  25. :log warning "LTE profile changed to default";
  26. };
  27. } else={
  28. :log warning "Changing LTE to passthrough mode, please wait..."
  29. /interface lte set lte1 apn-profiles=$passthroughAPNname;
  30. :do {:nothing} while=([/interface lte get lte1 running] = false);
  31. :log warning "LTE interface changed to passthrough mode";
  32. };
  33. set laststate $currentstate;
  34. };
Add Comment
Please, Sign In to add comment