Dynamic DNS Update Script for NO-IP behind NAT on Mikrotik Router V2


Dynamic DNS Update Script for NO-IP behind NAT on Mikrotik Router V2

Mikrotik Script format direct paste into script section


#Dynamic DNS Update Script for No-IP DNS behind nat
# Set needed variables
:local username "your no-ip user login"
:local password "your no-ip password"
:local host "your no-ip host name"
:global previousIP
# print some debug info
:log info ("Update No-IP DNS: username = $username")
:log info ("Update No-IP DNS: hostname = $host")
:log info ("Update No-IP DNS: previousIP = $previousIP")
#
# behind nat - get the public address using dyndns url http://checkip.dyndns.org
/tool fetch mode=http address="checkip.dyndns.org" src-path="/" dst-path="/dyndns.checkip.html"
:delay 2
:local result [/file get dyndns.checkip.html contents]
:log info "dyndns result = $result"
# parse the current IP result
:local resultLen [:len $result]
:local startLoc [:find $result ": " -1]
:set startLoc ($startLoc + 2)
:local endLoc [:find $result "</body>" -1]
:local currentIP [pick $result $startLoc $endLoc]
:log info "No-IP DNS: currentIP = $currentIP"
:if ($currentIP != $previousIP) do={
:log info "No-IP: Current IP $currentIP is not equal to previous IP, update needed"
:set previousIP $currentIP
:local url "http://dynupdate.no-ip.com/nic/update/?myip=$currentIP&hostname=$host"
:log info "No-IP DNS: Sending update for $host"
/tool fetch url=$url user=$username password=$password mode=http dst-path=("no-ip_ddns_update.txt")
:log info "No-IP DNS: Host $host updated on No-IP with IP $currentIP"
:delay 2
:local result [/file get "no-ip_ddns_update.txt" contents]
:log info "Update Result = $result"
} else={
:log info "No-IP: update not needed "
}
# end

Mikrotik Terminal Export Format

/system script
add name=noip_ddns policy="read,write,policy" source="#Dynamic DNS Update Script for No-IP DNS beh\
    ind nat\r\
    \n# Set needed variables\r\
    \n:local username \"your no-ip user login\"\r\
    \n:local password \"your no-ip password\"\r\
    \n:local host \"your no-ip host name\"\r\
    \n:global previousIP\r\
    \n# print some debug info\r\
    \n:log info (\"Update No-IP DNS: username = \$username\")\r\
    \n:log info (\"Update No-IP DNS: hostname = \$host\")\r\
    \n:log info (\"Update No-IP DNS: previousIP = \$previousIP\")\r\
    \n#\r\
    \n# behind nat - get the public address using dyndns url http://checkip.dyndns.org\r\
    \n/tool fetch mode=http address=\"checkip.dyndns.org\" src-path=\"/\" dst-path=\"/dyndns.checkip.html\"\r\
    \n:delay 2\r\
    \n:local result [/file get dyndns.checkip.html contents]\r\
    \n:log info \"dyndns result = \$result\"\r\
    \n# parse the current IP result\r\
    \n:local resultLen [:len \$result]\r\
    \n:local startLoc [:find \$result \": \" -1]\r\
    \n:set startLoc (\$startLoc + 2)\r\
    \n:local endLoc [:find \$result \"</body>\" -1]\r\
    \n:local currentIP [pick \$result \$startLoc \$endLoc]\r\
    \n:log info \"No-IP DNS: currentIP = \$currentIP\"\r\
    \n:if (\$currentIP != \$previousIP) do={\r\
    \n:log info \"No-IP: Current IP \$currentIP is not equal to previous IP, update needed\"\r\
    \n:set previousIP \$currentIP\r\
    \n:local url \"http://dynupdate.no-ip.com/nic/update/\?myip=\$currentIP&hostname=\$host\"\r\
    \n:log info \"No-IP DNS: Sending update for \$host\"\r\
    \n/tool fetch url=\$url user=\$username password=\$password mode=http dst-path=(\"no-ip_ddns_update.txt\")\r\
    \n:log info \"No-IP DNS: Host \$host updated on No-IP with IP \$currentIP\"\r\
    \n:delay 2\r\
    \n:local result [/file get \"no-ip_ddns_update.txt\" contents]\r\
    \n:log info \"Update Result = \$result\"\r\
    \n} else={\r\
    \n:log info \"No-IP: update not needed \"\r\
    \n}\r\
    \n# end\r\
mum-people

MUM – Pakistan Presentation


Opening and introduction, new products

WISP / Industrial Deployment Using Mikrotik CapsMan

Initial debugging steps in RouterOS

MikroTik Implementation in Enterprise Network

Mikrotik Wireless Products and Their Best Setups

MikroTik RouterOS & RouterBoard Wireless features overview

 

Best Regard’s
Abubaker Siddiq Lasania
Virtual IT Support

Join in @ Page / Group

mum-people

MUM in review


MikroTik User Meeting (MUM) is a conference on MikroTik RouterOS software and RouterBoard hardware held 1st time in Karachi, Pakistan on 17th June 2016.

We All thanks to Mikrotik in this regard’s to give us a best way to introduces Pakistani Users and expert’s to present our love and experience toward’s there ROS & Hard wares.

Specially thanks to Dreams Network & Technology (Pvt) Ltd and also Shakeel Khan they work hard to managed the mum presentation in Pakistan.

 

Upcoming in Pakistan:

Stablisment of MikroTik Academy and Officially Certification Program.

Best Regard’s
Abubaker Siddiq Lasania
Virtual IT Support

Join in @ Page / Group

 

backup

Backup By Gmail – Mikrotik


UPDATED on Apr/05/2016  ( few correction and add suggestions ( receiver email field)

Tested on # apr/03/2016 14:47:25 by RouterOS 6.34.4

Adding script into script section …
open new terminal and copy bellow lines

/system script
add name=BackupEmail source="# Enter Sender/Receiver Details.\r\
    \n\r\
    \n:global gmailuser  GMAILUSERNAME\r\
    \n:global gmailid  YOUREMAILID@gmail.com\r\
    \n:global gmailpwd  YOURCURRENTPASSWORD\r\
    \n\r\
    \n## --- Do not change below ---- ##\r\
    \n\r\
    \n\r\
    \n# Enter Receiver  Details.\r\
    \n:global recmail RECEIVEREMAILADDRESS\r\
    \n\r\
    \n## --- Do not change below ---- ##\r\
    \n\r\
    \n#:log warning \"Mikrotik Router Backup JOB Started . . . \"\r\
    \n:local gmailip\r\
    \n:set gmailip [:resolve \"smtp.gmail.com\"]\r\
    \n:global backupfile configbackup\r\
    \n:global mikrotikexport mtexport_backup\r\
    \n:global sub1 ([/system identity get name])\r\
    \n:global sub2 ([/system clock get time])\r\
    \n:global sub3 ([/system clock get date])\r\
    \n:log warning \"Creating new up to date backup files . . . \"\r\
    \n\r\
    \n/system backup save dont-encrypt=yes name=\$backupfile\r\
    \n/export compact file=\$mikrotikexport\r\
    \n\r\
    \n/tool e-mail set address=\$gmailip from=\$gmailid password=\$gmailpwd port=587 start-tls=yes user=\$gmailuser\r\
    \n\r\
    \n:log warning \"Backup process pausing for 10s so it can complete creating backup if system is busy ...\"\r\
    \n:delay 10s\r\
    \n:log info \"Start Sending Backup File via Email using GMAIL SMTP . . .\"\r\
    \n/tool e-mail send to=\$recmail password=\$gmailpwd subject=\"\$sub3 \$sub2 \$sub1 Configuration BACKUP File\" from=\$gmailid file=\$backupfile server=\$gmailip start-tls=yes\r\
    \n:delay 30s\r\
    \n/tool e-mail send to=\$gmailid password=\$gmailpwd subject=\"\$sub3 \$sub2 \$sub1 Configuration EXPORT File\" from=\$gmailid file=\$mikrotikexport server=\$gmailip start-tls=yes\r\
    \n# Delete Old backup files to save space.\r\
    \n/file remove \$backupfile\r\
    \n:delay 30s\r\
    \n/file remove \$mikrotikexport\r\
    \n/tool e-mail set address=0.0.0.0 from=<> password=xxxx port=25 start-tls=yes user=yourid\r\
    \n:log warning \"Backup Finished & Backup File Removed. All Done. You should verify your inbox for confirmation\""

Now add Schedule to run every night 12:05 AM

/system scheduler
add interval=1d name=BackupByEmail on-event=BackupEmail start-date=apr/03/2016 start-time=00:05:00

Now it’s time to edit script and change some needed information about your GMAIL account

gmailuser GMAILUSERNAME
gmailid YOUREMAILID@gmail.com
global gmailpwd YOURCURRENTPASSWORD

New Field Edit
global recmail RECEIVEREMAILADDRESS

Best Regard’s
Abubaker Siddiq Lasania
Virtual IT Support

Join in @ Page / Group

2 Wan Load Balance

2 Wan Dynamic Dhcp-Client Load Balance


Mikrotik Dynamic Dhcp-Client Load balance script.

Kindly do change the following as mention below.

ether1 = ether1-gateway
ether2 = ether2-gateway
ether3 = ether3

Ether3 is a Lan Interface you can rename after complete 7 steps .

Step 1.
Add dynamic client on ether1 & ether2 (WAN1 & WAN2)

/ip dhcp-client
add add-default-route=no dhcp-options=hostname,clientid disabled=no interface=ether1-gateway use-peer-dns=no use-peer-ntp=no
add add-default-route=no dhcp-options=hostname,clientid disabled=no interface=ether2-gateway use-peer-dns=no use-peer-ntp=no

Step 2: Add Lan Interface IP . ( ether3 )

/ip address
add address=192.168.88.1/24 interface=ether3 network=192.168.88.0

Step 3: Add Firewall Nat rule.

/ip firewall nat
add action=masquerade chain=srcnat out-interface=ether1-gateway
add action=masquerade chain=srcnat out-interface=ether2-gateway

Step 4:  Add firewall Mangle Rules

/ip firewall mangle
add action=mark-connection chain=prerouting comment="Load Balance" connection-state=new in-interface=ether1-gateway new-connection-mark=ether1_conn
add action=mark-connection chain=prerouting connection-state=new in-interface=ether2-gateway new-connection-mark=ether2_conn
add action=mark-routing chain=output connection-mark=ether1_conn new-routing-mark=to_ether1
add action=mark-routing chain=output connection-mark=ether2_conn new-routing-mark=to_ether2
add action=mark-connection chain=prerouting connection-state=new dst-address-type=!local in-interface=ether3 new-connection-mark=ether1_conn per-connection-classifier=both-ports:2/0
add action=mark-connection chain=prerouting connection-state=new dst-address-type=!local in-interface=ether3 new-connection-mark=ether2_conn per-connection-classifier=both-ports:2/1
add action=mark-routing chain=prerouting connection-mark=ether1_conn in-interface=ether3 new-routing-mark=to_ether1
add action=mark-routing chain=prerouting connection-mark=ether2_conn in-interface=ether3 new-routing-mark=to_ether2

Step 5: Add Routes ( Setting temporary  gateway)

/ip route
add check-gateway=ping comment="Ether1-Wan routing gateway" distance=1 gateway=192.168.0.1 routing-mark=to_ether1
add check-gateway=ping comment="Ether2-Wan routing gateway" distance=1 gateway=192.168.1.1 routing-mark=to_ether2
add comment=Ether1-Wan distance=1 gateway=192.168.0.1
add comment=Ether2-Wan distance=2 gateway=192.168.1.1

step 6: Create New Script with name ChangeGateways and copy below lines.

:global newgw [/ip dhcp-client get [find interface="ether1-gateway" ] gateway ]
:global activegw [/ip route get [/ip route find comment="Ether1-Wan"] gateway ]
:if ($newgw != $activegw) do={
/ip route set [find comment="Ether1-Wan"] gateway=$newgw
/ip route set [find comment="Ether1-Wan routing gateway"] gateway=$newgw
}
:global newgw [/ip dhcp-client get [find interface="ether2-gateway" ] gateway ]
:global activegw [/ip route get [/ip route find comment="Ether2-Wan"] gateway ]
:if ($newgw != $activegw) do={
/ip route set [find comment="Ether2-Wan"] gateway=$newgw
/ip route set [find comment="Ether2-Wan routing gateway"] gateway=$newgw
}

Step 7: Final Step.

Now add schedule to run this script with 2 seconds timmer ..

Best Regard’s
Abubaker Siddiq Lasania
Virtual IT Support

Join in @ Page / Group

2015 in review


The WordPress.com stats helper monkeys prepared a 2015 annual report for this blog.

Here’s an excerpt:

The concert hall at the Sydney Opera House holds 2,700 people. This blog was viewed about 60,000 times in 2015. If it were a concert at Sydney Opera House, it would take about 22 sold-out performances for that many people to see it.

Click here to see the complete report.

666

HOW TO SETUP BURSTED PROFILE IN MIKROTIK


Brust_Profile1

Brust_Profile2


means:
Rate:300k/800k
Burst Rate: 300k/1000k
Burst Threshold: 300k/900k
Burst Time: 30/30
Priority: 8
Minimum rate: 300k/768k

Brust_Queue1

Brust_Queue2

Best Regard’s
Abubaker Siddiq Lasania
Virtual IT Support

Join in @ Page / Group

mikrotik

Access Mikrotik Remotely


Method to access Load Balance + User Server via remotely. IF you have only 1 server .. no need to setup any thing accept port forwarding in adsl modem i.e 8291 in advance section / virtual server or NAT DMZ  set (Mikrotik) WAN IP. (192.168.1.2)

Quick Note for Beginners:

Option 1
Before you start below method you need Need Static IP Address ( WAN )

Option 2

Before you start below method you need Dynamic IP Updater Script to update your IP Address ( WAN )

Free Dynamic IP updater for Mikrotik

1. ChangeIP.com
2. no-ip.com

You can use any 1 of them to update your dynamic IP.

Step 1
9kuiv7.jpg

Step 2

ma8fiw.jpg

Open 1st router (Load Balance)

Goto IP Services

Change Winbox port 8291 -> 8292

router1_service

Goto IP FIREWALL NAT ( Load Balance )

fwd1

Set to address ( Next Server Wan IP )

fwd2

How to check winbox port are open ?

open your browser and type http://ping.eu/port-chk

ping.eu_portcheck1

ping.eu_portcheck2

Best Regard’s
Abubaker Siddiq Lasania
Virtual IT Support

Join in @ Page / Group

Skype Logo

How to stop advertisement in Skype


How to stop advertisement in Skype


/ip dns static
add address=127.0.0.1 name=pubads.g.doubleclick.net
add address=127.0.0.1 name=static.doubleclick.net
add address=127.0.0.1 name=devads.skypeassets.net
add address=127.0.0.1 name=devapps.skype.net
add address=127.0.0.1 name=qawww.skypeassets.net
add address=127.0.0.1 name=qaapi.skype.net
add address=127.0.0.1 name=preads.skypeassets.net
add address=127.0.0.1 name=preapps.skype.net
add address=127.0.0.1 name=static.skypeassets.com
add address=127.0.0.1 name=serving.plexop.net
add address=127.0.0.1 name=preg.bforex.com
add address=127.0.0.1 name=ads1.msads.net
add address=127.0.0.1 name=flex.msn.com
add address=127.0.0.1 name=apps.skype.com
add address=127.0.0.1 name=api.skype.com
add address=127.0.0.1 name=cdn.mbstatic.org
add address=127.0.0.1 name=marathonbet.com
add address=127.0.0.1 name=megogo.net
add address=127.0.0.1 name=adselector.ru
add address=127.0.0.1 name=pluso.ru
add address=127.0.0.1 name=flash.begun.ru
add address=127.0.0.1 name=ad.adriver.ru

Best Regard’s
Abubaker Siddiq Lasania
Virtual IT Support

Join in @ Page / Group

rb_multipple_dhcp_server

Multiple Server in Mikrotik


Yes you can do Hotspot / PPP / DHCP in each interface as you like.

Multiple combination also work without hesitation.

In above picture i am simply configure multiple dhcp servers on each ethernet interface.

Step 1

Change Interface name
ether1 as WAN
ether2 as Lan1
ether3 as Lan2
ether4 as Lan3
ether5 as Lan4

Step 2
Goto IP Address
Add Wan IP address
Add Lan1 IP address as 10.0.1.1/24
Add Lan2 IP address as 10.0.2.1/24
Add Lan3 IP address as 10.0.3.1/24
Add Lan4 IP address as 10.0.4.1/24

Step 3
Goto IP Dhcp-Server
In Dhcp-Server Dhcp tab
Click on Dhcp Setup
1

2

3

4

5

6

7

8

Repeat same for other interface.

Step 4

In IP Firewall nat

add masquerade rule for local subnets and set out interface as wan.

i hope you will get some basic information about to setup multiple dhcp server on each interface on Mikrotik router.

Best Regard’s
Abubaker Siddiq Lasania
Virtual IT Support

Join in @ Page / Group