Community discussions

MikroTik App
 
zhup
Member Candidate
Member Candidate
Topic Author
Posts: 112
Joined: Thu Dec 03, 2015 10:10 pm

Firewall rules and block list / blacklist

Fri Aug 05, 2016 11:31 am

Hello,

I would like to use the block list from openbl.org to block unwanted access to my router. I have already imported the blacklist but I do not know if the rules below are correct to block the IP addresses from the black list:
add chain=forward action=drop src-address-list=blacklist in-interface=all-ethernet 
add chain=forward action=drop dst-address-list=blacklist in-interface=all-ethernet
Thank you in advance.
 
Zorro
Long time Member
Long time Member
Posts: 675
Joined: Wed Apr 16, 2014 2:43 pm

Re: Firewall rules and block list / blacklist

Sat Aug 06, 2016 5:19 am

logically in "forward" ppl tend to blacklist "source" lists, not destination. thats (if you like to)for "output" chain, not "forward".
fors tart try forcus on input and forward chains and put in "source" adress lsit, not destination.
 
IntrusDave
Forum Guru
Forum Guru
Posts: 1286
Joined: Fri May 09, 2014 4:36 am
Location: Rancho Cucamonga, CA

Re: Firewall rules and block list / blacklist

Sat Aug 06, 2016 6:15 am

Use the RAW for this. It allows the router to block before a connection is processed. Lightens the load on the router.
you can use the blacklist update script here: http://forum.mikrotik.com/viewtopic.php?f=9&t=98804
That will get you a current blocklist that includes the openbl.org list
 
zhup
Member Candidate
Member Candidate
Topic Author
Posts: 112
Joined: Thu Dec 03, 2015 10:10 pm

Re: Firewall rules and block list / blacklist

Mon Aug 08, 2016 1:21 pm

Use the RAW for this. It allows the router to block before a connection is processed. Lightens the load on the router.
you can use the blacklist update script here: http://forum.mikrotik.com/viewtopic.php?f=9&t=98804
That will get you a current blocklist that includes the openbl.org list
Could you please give me this RAW rule to block the IP from the list before the connection is established?
Is it possible to store the block list on the usb pendrive to avoid to many writes on the flash?
 
IntrusDave
Forum Guru
Forum Guru
Posts: 1286
Joined: Fri May 09, 2014 4:36 am
Location: Rancho Cucamonga, CA

Re: Firewall rules and block list / blacklist

Mon Aug 08, 2016 4:49 pm

/ip firewall raw
add action=drop chain=prerouting in-interface=ether1 src-address-list=dynamicBlacklist
The dynamicBlacklist list that I posted does not write the list to the NAND. The dynamic rules are stored in memory.
If you want the initial download to go to the USB flash, you will need to adjust the script and include the file path.
 
zhup
Member Candidate
Member Candidate
Topic Author
Posts: 112
Joined: Thu Dec 03, 2015 10:10 pm

Re: Firewall rules and block list / blacklist

Tue Aug 09, 2016 12:14 pm

From what lists you create your dynamicBlacklist?
 
IntrusDave
Forum Guru
Forum Guru
Posts: 1286
Joined: Fri May 09, 2014 4:36 am
Location: Rancho Cucamonga, CA

Re: Firewall rules and block list / blacklist

Tue Aug 09, 2016 4:27 pm

Lists are built from 5 publically available lists as well as data that my routers and servers have collected.
 
zhup
Member Candidate
Member Candidate
Topic Author
Posts: 112
Joined: Thu Dec 03, 2015 10:10 pm

Re: Firewall rules and block list / blacklist

Wed Aug 10, 2016 7:32 pm

...
The dynamicBlacklist list that I posted does not write the list to the NAND. The dynamic rules are stored in memory.
...
But first the file "dynamic.rsc" is being saved into the nand.
 
IntrusDave
Forum Guru
Forum Guru
Posts: 1286
Joined: Fri May 09, 2014 4:36 am
Location: Rancho Cucamonga, CA

Re: Firewall rules and block list / blacklist

Fri Aug 12, 2016 8:20 am

yes it is. currently unavoidable. But one large write is much better than several thousand small ones.
 
pe1chl
Forum Guru
Forum Guru
Posts: 10240
Joined: Mon Jun 08, 2015 12:09 pm

Re: Firewall rules and block list / blacklist

Fri Aug 12, 2016 11:05 am

When you want a dynamic blacklist containing only single IP addresses (not subnets), on RouterOS 6.36 and later,
you can put the addresses in some DNS server you can manage and add an address list that has the corresponding
DNS name. I have tried with about 2000 addresses and it works OK: the MikroTik resolves the DNS name, finds
there are too many results for UDP, re-tries in TCP mode (so your DNS server has to support that!) and retrieves
all the 2000 addresses and puts them in the address list. And the DNS query is automatically re-run every time
the TTL of the DNS record ticks to zero.
So, no more need for scripts, you can configure many routers like this and only need to maintain the list in the
DNS server, with a TTL appropriate for the frequency at which you do the updates.
Unfortunately this only works for single addresses, because you cannot put subnets in DNS. Maybe a nice
enhancement would be when MikroTik also resolves TXT records and recognizes a.b.c.d/e strings to create
subnets in the address list.
 
IntrusDave
Forum Guru
Forum Guru
Posts: 1286
Joined: Fri May 09, 2014 4:36 am
Location: Rancho Cucamonga, CA

Re: Firewall rules and block list / blacklist

Fri Aug 12, 2016 5:36 pm

As I said.. Unavoidable. More than half the list is subnets. expanding it to single IP's would make the list unrealistic. Also, with DNS, I have no data from the client, so I have no idea what OS or amount of memory. Those are used to tailor the list. At some points of the month, the full list can grown to over 10k addresses. (Bases on 3, 7, 15 and 30 day status) The low memory boxes will get a smaller list, while the unites with 1G+ will get the full 30 days.
 
pe1chl
Forum Guru
Forum Guru
Posts: 10240
Joined: Mon Jun 08, 2015 12:09 pm

Re: Firewall rules and block list / blacklist

Fri Aug 12, 2016 5:53 pm

The memory size problem can be worked around by having more than one DNS name resolving to lists of several sizes.
The particular name to resolve would be dependent on the router type.
Of course not being able to block subnets this way is the real problem. It could be solved by using TXT records.
In general, I like this way of fetching address lists into various routers.

Who is online

Users browsing this forum: GoogleOther [Bot] and 90 guests