How to apply full bogon “Martians networks” list to mikrotik

Підписуйтеся на Telegram-канал «DOU #tech», щоб не пропустити нові технічні статті.

Hello folks, just wanna share my knowledge about how to add bogon or full bogon lists to RouterOS/Mikrotik to improve your network security, prevent DOS, etc.

So before we start to add it we must know what is it these bogon/full bogons networks.

Bogon filtering is the practice of filtering bogons, which are bogus (fake) IP addresses of a computer network. Bogons include IP packets on the public Internet that contain addresses that are not in any range allocated or delegated by the Internet Assigned Numbers Authority (IANA) or a delegated regional Internet registry (RIR) and allowed for public Internet use. The areas of unallocated address space are called the bogon space. ref. and ref.

Fullbogons The Bogons list above reflects unallocated, reserved, and special designated IPv4 address ranges only. When address space is allocated by IANA to the RIRs, it is often subdivided before being assigned to specific networks. Our traditional bogons do not include the ranges that are unassigned by the RIRs. More importantly, our traditional bogons project predates the wide adoption of IPv6 and does not include IPv6 addresses. ref.

Why you must use bogon lists?

Bogon’s packets are useful to cybercriminals because the packets cannot be attributed to an actual host (since the source IP is bogus). Routers don’t examine the source IP address of a packet, all they care about is the destination IP address, so routers will happily forward bogon packets to their destination. Bogons can be used to launch TCP SYN attacks and are used in about 10% of DDoS attacks on the internet.

So full bogons are more efficient to protect your network/ISP network. This article is better for use for Internet Service Providers because my recommendation is for home/office networks is to use white rules, where you create some rules of accept traffic, above drop rules, where you drop all not related to white rules in the firewall.

But where you can get these dynamically updated full bogon lists?

Team-cymru can assist for it, just follow this link, for ipv6.

As far as you can see we have a huge of IP addresses.

!Please pay attention Updated every four hours. but the recommendation for download it is once per day.
We have a source of full bogons IPs, next one will be how to add it to Mikrotik.

System -> Script -> Add newScript
add name and insert script

# Automatically add BOGONs to your firewall’s address lists.
# Only works with 6.43 and up.
#
# Please do not fetch more often than the listed update interval, for the
# lists that are updated only as IANA allocations change, please do not fetch
# more than once per day.
#
# by Phillip Stromberg
# 2018–11–07
# uses team-cymru.org BOGON lists
{
:global content;
:local url;
:local addressListName;

:set addressListName “AUTOBOGON”

####### UNCOMMENT THE URL YOU NEED:#######

### This is the list of bit notation bogons, aggregated, in text format.
### Updated as IANA allocations and special prefix reservations are made.

# :set url “https://www.team-cymru.org/Services/Bogons/bogon-bn-agg.txt"

### The traditional bogon prefixes, plus prefixes that have been allocated to RIRs
### but not yet assigned by those RIRs to ISPs, end-users, etc.
### Updated every four hours.

:set url “https://www.team-cymru.org/Services/Bogons/fullbogons-ipv4.txt"

###########################################################################

:local result [/tool fetch url=$url as-value output=user];

:if ($result->”status” = “finished”) do={
:set content ($result->”data”);
}
:global contentLen [ :len $content ];
:global lineEnd 0;
:global line “”;
:global lastEnd -1;

/ip firewall address-list remove [find list=$addressListName];

:do {
:set lineEnd [:find $content “\n” $lastEnd ];
:set line [:pick $content $lastEnd $lineEnd];
:set lastEnd ( $lineEnd + 1 );
:if ( [:pick $line 0] = “#” ) do={
} else={
# :put $line;
/ip firewall address-list add address=$line list=$addressListName;
}

} while ($lineEnd < $contentLen — 2)
}
thank you Phillip Stromberg for great luna script :)
Policy must be set: read, write, test.

my forked code is

# Automatically add BOGONs IPv6 to your firewall’s address lists.
# Works with 6.47.7 .
#
# Please do not fetch more often than the listed update interval, for the
# lists that are updated only as IANA allocations change, please do not fetch
# more than once per day.
#
# by Phillip Stromberg fork and modified by Levko Kravchuk# , add IPv6 full bogons
#11/17/2020
# uses team-cymru.org BOGON lists
{
:global content;
:local url;
:local addressListName;

:set addressListName “IPv6_AUTOBOGON”
########### UNCOMMENT THE URL YOU NEED: ###########

### This is the list of bit notation bogons, aggregated, in text format.
### Updated as IANA allocations and special prefix reservations are made.

### The traditional bogon prefixes, plus prefixes that have been allocated to RIRs
### but not yet assigned by those RIRs to ISPs, end-users, etc.
### Updated every four hours.

:set url “https://www.team-cymru.org/Services/Bogons/fullbogons-ipv6.txt"
###########################################################################

:local result [/tool fetch url=$url as-value output=user];

:if ($result->”status” = “finished”) do={
:set content ($result->”data”);
}
:global contentLen [ :len $content ];
:global lineEnd 0;
:global line “”;
:global lastEnd -1;

/ipv6 firewall address-list remove [find list=$addressListName];
:do {
:set lineEnd [:find $content “\n” $lastEnd ];
:set line [:pick $content $lastEnd $lineEnd];
:set lastEnd ( $lineEnd + 1 );
:if ( [:pick $line 0] = “#” ) do={
} else={
# :put $line;
/ipv6 firewall address-list add address=$line list=$addressListName;
}

} while ($lineEnd < $contentLen — 2)
}

System -> scheduler

If you need to add simple bogon list just uncomment this line # :set url “https://www.team-cymru.org/Services/Bogons/bogon-bn-agg.txt"

Then add it to the scheduler with the same name as the script and same policy. Try run script and look into the firewall to check if changes were applied, check if rules were set. Please note to set relative block input/forwarding, rules before or after white list rules according to your project/environment.

ENJOY being safe:)

👍ПодобаєтьсяСподобалось0
До обраногоВ обраному0
LinkedIn
Дозволені теги: blockquote, a, pre, code, ul, ol, li, b, i, del.
Ctrl + Enter
Дозволені теги: blockquote, a, pre, code, ul, ol, li, b, i, del.
Ctrl + Enter

Next time try this product app.grammarly.com/apps

sure

Непогано, але вирішити писати на англійській роблячи таку кількість помилок ідея так собі.

Дякую, де шо поправив

Підписатись на коментарі