Sunday, December 11, 2016

MikroTik | Mail Spammer Rule

Actually, it has been helping to detect which workstations or hosts are sending spam. Let's copy below script and paste the script in new terminal.


/ip firewall filter
add action=add-src-to-address-list address-list=spammer address-list-timeout=\
    1d chain=forward comment="spam 25 port listing rules" connection-limit=\
    60,32 dst-port=25 protocol=tcp
add action=drop chain=forward comment="spammer's mail deny" dst-port=25 \
    protocol=tcp src-address-list=spammer

Or
/ip firewall filter
add action=add-src-to-address-list address-list=spammer address-list-timeout=\
    1d chain=forward comment="25 port listing rules" connection-limit=60,32 \
    dst-port=25 limit=60,5 protocol=tcp
add action=drop chain=forward comment="spammer's mail" dst-port=25 protocol=\
    tcp src-address-list=spammer

MikroTik | Automatic Backup Create And Send To E-mail ID

I have been configured automatic backup create in MikroTik router and send backup to E-mail ID. You should follow below steps:

1. Email configuration in MikroTik router.
2. Writing script for storing backup and sending Email.
3. Creating scheduler for running script regularly send backup.

Steps 1: Email configuration in MikroTik router.
At first configure E-mail setting in MikroTik router and necessary information is below -


Steps 2: Writing script for storing backup and sending Email.



Steps 3: Creating scheduler for running script regularly send backup.


 Explanation: First we give a code snippet and then explain what it actually does.

/tool e-mail
set address=74.125.206.109 from=<xyz@gmail.com> password=\
    xyzxyzxyz port=587 start-tls=yes user=xyz


/system script

add name=backup_mail policy=\
    ftp,reboot,read,write,policy,test,password,sniff,sensitive source=":log in\
    fo \"backup beginning now\"\r\
    \n:global backupfile ([/system identity get name] . \"-\" . [/system clock\
    \_get time])\r\
    \n/system backup save name=\$backupfile\r\
    \n:log info \"backup pausing for 10s\"\r\
    \n:delay 10s\r\
    \n:log info \"backup being emailed\"\r\
    \n\r\
    \n/tool e-mail send to=\"xyz@gmail.com\" subject=([/system identity\
    \_get name] . \\\r\
    \n\" Backup_From_Mikrotik\") from=xyz@gmail.com file=\$backupfile\r\
    \n:log info \"backup finished\"\r\
    \n:delay 20s\r\
    \n:log info \"Deleting Backup File. All Done.\"\r\
    \n/file remove \$backupfile"

Or

Add the script manulay at script tab -

:log info "backup beginning now"
:global backupfile ([/system identity get name] . "-" . [/system clock get time])
/system backup save name=$backupfile
:log info "backup pausing for 10s"
:delay 10s
:log info "backup being emailed"

/tool e-mail send to="xyz@gmail.com" subject=([/system identity get name] . \
" Backup_From_Mikrotik") from=xyz@gmail.com file=$backupfile
:log info "backup finished"
:delay 20s
:log info "Deleting Backup File. All Done."
/file remove $backupfile


 /system scheduler
add interval=1d name=sched_backup_mail on-event=backup_mail policy=\
    ftp,reboot,read,write,policy,test,password,sniff,sensitive start-date=\
    dec/10/2016 start-time=17:30:00


Thank You