:do { /system script add dont-require-permissions=no name=rotateWgPort owner=admin policy=\ ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source=":do\ \_{\r\ \n # Define the interface name (Change \"wireguard1\" to your actual inte\ rface name)\r\ \n :local wgName \"wg1\"\r\ \n\r\ \n # Generate a random offset between 0 and 999\r\ \n :local randomOffset ([:rndnum from=0 to=999])\r\ \n\r\ \n # Calculate the final port (45000 + offset)\r\ \n :local newPort (45000 + \$randomOffset)\r\ \n\r\ \n # Apply the new port to the WireGuard interface\r\ \n /interface wireguard set [find name=\$wgName] listen-port=\$newPort\r\ \n\r\ \n # Log the change for your records\r\ \n :log info (\"WireGuard port for \$wgName changed to: \$newPort\")\r\ \n}" /system scheduler add interval=1m name=wgPortRotate on-event="/system/script/run rotateWgPort;" \ policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon \ start-date=1970-01-01 start-time=00:00:00 }