{"id":107,"date":"2021-03-10T09:58:18","date_gmt":"2021-03-10T01:58:18","guid":{"rendered":"https:\/\/blog.wikazo.com\/?p=107"},"modified":"2021-03-11T13:59:41","modified_gmt":"2021-03-11T05:59:41","slug":"block-access-menggunakan-domain-atau-keyword-di-mikrotik","status":"publish","type":"post","link":"https:\/\/blog.wikazo.com\/index.php\/2021\/03\/10\/block-access-menggunakan-domain-atau-keyword-di-mikrotik\/","title":{"rendered":"Block Access Menggunakan Domain atau Keyword di Mikrotik"},"content":{"rendered":"\n<hr class=\"wp-block-separator has-text-color has-background is-style-wide\" style=\"background-color:#15a300;color:#15a300\"\/>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Environment:<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Mikrotik Version: 6.43.2<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Mikrotik Series: RB20011UiAS<\/p>\n\n\n\n<hr class=\"wp-block-separator has-text-color has-background is-style-wide\" style=\"background-color:#15a300;color:#15a300\"\/>\n\n\n\n<p class=\"wp-block-paragraph\">Pertama, pastikan user di LAN sudah bisa mengakses internet dengan normal, kemudian ikuti langkah berikut:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Setting DNS<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Checklist <strong>Allow Remote Requests<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"406\" height=\"398\" src=\"https:\/\/blog.wikazo.com\/wp-content\/uploads\/2021\/03\/15.png\" alt=\"\" class=\"wp-image-111\" srcset=\"https:\/\/blog.wikazo.com\/wp-content\/uploads\/2021\/03\/15.png 406w, https:\/\/blog.wikazo.com\/wp-content\/uploads\/2021\/03\/15-300x294.png 300w, https:\/\/blog.wikazo.com\/wp-content\/uploads\/2021\/03\/15-50x50.png 50w\" sizes=\"auto, (max-width: 406px) 100vw, 406px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Setting Firewall<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Tambahkan NAT untuk akses DNS (port 53) agar query DNS tersimpan di mikrotik, <\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;mode&quot;:&quot;null&quot;,&quot;mime&quot;:&quot;text\/plain&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;language&quot;:&quot;Plain Text&quot;,&quot;modeName&quot;:&quot;text&quot;}\">\/ip firewall nat\nadd action=redirect chain=dstnat dst-port=53 protocol=udp to-ports=53<\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Setting Scheduler<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Buka <strong>System &#8211; Scheduler &#8211; Add (+)<\/strong>, Sesuaikan <strong>Name<\/strong>, <strong>Start Time<\/strong> dan <strong>Interval<\/strong>,<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"686\" height=\"529\" src=\"https:\/\/blog.wikazo.com\/wp-content\/uploads\/2021\/03\/13-2.png\" alt=\"\" class=\"wp-image-114\" srcset=\"https:\/\/blog.wikazo.com\/wp-content\/uploads\/2021\/03\/13-2.png 686w, https:\/\/blog.wikazo.com\/wp-content\/uploads\/2021\/03\/13-2-300x231.png 300w\" sizes=\"auto, (max-width: 686px) 100vw, 686px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">disini schedule akan disimpan dengan nama <strong>BlockSite<\/strong> dan mulai dijalankan pada jam <strong>01:00<\/strong> dengan interval <strong>1 jam<\/strong>. Kemudian pada bagian <strong>On Event<\/strong>, isikan script berikut:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;mode&quot;:&quot;null&quot;,&quot;mime&quot;:&quot;text\/plain&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;language&quot;:&quot;Plain Text&quot;,&quot;modeName&quot;:&quot;text&quot;}\">##########################################################################\n# Find all entry on dns cache\n:foreach iDNS in=[\/ip dns cache all find where (name~&quot;netflix&quot; ||  name~&quot;bigo&quot; || name~&quot;tiktok&quot; || name~&quot;mlive&quot; || name~&quot;btc&quot; || name~&quot;bsv&quot; || name~&quot;bch&quot; || name~&quot;northghost&quot; || name~&quot;pool&quot; || name~&quot;tcdn.me&quot; || name~&quot;update.kies.samsung.com&quot; || name~&quot;3g.cn&quot; || name~&quot;browserupdate&quot; || name~&quot;miui&quot; || name~&quot;apple&quot; || name~&quot;mobile-legends&quot; || name~&quot;semi&quot; || name~&quot;nonton&quot; || name~&quot;bioskop&quot; || name~&quot;drakor&quot; || name~&quot;film&quot; || name~&quot;avast&quot; || name~&quot;avira&quot; || name~&quot;vidio&quot; || name~&quot;tv&quot; || name~&quot;smule&quot; || name~&quot;drama&quot; || name~&quot;korea&quot; || name~&quot;instagram&quot; || name~&quot;football&quot; || name~&quot;facebook&quot; || name~&quot;streaming&quot; || name~&quot;soccer&quot; || name~&quot;bola&quot; ||name~&quot;game&quot; || name~&quot;poker&quot; || name~&quot;porn&quot; || name~&quot;qq.com&quot; || name~&quot;qq.net&quot; || name~&quot;qq.org&quot; || name~&quot;roulette&quot; || name~&quot;sbobet&quot; || name~&quot;casino&quot; || name~&quot;xvideos&quot;) &amp;&amp; (type=&quot;A&quot;) ] do={\n# find and filtering keyword and only find record for type A\n# for keyword just add keyword || name~&quot;KEYWORD&quot;) before &amp;&amp; (type=&quot;A&quot;)\n##########################################################################\n:local tmpDNSsite [\/ip dns cache get $iDNS name] ;\n:local tmpDNSip [\/ip dns cache get $iDNS address];\n:local nameList &quot;BLOCK_SITE&quot;;\n# save to local cache by string\n##########################################################################\ndelay delay-time=10ms\n# wait for 10ms\n##########################################################################\n:if ( [\/ip firewall address-list find where address=$tmpDNSip] = &quot;&quot;) do={ \n# chek for no more duplicate site on cache\n##########################################################################\n:log warning (&quot;Added site to block on dns: $tmpDNSsite : $tmpDNSip&quot;);\n# show info on warning log\n########################################################################## \n\/ip firewall address-list add address=$tmpDNSip list=$nameList comment=$tmpDNSsite timeout=24:00:00;\n# add site to add list entry.\n##########################################################################\n}\n}\n# End Script \n##########################################################################<\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">Simpan schedule tersebut, dan setelah 1 jam maka dibagian <strong>Firewall &#8211; Address Lists<\/strong> akan ada list domain dan IP Address yang akan di block.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"781\" height=\"431\" src=\"https:\/\/blog.wikazo.com\/wp-content\/uploads\/2021\/03\/14.png\" alt=\"\" class=\"wp-image-115\" srcset=\"https:\/\/blog.wikazo.com\/wp-content\/uploads\/2021\/03\/14.png 781w, https:\/\/blog.wikazo.com\/wp-content\/uploads\/2021\/03\/14-300x166.png 300w, https:\/\/blog.wikazo.com\/wp-content\/uploads\/2021\/03\/14-768x424.png 768w\" sizes=\"auto, (max-width: 781px) 100vw, 781px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Kemudian tambahkan script berikut untuk mengeksekusi Address Lists tersebut <\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;mode&quot;:&quot;null&quot;,&quot;mime&quot;:&quot;text\/plain&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;language&quot;:&quot;Plain Text&quot;,&quot;modeName&quot;:&quot;text&quot;}\">\/ip firewall mangle\nadd action=mark-packet chain=prerouting comment=BLOCK_SITE \\\n    dst-address-list=BLOCK_SITE in-interface=ether-LAN new-packet-mark=\\\n    block_pkt passthrough=no\n\/ip firewall filter\nadd action=jump chain=forward comment=BLOCK_SITE jump-target=socmed \\\n\tpacket-mark=socmed_pkt\nadd action=drop chain=socmed comment=BLOCK_SITE packet-mark=socmed_pkt<\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">pada script mangle sesuaikan in-interface yang digunakan untuk akses LAN. Perhatikan counter filter <strong>Bytes\/Packet <\/strong>yang baru saja dibuat, jika terus bertambah maka block access menggunakan domain atau keyword telah berhasil.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Done&#8230;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Environment: Mikrotik Version: 6.43.2 Mikrotik Series: RB20011UiAS Pertama, pastikan user di LAN sudah bisa mengakses internet dengan normal, kemudian ikuti langkah berikut: Setting DNS Checklist Allow Remote Requests Setting Firewall<span class=\"more-button\"><a href=\"https:\/\/blog.wikazo.com\/index.php\/2021\/03\/10\/block-access-menggunakan-domain-atau-keyword-di-mikrotik\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\">Block Access Menggunakan Domain atau Keyword di Mikrotik<\/span><\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[18,15,16],"class_list":["post-107","post","type-post","status-publish","format-standard","hentry","category-notes","tag-firewall","tag-mikrotik","tag-script"],"_links":{"self":[{"href":"https:\/\/blog.wikazo.com\/index.php\/wp-json\/wp\/v2\/posts\/107","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.wikazo.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.wikazo.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.wikazo.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.wikazo.com\/index.php\/wp-json\/wp\/v2\/comments?post=107"}],"version-history":[{"count":6,"href":"https:\/\/blog.wikazo.com\/index.php\/wp-json\/wp\/v2\/posts\/107\/revisions"}],"predecessor-version":[{"id":137,"href":"https:\/\/blog.wikazo.com\/index.php\/wp-json\/wp\/v2\/posts\/107\/revisions\/137"}],"wp:attachment":[{"href":"https:\/\/blog.wikazo.com\/index.php\/wp-json\/wp\/v2\/media?parent=107"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.wikazo.com\/index.php\/wp-json\/wp\/v2\/categories?post=107"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.wikazo.com\/index.php\/wp-json\/wp\/v2\/tags?post=107"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}