elicro ревизій цього gist . До ревизії
1 file changed, 26 insertions
add-wg1-port-rotate.rsc(файл створено)
| @@ -0,0 +1,26 @@ | |||
| 1 | + | :do { | |
| 2 | + | /system script | |
| 3 | + | add dont-require-permissions=no name=rotateWgPort owner=admin policy=\ | |
| 4 | + | ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source=":do\ | |
| 5 | + | \_{\r\ | |
| 6 | + | \n # Define the interface name (Change \"wireguard1\" to your actual inte\ | |
| 7 | + | rface name)\r\ | |
| 8 | + | \n :local wgName \"wg1\"\r\ | |
| 9 | + | \n\r\ | |
| 10 | + | \n # Generate a random offset between 0 and 999\r\ | |
| 11 | + | \n :local randomOffset ([:rndnum from=0 to=999])\r\ | |
| 12 | + | \n\r\ | |
| 13 | + | \n # Calculate the final port (45000 + offset)\r\ | |
| 14 | + | \n :local newPort (45000 + \$randomOffset)\r\ | |
| 15 | + | \n\r\ | |
| 16 | + | \n # Apply the new port to the WireGuard interface\r\ | |
| 17 | + | \n /interface wireguard set [find name=\$wgName] listen-port=\$newPort\r\ | |
| 18 | + | \n\r\ | |
| 19 | + | \n # Log the change for your records\r\ | |
| 20 | + | \n :log info (\"WireGuard port for \$wgName changed to: \$newPort\")\r\ | |
| 21 | + | \n}" | |
| 22 | + | /system scheduler | |
| 23 | + | add interval=1m name=wgPortRotate on-event="/system/script/run rotateWgPort;" \ | |
| 24 | + | policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon \ | |
| 25 | + | start-date=1970-01-01 start-time=00:00:00 | |
| 26 | + | } | |
Новіше
Пізніше