Задача: генерировать случайный пароль для гостевой WiFi сети и отправлять ее на определенный адрес почты
Решение: в Mikrotik нет нормального произвольного генератора паролей, поэтому либо пользуемся сторонним сервисом https://www.random.org/passwords/ либо командой /certificate scep-server otp
Примечания:
# MikroTik Random Password for WiFi (CAPsMAN) # Define name of your WiFi (CAPsMAN) profile :local wifiprofile security-guest # Define Password Length :local passlength 8 # Define the parameters for mail notification :local destmail [email protected] #:local ccdestmail [email protected] :local content "New Wi-Fi password" :local emailauthuser [email protected] :local emailfrom [email protected] :local emailserver smtp.mail.ru :local emailauthpass my_password # Gets a new password ##:local new ([/tool fetch url="https://www.random.org/passwords/\?num=1&len=$passlength&format=plain&rnd=new" output=user as-value]->"data") # Trim line break simbol "\n" ##:local newPassword [ :pick $new 0 [ :find $new "\n" ] ]; :local new ([/certificate scep-server otp generate minutes-valid=0 as-value]->"password"); :local newPassword [:pick $new 0 $passlength ] # Set password to wifi profile /caps-man security set [find name="security-guest"] passphrase=$newPassword #Sendind e-mail /tool e-mail send server=$emailserver to="$destmail" subject=$content body="New Password for WiFi Guest is: $newPassword" user=$emailauthuser password=$emailauthpass from="$emailfrom" # Write a log line :log warning message="Wifi password for profile $wifiprofile has ben set to: $newPassword" :put $newPassword