{"id":11684,"date":"2021-08-12T12:00:00","date_gmt":"2021-08-12T15:00:00","guid":{"rendered":"https:\/\/made4it.com.br\/blackhole-bgp-mikrotik\/"},"modified":"2023-03-08T11:49:04","modified_gmt":"2023-03-08T14:49:04","slug":"blackhole-bgp-mikrotik","status":"publish","type":"post","link":"https:\/\/made4it.com.br\/en\/blackhole-bgp-mikrotik\/","title":{"rendered":"Blackhole BGP \u2013 Mikrotik"},"content":{"rendered":"\n<p>Now that you know what a <strong>BGP blackhole<\/strong> is <a href=\"https:\/\/www.made4it.com.br\/rtbh-blackhole-o-que-e\/\" class=\"rank-math-link\">(if you still know, check out our article on RTBH &#8211; Blackhole)<\/a>. Now it&#8217;s time to <strong>configure it in Mikrotike<\/strong> to be able to protect yourself from DDoS attacks.<\/p>\n\n<p>To summarize the Blackhole, <strong>it is a technique of sending a route to the \u201cblack hole\u201d<\/strong> or simply making the router discard packets directed to that IP.<\/p>\n\n<p>Now that I know what, now comes the question how to blackhole my router? In today&#8217;s article we will show how to configure Blackhole in Mikrotik Routers running RouterOS.<br\/><br\/>To do the Blackhole manually we have some steps that are:<\/p>\n\n<ol class=\"wp-block-list\"><li>Identify the attacked IP<\/li><li>Create route to blackhole<\/li><li>Advertise this blackhole route via BGP to your carriers\/upstreams<\/li><\/ol>\n\n<p>You can automate all of this with <strong><a href=\"https:\/\/www.made4it.com.br\/made4flow-analisador-de-netflow\/\" class=\"rank-math-link\">Made4Flow<\/a><\/strong>, already closing a direct session and not having to do manual work.<\/p>\n\n<p>If you want to know how to automate everything with Made4Flow, check out our next article.<\/p>\n\n<p>So let&#8217;s go to the settings:<\/p>\n\n<p>\n          <strong>1 \u2013 Identify the attacked IP<\/strong>\n        <\/p>\n\n<p>You can use some of Mikrotik&#8217;s own tools like Torch or use a Netflow Software that has a DDoS attack sensor like Made4Flow<\/p>\n\n<p>Via Torch, go to Tools -&gt; Torch and choose the interface where you are being attacked<\/p>\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.made4it.com.br\/wp-content\/uploads\/2021\/07\/m1.png\"><img fetchpriority=\"high\" decoding=\"async\" width=\"1686\" height=\"1118\" src=\"https:\/\/www.made4it.com.br\/wp-content\/uploads\/2021\/07\/m1.png\" alt=\"\" class=\"wp-image-1829\" srcset=\"https:\/\/made4it.com.br\/wp-content\/uploads\/2021\/07\/m1.png 1686w, https:\/\/made4it.com.br\/wp-content\/uploads\/2021\/07\/m1-300x199.png 300w, https:\/\/made4it.com.br\/wp-content\/uploads\/2021\/07\/m1-1024x679.png 1024w, https:\/\/made4it.com.br\/wp-content\/uploads\/2021\/07\/m1-768x509.png 768w, https:\/\/made4it.com.br\/wp-content\/uploads\/2021\/07\/m1-1536x1019.png 1536w\" sizes=\"(max-width: 1686px) 100vw, 1686px\" \/><\/a><\/figure>\n\n<p>Or in Made4Flow in a simple way by accessing Anti-DDoS -&gt; Active Anomalies<\/p>\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.made4it.com.br\/wp-content\/uploads\/2021\/07\/m2.png\"><img decoding=\"async\" width=\"1854\" height=\"753\" src=\"https:\/\/www.made4it.com.br\/wp-content\/uploads\/2021\/07\/m2.png\" alt=\"\" class=\"wp-image-1830\" srcset=\"https:\/\/made4it.com.br\/wp-content\/uploads\/2021\/07\/m2.png 1854w, https:\/\/made4it.com.br\/wp-content\/uploads\/2021\/07\/m2-300x122.png 300w, https:\/\/made4it.com.br\/wp-content\/uploads\/2021\/07\/m2-1024x416.png 1024w, https:\/\/made4it.com.br\/wp-content\/uploads\/2021\/07\/m2-768x312.png 768w, https:\/\/made4it.com.br\/wp-content\/uploads\/2021\/07\/m2-1536x624.png 1536w\" sizes=\"(max-width: 1854px) 100vw, 1854px\" \/><\/a><\/figure>\n\n<p>The attacked IP was: 200.189.56.55 (Example)<\/p>\n\n<p>\n          <strong>2) Create a route to blackhole<\/strong>\n        <\/p>\n\n<p>After identifying the IP attacked via Torch or via Made4Flow, now it&#8217;s time to create the route on your Router<\/p>\n\n<p>For that go to IP -&gt; Routes and add a new Route<\/p>\n\n<p>Let&#8217;s assume that the attacked IP is 200.200.200.1, let&#8217;s create the route as follows<\/p>\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.made4it.com.br\/wp-content\/uploads\/2021\/07\/m3.png\"><img decoding=\"async\" width=\"1486\" height=\"718\" src=\"https:\/\/www.made4it.com.br\/wp-content\/uploads\/2021\/07\/m3.png\" alt=\"\" class=\"wp-image-1831\" srcset=\"https:\/\/made4it.com.br\/wp-content\/uploads\/2021\/07\/m3.png 1486w, https:\/\/made4it.com.br\/wp-content\/uploads\/2021\/07\/m3-300x145.png 300w, https:\/\/made4it.com.br\/wp-content\/uploads\/2021\/07\/m3-1024x495.png 1024w, https:\/\/made4it.com.br\/wp-content\/uploads\/2021\/07\/m3-768x371.png 768w\" sizes=\"(max-width: 1486px) 100vw, 1486px\" \/><\/a><\/figure>\n\n<p>Add the Dst-address as 200.200.200.1\/32, to identify that it is only the specific IP and the Blackhole type<\/p>\n\n<p>Or via terminal with the following command:<\/p>\n\n<p>\/ip route<br\/>add distance=1 dst-address=200.200.200.1\/32 type=blackhole<\/p>\n\n<p>After applying the route in blackhole this IP will <strong>STOP WORKING!<\/strong><\/p>\n\n<p>\n          <strong>3 &#8211; Advertise this blackhole route via BGP to your carriers\/upstreams<\/strong>\n        <\/p>\n\n<p>After identifying and blackhole the route you need to advertise via BGP to your operators\/upstreams.<\/p>\n\n<p>For this we have a few steps:<\/p>\n\n<ol class=\"wp-block-list\"><li>Create the Route for BGP<\/li><\/ol>\n\n<p>To do this go to Routing -&gt; BGP -&gt; Networks and add the route that is in blackhole<\/p>\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.made4it.com.br\/wp-content\/uploads\/2021\/07\/m4.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1420\" height=\"766\" src=\"https:\/\/www.made4it.com.br\/wp-content\/uploads\/2021\/07\/m4.png\" alt=\"\" class=\"wp-image-1832\" srcset=\"https:\/\/made4it.com.br\/wp-content\/uploads\/2021\/07\/m4.png 1420w, https:\/\/made4it.com.br\/wp-content\/uploads\/2021\/07\/m4-300x162.png 300w, https:\/\/made4it.com.br\/wp-content\/uploads\/2021\/07\/m4-1024x552.png 1024w, https:\/\/made4it.com.br\/wp-content\/uploads\/2021\/07\/m4-768x414.png 768w\" sizes=\"(max-width: 1420px) 100vw, 1420px\" \/><\/a><\/figure>\n\n<p>In our example the attacked IP was: 200.200.200.1\/32<\/p>\n\n<p>Or via command:<\/p>\n\n<p>\/routing bgp network<br\/>add network=200.200.200.1\/32 synchronize=no<\/p>\n\n<ol class=\"wp-block-list\" start=\"2\"><li>Configure your Route-Map or Filters to send the advertisement<\/li><\/ol>\n\n<p>Enter Routing -&gt; Filters and add the new Filter. In our example, the Filter of our operator XPTO has the name TRANSITO-XPTO-OUT and we are going to add it to send our blackhole route:<\/p>\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.made4it.com.br\/wp-content\/uploads\/2021\/07\/m5.png\"><img loading=\"lazy\" decoding=\"async\" width=\"870\" height=\"1074\" src=\"https:\/\/www.made4it.com.br\/wp-content\/uploads\/2021\/07\/m5.png\" alt=\"\" class=\"wp-image-1833\" srcset=\"https:\/\/made4it.com.br\/wp-content\/uploads\/2021\/07\/m5.png 870w, https:\/\/made4it.com.br\/wp-content\/uploads\/2021\/07\/m5-243x300.png 243w, https:\/\/made4it.com.br\/wp-content\/uploads\/2021\/07\/m5-829x1024.png 829w, https:\/\/made4it.com.br\/wp-content\/uploads\/2021\/07\/m5-768x948.png 768w\" sizes=\"(max-width: 870px) 100vw, 870px\" \/><\/a><\/figure>\n\n<p>Add the IP attacked with the mask \/32 in Prefix<\/p>\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.made4it.com.br\/wp-content\/uploads\/2021\/07\/m6.png\"><img loading=\"lazy\" decoding=\"async\" width=\"860\" height=\"1068\" src=\"https:\/\/www.made4it.com.br\/wp-content\/uploads\/2021\/07\/m6.png\" alt=\"\" class=\"wp-image-1834\" srcset=\"https:\/\/made4it.com.br\/wp-content\/uploads\/2021\/07\/m6.png 860w, https:\/\/made4it.com.br\/wp-content\/uploads\/2021\/07\/m6-242x300.png 242w, https:\/\/made4it.com.br\/wp-content\/uploads\/2021\/07\/m6-825x1024.png 825w, https:\/\/made4it.com.br\/wp-content\/uploads\/2021\/07\/m6-768x954.png 768w\" sizes=\"(max-width: 860px) 100vw, 860px\" \/><\/a><\/figure>\n\n<p>In Actions we will mark it as Accept to accept sending this route<\/p>\n\n<p>And finally in BGP Actions and add our operator&#8217;s community:<br\/><br\/>Our XPTO carrier uses community BGP 666:666 to send traffic to Blackhole<\/p>\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.made4it.com.br\/wp-content\/uploads\/2021\/07\/m7-1.png\"><img loading=\"lazy\" decoding=\"async\" width=\"862\" height=\"1064\" src=\"https:\/\/www.made4it.com.br\/wp-content\/uploads\/2021\/07\/m7-1.png\" alt=\"\" class=\"wp-image-1836\" srcset=\"https:\/\/made4it.com.br\/wp-content\/uploads\/2021\/07\/m7-1.png 862w, https:\/\/made4it.com.br\/wp-content\/uploads\/2021\/07\/m7-1-243x300.png 243w\" sizes=\"(max-width: 862px) 100vw, 862px\" \/><\/a><\/figure>\n\n<p>Via cli it looks like this:<\/p>\n\n<p>\/routing filter<br\/>add action=accept chain=TRANSITO-XPTO-OUT prefix=200.200.200.1 set-bgp-communities=666:666<\/p>\n\n<p><strong>Tip 1<\/strong>: Don&#8217;t forget to change the order (Number) of the rule so that it is before the total discard\/reject filter. RouterOS reads Filters rules in numeric sequence, from rule 0 onwards.<\/p>\n\n<p><strong>Tip 2<\/strong>: Talk to your operator to find out which BGP blackhole community they use<\/p>\n\n<p>Once this is done, the IP will remain in blackhole and announced to your operator, the attack will cease if it goes to this single IP.<\/p>\n\n<p>To make life easier, we have the video below, showing in practice how to configure the Mikrotik with Blackhole<\/p>\n\n          \n\n          <figure class=\"wp-block-embed\">\n            <div class=\"wp-block-embed__wrapper\">\n<iframe title=\"Como configurar blackhole em roteadores mikrotik\" width=\"800\" height=\"450\" src=\"https:\/\/www.youtube.com\/embed\/ChlF4xnfN5s?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" allowfullscreen><\/iframe>\n<\/div>\n          <\/figure>\n          \n\n        \n\n<p>\n          <strong>If you have any doubts, do not hesitate to contact us via WhatsApp, Social Networks or E-mail.<\/strong>\n        <\/p>\n\n<p class=\"has-text-align-center\">\n          <strong>See you next time!<\/strong>\n        <\/p>\n","protected":false},"excerpt":{"rendered":"<p>How to configure a BGP blackhole in Mikrotik<\/p>\n","protected":false},"author":13,"featured_media":8806,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"postBodyCss":"","postBodyMargin":[],"postBodyPadding":[],"postBodyBackground":{"backgroundType":"classic","gradient":""},"footnotes":""},"categories":[352],"tags":[298,440,441,452,442],"class_list":["post-11684","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized-en","tag-bgp-en","tag-blackhole-en","tag-blackhole-bgp-en","tag-ddos-atack-en","tag-ddos-protection"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/made4it.com.br\/en\/wp-json\/wp\/v2\/posts\/11684","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/made4it.com.br\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/made4it.com.br\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/made4it.com.br\/en\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/made4it.com.br\/en\/wp-json\/wp\/v2\/comments?post=11684"}],"version-history":[{"count":0,"href":"https:\/\/made4it.com.br\/en\/wp-json\/wp\/v2\/posts\/11684\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/made4it.com.br\/en\/wp-json\/wp\/v2\/media\/8806"}],"wp:attachment":[{"href":"https:\/\/made4it.com.br\/en\/wp-json\/wp\/v2\/media?parent=11684"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/made4it.com.br\/en\/wp-json\/wp\/v2\/categories?post=11684"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/made4it.com.br\/en\/wp-json\/wp\/v2\/tags?post=11684"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}