Friday, November 29, 2019

proxmox repository

deb http://kartolo.sby.datautama.net.id/debian stretch main contrib non-free
deb http://kartolo.sby.datautama.net.id/debian stretch-updates main contrib non-free
deb http://kartolo.sby.datautama.net.id/debian-security/ stretch/updates main contrib non-free
deb http://download.proxmox.com/debian/pve stretch pve-no-subscription
disable /etc/apt/sources.list.d/pve-enterprise.list

disable apt update ipv6
nano /etc/apt/apt.conf.d/99force-ipv4
Acquire::ForceIPv4 "true";
apt update; apt dist-upgrade


Thursday, November 14, 2019

smokeping sample configuration

# source : https://nsrc.org/workshops/ws-files/2011/sanog17/exercises/exercises-smokeping.html
# Note that all IP addresses in this file are false, to prevent some
# machine falling under a deadly DOS storm because all users keep
# the same addresses in their config.

*** General ***

################################################
# DON'T TOUCH UNLESS YOU KNOW WHAT YOU'RE DOING
# BETWEEN THESE MARKS!
################################################
sendmail = /usr/sbin/sendmail
imgcache = /var/www/smokeping
imgurl   = ../smokeping
datadir  = /var/lib/smokeping
piddir   = /var/run/smokeping
smokemail = /etc/smokeping/smokemail
tmail    = /etc/smokeping/tmail
################################################
# END OF DON'T TOUCH SECTION
################################################


# Please edit this to suit your installation
#
# If you have a fully qualified domain name, then you should add this to all
# occurrences of "noc".
#
owner    = The NOCMeister
contact  = monitor@noc
cgiurl   = http://noc/cgi-bin/smokeping.cgi
mailhost = localhost 
# specify this to get syslog logging
syslogfacility = local0
# each probe is now run in its own process
# disable this to revert to the old behaviour
# concurrentprobes = no

*** Alerts ***
to = monitor@noc
from = smokealert@noc

+bigloss
type = loss
# in percent
pattern = ==0%,==0%,==0%,==0%,>0%,>0%,>0%
comment = suddenly there is packet loss

+someloss
type = loss
# in percent
pattern = >0%,*12*,>0%,*12*,>0%
comment = loss 3 times  in a row

+startloss
type = loss
# in percent
pattern = ==S,>0%,>0%,>0%
comment = loss at startup

+rttdetect
type = rtt
# in milli seconds
pattern = <10,<10,<10,<10,<10,<100,>100,>100,>100
comment = routing messed up again ?

+hostdown
type = loss
# in percent
pattern = ==0%,==0%,==0%, ==U
comment = no reply

+lossdetect
type = loss
# in percent
pattern = ==0%,==0%,==0%,==0%,>20%,>20%,>20%
comment = suddenly there is packet loss




*** Database ***

step     = 300
pings    = 20

# consfn mrhb steps total

AVERAGE  0.5   1  1008
AVERAGE  0.5  12  4320
    MIN  0.5  12  4320
    MAX  0.5  12  4320
AVERAGE  0.5 144   720
    MAX  0.5 144   720
    MIN  0.5 144   720

*** Presentation ***

template = /etc/smokeping/basepage.html

+ overview 

width = 600
height = 50
range = 10h

+ detail

width = 600
height = 200
unison_tolerance = 2

"Last 3 Hours"    3h
"Last 30 Hours"   30h
"Last 10 Days"    10d
"Last 400 Days"   400d

*** Probes ***

+ FPing
binary = /usr/bin/fping

+ EchoPingHttp

+ DNS
binary = /usr/bin/dig
pings = 5
step = 180



*** Targets ***

probe = FPing

## You have to edit and uncomment all what you want below this.
# Please, refer to smokeping_config man page for more info
# The given adresses aren't real to avoid DoS.

menu = Top
title = Network Latency Grapher
remark = intERLab at AIT Network Operations and Management Workshop \
         sample SmokePing site 

+ Local

menu = APRICOT 2008 
title = Network Management Workshop 

#
####### LATENCY ########
#

++ Latency

menu = Latency
title = Measure of Latency using icmp ping

+++ LocalMachine 

menu = NOC 
title = The NOC@intERLab
host = localhost
alerts = startloss,someloss,bigloss,rttdetect,hostdown

#++ NOCSquid
#
#menu = The NOC Squid
#title = www-cache / HTTP for noc@apricot2008
#probe = EchoPingHttp
#host = localhost
#port = 8080 # use the squid port
#url = http://localhost/
#

#
## You should edit this for your particular class setup.
## For each PC if you have a fully qualified domain name,
## you should add this as well.
##
#

+++ PC1

menu = pc1
title = pc1
host = pc1
alerts = startloss,someloss,bigloss,rttdetect,hostdown

+++ PC2

menu = pc2
title = pc2
host = pc2
alerts = startloss,someloss,bigloss,rttdetect,hostdown

+++ PC3

menu = pc3
title = pc3
host = pc3
alerts = startloss,someloss,bigloss,rttdetect,hostdown

+++ PC4

menu = pc4
title = pc4
host = pc4
alerts = startloss,someloss,bigloss,rttdetect,hostdown

+++ PC5

menu = pc5
title = pc5
host = pc5
alerts = startloss,someloss,bigloss,rttdetect,hostdown

+++ PC6

menu = pc6
title = pc6
host = pc6
alerts = startloss,someloss,bigloss,rttdetect,hostdown

+++ PC7

menu = pc7
title = pc7
host = pc7
alerts = startloss,someloss,bigloss,rttdetect,hostdown

+++ PC8

menu = pc8
title = pc8
host = pc8
alerts = startloss,someloss,bigloss,rttdetect,hostdown

+++ PC9

menu = pc9
title = pc9
host = pc9
alerts = startloss,someloss,bigloss,rttdetect,hostdown

+++ PC10

menu = pc10
title = pc10
host = pc10
alerts = startloss,someloss,bigloss,rttdetect,hostdown

+++ PC11

menu = pc11
title = pc11
host = pc11
alerts = startloss,someloss,bigloss,rttdetect,hostdown

+++ PC12

menu = pc12
title = pc12
host = pc12
alerts = startloss,someloss,bigloss,rttdetect,hostdown

+++ PC13

menu = pc13
title = pc13
host = pc13
alerts = startloss,someloss,bigloss,rttdetect,hostdown
+++ PC14

menu = pc14
title = pc14
host = pc14
alerts = startloss,someloss,bigloss,rttdetect,hostdown

+++ PC15

menu = pc15
title = pc15
host = pc15
alerts = startloss,someloss,bigloss,rttdetect,hostdown

#
####### APACHE ########
#

#
# You should edit this for your particular class setup.
# For each PC if you have a fully qualified domain name,
# you should add this as well.
#

++ Apache

menu = HTTP
title = Apache (http) service

+++ NOC

menu = NOC
title = Apache 2 Server for noc
probe = FPing
host = localhost

+++ PC1

menu = PC1 
title = Apache 2 Server for pc1
probe = FPing
host = pc1

+++ PC2

menu = PC2 
title = Apache 2 Server for pc2
probe = FPing
host = pc2

+++ PC3

menu = PC3 
title = Apache 2 Server for pc3
probe = FPing
host = pc3

+++ PC4

menu = PC4 
title = Apache 2 Server for pc4
probe = FPing
host = pc4

+++ PC5

menu = PC5 
title = Apache 2 Server for pc5
probe = FPing
host = pc5

+++ PC6

menu = PC6 
title = Apache 2 Server for pc6
probe = FPing
host = pc6

+++ PC7

menu = PC7 
title = Apache 2 Server for pc7
probe = FPing
host = pc7

+++ PC8

menu = PC8 
title = Apache 2 Server for pc8
probe = FPing
host = pc8

+++ PC9

menu = PC9 
title = Apache 2 Server for pc9
probe = FPing
host = pc9

+++ PC10

menu = PC10 
title = Apache 2 Server for pc10
probe = FPing
host = pc10

+++ PC11

menu = PC11 
title = Apache 2 Server for pc11
probe = FPing
host = pc11

+++ PC12

menu = PC12 
title = Apache 2 Server for pc12
probe = FPing
host = pc12

+++ PC13

menu = PC13 
title = Apache 2 Server for pc13
probe = FPing
host = pc13

+++ PC14

menu = PC14 
title = Apache 2 Server for pc14
probe = FPing
host = pc14

+++ PC15

menu = PC15 
title = Apache 2 Server for pc15
probe = FPing
host = pc15

#
####### APACHE ########
#

++ DNS 

probe = DNS
menu = DNS 
title = DNS (name server latency)


+++ NOC

menu = NOC
title = Name Server Latency for noc
host = noc 

#
####### WORLD ########
#

+ World

menu = World
title = Worldwide Connectivity

++ Africa

menu = Africa
title = African Connectivity

+++ SouthAfrica

menu = AfNOG
title = African Network Operators Group
host = afnog.org

++ NorthAmerica

menu = North America
title = North American Connectivity

+++ USA

menu = USA
title = Select US Servers

++++ NSRC

menu = NSRC
title = NSRC (Eugene, Oregon, USA)
host = nsrc.org

++++ WRC

menu = WRC
title = ISOC Workshop Resource Centre (Eugene, Oregon, USA)
host = ws.edu.isoc.org

++++ shell

menu = shell.uoregon.edu
title = Main User Box, University of Oregon (Eugene, Oregon, USA)
host = shell.uoregon.edu

++ SouthAmerica

menu = South America
title =South American Connectivity

+++ Chile

menu = Chile
title = sageduck.org
host = sageduck.org


#
####### Multi Targe ########
#

#+ MultiTarget 

#menu = MultiTarget 
#title = Multi Target Graph of ping Latency  

#++ NorthAmerica 

#menu = NorthAmerica 
#title = North American Servers
#host = shell.uoregon.edu \
#       nsrc.org \
#       psg.com
#alerts = bigloss,rttdetect 

Monday, September 9, 2019

gadget to addresslist mikrotik


Kali ini saya akan share tips menambahkan gadget ke dalam addresslist mikrotik

:local newDynamics value=[/ip dhcp-server lease find dynamic=yes];
:local newList value="";
:foreach i in=[$newDynamics] do={
:local dynamicIP [/ip dhcp-server lease get $i address];
:local dynamicMAC [/ip dhcp-server lease get $i mac-address];
:local dynamicHOST [/ip dhcp-server lease get $i host-name];
:if ($dynamicHOST~"(Andro|andro|Redmi|redmi|Vivo|vivo|Iphone|iphone|Galaxy|galaxy|BLACKBER)") do={
      /ip firewall address-list add list=cidr_hs_office address=$dynamicIP comment=$dynamicHOST
      :log warning "$dynamicIP added"
      }
}
script diatas silahkan tambahkan pada system => scheduler

Tuesday, August 27, 2019

tangkap akamai addresslist mikrotik

Kali ini saya akan bagi tips buat anda yang pengen bikin address-list akamai di mikrotik.
OK, saya anggap anda bisa searching di bgp.he.net untuk mendapatkan informasi as-number akamai
kemudian di blog ini juga sudah ada generate prefix berdasarkan asnumber, silahkan cari.
setelah ini anggaplah sudah ter-generate dan muncul 2 file berisi list ip akamai tadi


kemudian, gabunglah kedua file tadi
/dump # cat  AS35994-AS35994-akamai.rsc >> AS20940-AS20940-akamai.rsc
/dump # sort --unique -k7 AS20940-AS20940-akamai.rsc >> cidr_akamai.rsc 

contoh hasilnya seperti berikut
/ip firewall address-list add list=cidr_akamai comment=AS20940-akamai address=96.7.251.0/24
/ip firewall address-list add list=cidr_akamai comment=AS20940-akamai address=96.7.252.0/22
/ip firewall address-list add list=cidr_akamai comment=AS20940-akamai address=96.7.34.0/24
/ip firewall address-list add list=cidr_akamai comment=AS20940-akamai address=96.7.38.0/24
/ip firewall address-list add list=cidr_akamai comment=AS20940-akamai address=96.7.40.0/24
/ip firewall address-list add list=cidr_akamai comment=AS20940-akamai address=96.7.48.0/24
/ip firewall address-list add list=cidr_akamai comment=AS20940-akamai address=96.7.51.0/24
/ip firewall address-list add list=cidr_akamai comment=AS20940-akamai address=96.7.54.0/23
/ip firewall address-list add list=cidr_akamai comment=AS20940-akamai address=96.7.74.0/24

jika sudah, maka siap di import di mikrotik anda.

note::
 --unique = berarti filter ip address tanpa duplikat
-k7 = adalah kolom ke-7 yang akan kita urutkan


mikrotik ppp auto disable per bulan


on-up
====

:local remote
:set remote $"remote-address"
:log warning ("wellcome ppp-$user ( $remote )")
:if ( [ /ppp secret get "$user" comment ] = "" ) do={
:local month
:local year
:local yeardiv
:local yearmult
:local leapyear
:local lastday
:local date [ /system clock get date ]
:local time [ /system clock get time ]
# ambil nama bulan dan tahun dari date
:set month [:pick $date 0 3]
:set year [:pick $date 7 11]
# check tahun kabisat atau bukan
:set yeardiv ($year / 4)
:set yearmult ($yeardiv * 4)
:if ([$yearmult] = $year) do={ :set leapyear true } else={ :set leapyear false }
# set nilai lastday sesuai nama bulan dan tahun
:if ([$month] = "jan") do={ :set lastday 31d }
:if ([$month] = "feb") do={
:if ($leapyear = true) do={ :set lastday 29d }
:if ($leapyear = false) do={ :set lastday 28d }
}
:if ([$month] = "mar") do={ :set lastday 31d }
:if ([$month] = "apr") do={ :set lastday 30d }
:if ([$month] = "may") do={ :set lastday 31d }
:if ([$month] = "jun") do={ :set lastday 30d }
:if ([$month] = "jul") do={ :set lastday 31d }
:if ([$month] = "aug") do={ :set lastday 31d }
:if ([$month] = "sep") do={ :set lastday 30d }
:if ([$month] = "oct") do={ :set lastday 31d }
:if ([$month] = "nov") do={ :set lastday 30d }
:if ([$month] = "dec") do={ :set lastday 31d }
# cek nilai lastday
#:log info ("$lastday")
/ppp secret set $user comment="$date $time"
/system scheduler remove [find name="ppp-$user"]
/system scheduler add interval=$lastday name="ppp-$user" on-event="/ppp active remove [find user=\"$user\"]\r\n/ppp secret disable [find name=\"$user\"]\r\n/system scheduler remove [find name=\"ppp-$user\"]" start-date=$date start-time=$time
} else={
:local zoky [ /ppp secret get "$user" comment ]
:local zoky1 " $zoky"
:local zoky2
:for i from=0 to=([:len $zoky1] - 1) do={
:local char [:pick $zoky1 $i]
:if ($char = " ") do={
:set $char "\\ "
}
:set zoky2 ($zoky2 . $char)
}
:local var $zoky2
:local myArray [:toarray [:pick $var ([:find $var " "]+1) [:len $var]]]
:local month
:local year
:local yeardiv
:local yearmult
:local leapyear
:local lastday
:local comdate [:pick $myArray 0]
:local comtime [:pick $myArray 1]
# ambil nama bulan dan tahun dari comdate
:set month [:pick $comdate 0 3]
:set year [:pick $comdate 7 11]
# check tahun kabisat atau bukan
:set yeardiv ($year / 4)
:set yearmult ($yeardiv * 4)
:if ([$yearmult] = $year) do={ :set leapyear true } else={ :set leapyear false }
# set nilai lastday sesuai nama bulan dan tahun
:if ([$month] = "jan") do={ :set lastday 31d }
:if ([$month] = "feb") do={
:if ($leapyear = true) do={ :set lastday 29d }
:if ($leapyear = false) do={ :set lastday 28d }
}
:if ([$month] = "mar") do={ :set lastday 31d }
:if ([$month] = "apr") do={ :set lastday 30d }
:if ([$month] = "may") do={ :set lastday 31d }
:if ([$month] = "jun") do={ :set lastday 30d }
:if ([$month] = "jul") do={ :set lastday 31d }
:if ([$month] = "aug") do={ :set lastday 31d }
:if ([$month] = "sep") do={ :set lastday 30d }
:if ([$month] = "oct") do={ :set lastday 31d }
:if ([$month] = "nov") do={ :set lastday 30d }
:if ([$month] = "dec") do={ :set lastday 31d }
# cek nilai lastday
#:log info ("$lastday")
/system scheduler remove [find name="ppp-$user"]
/system scheduler add interval=$lastday name="ppp-$user" on-event="/ppp active remove [find user=\"$user\"]\r\n/ppp secret disable [find name=\"$user\"]\r\n/system scheduler remove [find name=\"ppp-$user\"]" start-date=$comdate start-time=$comtime
} :local profile [/ppp secret get [find name="$user"] profile]
:local rateLimit [/ppp profile get [find name="$profile"] rate-limit]
:local parent [/ppp profile get [find name="$profile"] parent]
:local queue [/ppp profile get [find name="$profile"] queue]
/queue simple remove [find name="$user-$remote"]
/queue simple add max-limit="$rateLimit" name="$user-$remote" parent="$parent" queue="$queue/$queue" target="$remote"
/queue simple remove [find where name~"-$user"]


on-down
======
:local remote
:set remote $"remote-address"
:log warning ("goodbye $user ( $remote )")
:local bytes [/queue simple get [find name="$user-$remote"] bytes]
:local totalbytes
:local arraybytes [:toarray [:pick $bytes ([:find $bytes "/"]+1) [:len $bytes]]]
:local upbytes [:pick $arraybytes 0]
:local downbytes [:pick $arraybytes 1]
:set totalbytes ($upbytes+$downbytes)
:local zoky [/ppp secret get "$user" comment]
:local zoky1 " $zoky"
:local zoky2
:for i from=0 to=([:len $zoky1] - 1) do={
:local char [:pick $zoky1 $i]
:if ($char = " ") do={
:set $char "\\ "
}
:set zoky2 ($zoky2 . $char)
}
:local commentppp $zoky2
:local arraycomment [:toarray [:pick $commentppp ([:find $commentppp " "]+1) [:len $commentppp]]]
:local comdate [:pick $arraycomment 0]
:local comtime [:pick $arraycomment 1]
:local combytes [:pick $arraycomment 2]
:if ($combytes = "") do={
/ppp secret set "$user" comment="$comdate $comtime $totalbytes"
} else={
:local alltotalbytes
:set alltotalbytes ($combytes+$totalbytes)
/ppp secret set "$user" comment="$comdate $comtime $alltotalbytes"
}
/queue simple remove [find name="$user-$remote"]
note
===
profile harap di set max-limit, parent dan queue-typenya
bikin scheduler di run perjam atau terserah anda intervalnya
untuk update counter usagenya
:local userppp
:local usersimple
:foreach i in=[/ppp secret find] do {
:set userppp ( userppp [/ppp secret get $i name])
:local zoky [/ppp secret get "$userppp" comment]
:local zoky1 " $zoky"
:local zoky2
:for i from=0 to=([:len $zoky1] - 1) do={
:local char [:pick $zoky1 $i]
:if ($char = " ") do={
:set $char "\\ "
}
:set zoky2 ($zoky2 . $char)
}
:local commentppp $zoky2
:local arraycomment [:toarray [:pick $commentppp ([:find $commentppp " "]+1) [:len $commentppp]]]
:local comdate [:pick $arraycomment 0]
:local comtime [:pick $arraycomment 1]
:local combytes [:pick $arraycomment 2]
:if ([/ppp secret get [/ppp secret find name="$userppp"] profile] != "") do {
:foreach j in=[/queue simple find where name~"$userppp"] do {
:set usersimple ( usersimple [/queue simple get $j name])
:local bytes [/queue simple get [/queue simple find name="$usersimple"] bytes]
:local totalbytes
:local arraybytes [:toarray [:pick $bytes ([:find $bytes "/"]+1) [:len $bytes]]]
:local upbytes [:pick $arraybytes 0]
:local downbytes [:pick $arraybytes 1]
:set totalbytes ($upbytes+$downbytes)
:if ($combytes < 0) do {
:local alltotalbytes
:if (($comtime < 0)&&($combytes < 0)) do {
:set alltotalbytes ($comdate+$totalbytes)
/ppp secret set "$userppp" comment="$alltotalbytes"
} else {
:set alltotalbytes ($combytes+$totalbytes)
/ppp secret set "$userppp" comment="$comdate $comtime $alltotalbytes"
}
#:log warning "$userppp $comdate $comtime $combytes $usersimple $totalbytes $alltotalbytes"
} else {
:if ($totalbytes = $totalbytes) do {
#:log warning "no update usage ppp"
} else {
:local alltotalbytes
:if (($comtime < 0)&&($combytes < 0)) do {
:set alltotalbytes ($comdate+$totalbytes)
/ppp secret set "$userppp" comment="$alltotalbytes"
} else {
:set alltotalbytes ($combytes+$totalbytes)
/ppp secret set "$userppp" comment="$comdate $comtime $alltotalbytes"
}
#:log warning "$userppp $comdate $comtime $combytes $usersimple $totalbytes $alltotalbytes"
}
}
}
}
}

credits : zoky raharjo (fb) 

Thursday, July 18, 2019

Ganti IP Sentora

/etc/zpanel/panel/bin/setso --set server_ip xxx.xxx.xxx.xxx
/etc/sentora/configs/apache/httpd-vhosts.conf

Wednesday, May 22, 2019

script monitor trafik mikrotik

Yup, dah tau maksudnya kan ? kali ini saya akan share tips gimana caranya jalanin monitor trafik pada interface tertentu (ether1 misalnya) pada pelanggan, yang nantinya dapat digunakan sebagai report ke pelanggan bahwa penggunaan dalam satu bulan ini sudah mencapai sekian GigaByte. Begitu lah kira kira. nah berikut scriptnya, silahkan dibikin scheduler

:global iface ether1
:global trafikawal
:global trafik
# reset tanggal 1
#/system ntp client set primary-ntp=[:resolve id.pool.ntp.org] enabled=yes
#/system clock set time-zone-name="Asia/Jakarta"
:local date [/system clock get date]
:local tanggal [ :pick $date 4 6 ]
#:log warning $tanggal
:if ($tanggal = 1) do={:set trafikawal 0}
:set trafikawal [/interface get [find name=$iface] tx-byte]
   :if ($trafikawal > 1073741824) do={
   :set trafik ($trafikawal / 1073741824)
   :set trafik ($trafik." GB")
   } else={
   :set trafik ($trafikawal / 1048576)
   :set trafik ($trafik." MB")
   }
:log warning "trafik $iface = $trafik"
/in ethernet set $iface comment="$trafikawal"

Nah, setelah diteliti lagi, ternyata script diatas masih ada kekurangan, yaitu ketika perangkat reboot, kereset jadi 0, akhirnya gw ubah jadi revisi scriptnya begini

:global iface ether1
:global trafikFresh
:global trafikSave
:global trafikBit
:global trafikBytes
:global trafikTotal
:local date [/system clock get date]
:local tanggal [ :pick $date 4 6 ]
#:log warning $tanggal
:if ($tanggal = 1) do={:set trafikBit 0}
# jika direboot ambil dari comment interface
:if ([:len $trafikFresh ] = 0) do={
:set trafikSave [/interface get [find name=$iface] comment]
# catat ke variable
:set trafikFresh [/interface get [find name=$iface] tx-byte]
:set trafikTotal ([:tonum $trafikSave] + [:tonum $trafikFresh])
:set trafikBit $trafikTotal
} else={
:set trafikBit  [/interface get [find name=$iface] tx-byte]
:set trafikTotal ([:tonum $trafikSave] + [:tonum $trafikBit])
}
# jika ukuran gigabyte
:if ($trafikTotal > 1073741824) do={
:set trafikBytes ($trafikTotal / 1073741824)
:set trafikBytes ($trafikBytes." GB")
} else={
:set trafikBytes ($trafikTotal / 1048576)
:set trafikBytes ($trafikBytes." MB")
}
:log warning "trafik $iface = $trafikBytes"
/in ethernet set $iface comment="$trafikTotal"

nanti hasilnya seperti berikut :

Saturday, May 18, 2019

Script Mikrotik Cek Intermittent


Hmm.. kali ini mimin bakal share tips & trik cara gimana saat link intermittent maka dilakukan tindakan, di sini mimin disable peer yg ngarah ke sono. Bisa sobat kembangkan sendiri yah. Ok langsung aja bikin scheduler
:global intermit
:global melar
:global limitnotif
:local avgRtt;
:local pin
:local pout
:local target 124.195.38.1
/tool flood-ping $target count=10 do={
  :if ($sent = 10) do={
    :set avgRtt $"avg-rtt"
    :set pout $sent
    :set pin $received
  }
}
:local ploss (100 - (($pin * 100) / $pout))
:local LogErrorMsg ("Ping average for host%0A$target = ".[:tostr $avgRtt]."ms%0Apacket loss = ".[:tostr $ploss]."%")
:local LogWarnMsg ("Ping average for host%0A$target = ".[:tostr $avgRtt]."ms%0Apacket loss = ".[:tostr $ploss]."%")
:local LogError ("Ping average for $target = ".[:tostr $avgRtt]."ms - packet loss: ".[:tostr $ploss]."%")
:local LogWarn ("Ping average for $target = ".[:tostr $avgRtt]."ms - packet loss: ".[:tostr $ploss]."%")
:if ($avgRtt > 20) do={
:set melar ($melar +1)
:log error "$LogError"
} else={
:log warning "$LogWarn"
:set melar 0
}
# jika packetloss diatas 10% maka
:if ([:tostr $ploss] > 10) do={
   :set intermit ($intermit +1)
   :set limitnotif ($limitnotif +1)
   } else={
   :set intermit 0
   }
# jika intermitent terus
:if ($intermit >=10) do={
   :local pesan "$LogErrorMsg"
   /routing bgp peer set [find name~"INIX" disabled=no] disabled=yes
   /ip firewall mangle set [find comment="backup_conn" disabled=yes] disabled=no
   :if ($limitnotif = 2) do={
      /tool fetch url="https://api.telegram.org/bot380921546:AAGn69QpFDuLSOQd3E3JtI5nhfKDkdKMW/sendMessage?chat_id=-20353xxx&text=$pesan" keep-result=no
     }
   }
# jika tidak intermitent
:if ($intermit = 0) do={
   :if ($limitnotif >=10)  do={
   :set limitnotif 0
   }
   :if ($limitnotif =0) do={
   :set limitnotif ($limitnotif +1)
   }
   /routing bgp peer set [find name~"INIX" disabled=yes] disabled=no
   /ip firewall mangle set [find comment="backup_conn" disabled=no] disabled=yes
   :local pesan "$LogWarnMsg"
   :if ($limitnotif =2) do={
      /tool fetch url="https://api.telegram.org/bot380921546:AAGn69QpFDuLSOQd3E3JtI5nhfKDkdKMW/sendMessage?chat_id=-20353xxx&text=$pesan" keep-result=no
      }
   }

Tuesday, April 30, 2019

Redial L2TP Mikrotik Automatic


Pernah nggak kalian membuat VPN server, entah itu PPTP, EOIP, L2TP, dan lain sebagainya ??
Permasalahan yang mimin hadapi ketika membuat VPN server pada MikroTik, ketika koneksi yg ditumpangi (baca:InetBroadband) kadang suka ngetrip, terkadang session L2TP menjadi diskonek yg mengakibatkan laju jalur L2TP terhambat, Solusinya di redial, atau pada ppp active dilakukan remove secara manual.

Hal ini sangat merepotkan kl harus manual, soalnya mimin sering otw ga sempet monitor ngawasin 24jam! Nah solusi berikut ini sangat recomended bagi anda yang bekerja sebagai VPNers (yaelah). Langsung aja deh, buat scheduler di mikrotik kalian isinya begini.

:global count [/ppp active print count-only]
:local i
:for i from=1 to=$count do={
   :global user
   :global vpnip
   :set user [/ppp active get $i name];
   :delay 1
   :set vpnip [/ppp active get $i address];
   :delay 1
   :if ([/ping $vpnip count=2] = 0) do={
      /ppp active remove numbers=$i
      :log error "$user $vpnip request time out!"
      } else={
      :log warning "$user $vpnip is reply..."
      }
   }
 }

Saturday, April 27, 2019

Monitor Ethernet Mikrotik Telegram



Kali ini saya akan bagi tips buat monitoring Rate pada Ethernet Mikrotik lalu dilaporkan ke Telegram. OK langsung aja ya, buat scheduler isinya seperti berikut

:global perulangan
:global statusEth
:global iface "ether2-CDIX"
/int eth monitor ether2 once do={
   :if ($"rate" = "100Mbps" && $perulangan <3) do={
      :set statusEth 0
      :set perulangan ($perulangan +1)
      :log error "$iface is 100Mbps"
      :local pesan "$iface is 100Mbps";
      /tool fetch url="https://api.telegram.org/bot380921xxx:AAGn69QpFDuLSOQd3E3JtIJxxxxx/sendMessage?chat_id=-20353xxx&text=$pesan" keep-result=no
      :if ($perulangan = 3 && $statusEth = 0) do={
         :log error "$iface MASIH 100Mbps"
         :local pesan "$iface MASIH 100Mbps"
         /tool fetch url="https://api.telegram.org/bot380921xxx:AAGn69QpFDuLSOQd3E3JtIJxxxxx/sendMessage?chat_id=-20353xxx&text=$pesan" keep-result=no
         }
      } else={
         :set statusEth 1
         :if ($statusEth = 1 && $perulangan >= 1000) do={:set perulangan 1}
         :if ($statusEth = 1 && $perulangan >= 1) do={:set perulangan ($perulangan +1)}
         :if ($perulangan = 2) do={
            :log warning "$iface 1Gbps"
            :local pesan "Alhamdulillaah $iface 1Gbps";
            /tool fetch url="https://api.telegram.org/bot380921xxx:AAGn69QpFDuLSOQd3E3JtIJxxxxx/sendMessage?chat_id=-20353xxx&text=$pesan" keep-result=no
            }
      }
}