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

Sunday, October 16, 2016

MikroTik | Video Streaming Drop

I have been blocked video streaming, but not the webpage. It have been done on experiment of some streaming website like youtube, facebook, cnn and many more. After testing I found that result is good. When enter the website youtube, facebook it doesn't run the video (take a lot of time).

Follow the below script  --------------
/ip firewall layer7-protocol
add comment="" name=streaming regexp="videoplayback|video"
 
/ip firewall mangle
add action=mark-packet chain=prerouting comment="Mark Packet Streaming" \
    layer7-protocol=streaming new-packet-mark=streaming passthrough=no
 
/queue simple
add max-limit=64k/64k name=streaming packet-marks=streaming target=\
    192.168.0.3/32,192.168.0.4/32

Note: 192.168.0.3 or 192.168.0.4 is local host ip address, which blocked video steaming. Also noted that the video streaming drop technique didn't drop live tv streaming.

END

 

Friday, July 8, 2016

Mikrotik | BGP Configuration

What is BGP?: The Border Gateway Protocol (BGP) is an inter-autonomous system routing protocol based on distance-vector algorithm. It is used to exchange routing information across the Internet and is the only protocol that is designed to deal with a network of the Internet's size and the only protocol that can deal well with having multiple connections to unrelated routing domains.

BGP is designed to allow for sophisticated administrative routing policies to be implemented. BGP does not exchange information about network topology but rather reachability information. As such, BGP is better suited to inter-AS environments and special cases like informational feeds. If you just need to enable dynamic routing in your network, consider OSPF instead.

For more information: Wiki Mikrotik | BGP or Wikipedia | BGP


Step 1: Connect your Mikrotik router with your pc with a utp cable. Collect winbox software (or download it from www.mikrotik.com).


Step 2: Add the primary link IP address with subnet mask and select the port.


Step 3: Add the secondary link IP address with subnet mask and select the port.


Step 4: Add the local block IP address with subnet mask and select the port.


Step 5: Add the public block IP address with subnet mask and select the port.


Step 6: Add the BGP filter rules for primary link and follow the below screenshot

Step 7: Add the BGP filter rules for primary link and follow the below screenshot


Step 8: Add the BGP filter rules for primary link and follow the below screenshot



Step 9: Add the BGP filter rules for primary link and follow the below screenshot


Step 10: Add the BGP filter rules for primary link and follow the below screenshot


Step 11: Add the BGP filter rules for primary link and follow the below screenshot


Step 12: Add the BGP filter rules for primary link and follow the below screenshot


Step 13: Add the BGP filter rules for primary link and follow the below screenshot


Step 14: Add the BGP filter rules for primary link and follow the below screenshot


Step 15: Add the BGP filter rules for secondary link and follow the below screenshot


Step 16: Add the BGP filter rules for secondary link and follow the below screenshot


Step 17: Add the BGP filter rules for secondary link and follow the below screenshot


Step 18: Add the BGP filter rules for secondary link and follow the below screenshot


Step 19: Add the BGP filter rules for secondary link and follow the below screenshot


Step 20: Add the BGP filter rules for secondary link and follow the below screenshot


Step 21: Add the BGP filter rules for secondary link and follow the below screenshot


Step 22: Add the BGP filter rules for secondary link and follow the below screenshot


Step 23: Add the BGP filter rules for secondary link and follow the below screenshot


Step 24: Add the BGP instance (AS and Router ID)


Steps 25: Add the public ip with network address.


Step 26: Add the BGP peers for primary link.


Step 27: Add the BGP peers for secondary link.


Step 27: Check the link state and uptime.


Step 28: Add NAT rule for private subnet.


Step 29: Add NAT rule for private subnet.




Thanks You

Saturday, June 18, 2016

MikroTik | Web Proxy Log Configuration

RouterOS is capable of logging various system events and status information. Logs can be saved in routers memory (RAM), disk, file, sent by email or even sent to remote syslog server.

UP Link IP Address: 10.10.10.2/30
Local IP Address: 192.168.0.1/24
Log Configuration: Web Proxy Log
Platform: Mikrotik Router

Step 1: Connect your Mikrotik router with your pc with a utp cable. Collect winbox software (or download it from www.mikrotik.com), click on refresh tab for MAC scan, select the mac which has shown, login with admin user, no password.



Step 2: Add wan side IP address, subnet mask and select port.



Step 3: Then add LAN Side IP address, subnet mask and select port.



Step 4: Add routes.
 

Step 5: Add DNS address.



Step 6: Add NAT rules.


Step 7: Add NAT rules.



Step 8: Add NAT rules.



Step 9: Enable web proxy.


Step 10: Create log rules.



Step 11: Create log rules.



Step 12: Redirect log rules.



Step 13: Redirect log rules.



Step 14: Download "Web Proxy Log" application software from http://webproxy-log.software.informer.com/1.5/ and installed the application software. And also following screenshot.

Note: 192.168.0.3 is remote log storage host
 

Step 15: Import logs from write to log folder.


 
Step 16: IP wise user add from import log file.

Step 17: For check log report to select created user and select date. And then need to be click Generate.



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

/ip address
add address=192.168.0.1/24 comment=Local interface=ether3 network=192.168.0.0
add address=10.10.10.2/30 comment=UP_Link interface=ether1 network=10.10.10.0

/ip route
add check-gateway=ping distance=1 gateway=10.10.10.1

/ip dns
set servers=8.8.8.8, 4.2.2.2

/ip firewall nat
add action=masquerade chain=srcnat src-address=192.168.0.0/24

System log:

/system logging action
add bsd-syslog=yes name=syslog remote=192.168.0.3 target=remote
/system logging
add action=syslog topics=web-proxy,!debug
 
Web Proxy Redirect Rule:

/ip firewall nat

add action=redirect chain=dstnat dst-port=80 protocol=tcp src-address=\
192.168.0.0/24 to-ports=8080


END