MUM 2010
It is currently Tue Feb 09, 2010 5:13 am

All times are UTC + 2 hours [ DST ]




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: Automated blocking of IP addresses
PostPosted: Mon Dec 10, 2007 5:02 pm 
Offline
Frequent Visitor
Frequent Visitor
User avatar

Joined: Mon Jun 11, 2007 12:18 pm
Posts: 55
Location: Croatia
In my logs I have lots of entrys like
(50 messages not shown)
dec/10/2007 16:05:09 system,error,critical login failure for user username from 222.112.170.217 via ssh
dec/10/2007 16:05:12 system,error,critical login failure for user username from 222.112.170.217 via ssh
dec/10/2007 16:05:16 system,error,critical login failure for user user from 222.112.170.217 via ssh
dec/10/2007 16:05:19 system,error,critical login failure for user root from 222.112.170.217 via ssh
dec/10/2007 16:05:22 system,error,critical login failure for user admin from 222.112.170.217 via ssh
dec/10/2007 16:05:26 system,error,critical login failure for user test from 222.112.170.217 via ssh
dec/10/2007 16:05:29 system,error,critical login failure for user root from 222.112.170.217 via ssh
dec/10/2007 16:05:32 system,error,critical login failure for user root from 222.112.170.217 via ssh

Is there a way to automaticly block this ip after 3-4 failed logins?



Thanks


Top
 Profile  
 
 Post subject: Re: Automated blocking of IP addresses
PostPosted: Tue Dec 11, 2007 4:30 pm 
Offline
Staff
Staff
User avatar

Joined: Tue Feb 14, 2006 10:46 am
Posts: 2144
Location: Riga, Latvia
you can use access-list - so when host connects for the first time, he gets in a starting list, if it connects another time, it get further, when it connects 4th or 5th time its ip address is added to block list and he is dropped for some time.


Top
 Profile  
 
 Post subject: Re: Automated blocking of IP addresses
PostPosted: Wed Dec 12, 2007 10:32 am 
Offline
Frequent Visitor
Frequent Visitor
User avatar

Joined: Thu Jun 16, 2005 6:20 pm
Posts: 71
Location: Sabac, Serbia
My recommendation is to block the ports for router access in the input chain and allow connection to these port only by your ip address (or range) - this will prevent possible router hacking.
The ports are: 21,22,23,80,8291 all tcp.


Top
 Profile  
 
 Post subject: Re: Automated blocking of IP addresses
PostPosted: Wed Dec 12, 2007 11:19 am 
Offline
Frequent Visitor
Frequent Visitor
User avatar

Joined: Mon Jun 11, 2007 12:18 pm
Posts: 55
Location: Croatia
Access-lists can only be used with wireless interfaces...

My router has no wireless interfaces.

Public interface, DMZ interface and LAN interface (all wires)

On WAN i have static IP addresses and my log's are full of failed login attempts from the same IP address for hours....

I can't block remote access because i connect to the router the same way.

But regardless of where the attempts are comming from. Is there any way to prevent this?
Is there a way to add users IP to an address-list when he failes to logon? and count souch logins? If number of failed logins is greater than eg. 5 in the last minute, bloch the IP for 45 minutes?

I'm pretty new to scripting and some of the more advanced functions but i understand a good example!

Regards


Top
 Profile  
 
 Post subject: Re: Automated blocking of IP addresses
PostPosted: Wed Dec 12, 2007 11:37 am 
Offline
Frequent Visitor
Frequent Visitor
User avatar

Joined: Thu Jun 16, 2005 6:20 pm
Posts: 71
Location: Sabac, Serbia
tplecko wrote:
Access-lists can only be used with wireless interfaces...

My router has no wireless interfaces.

Public interface, DMZ interface and LAN interface (all wires)

On WAN i have static IP addresses and my log's are full of failed login attempts from the same IP address for hours....

I can't block remote access because i connect to the router the same way.

But regardless of where the attempts are comming from. Is there any way to prevent this?
Is there a way to add users IP to an address-list when he failes to logon? and count souch logins? If number of failed logins is greater than eg. 5 in the last minute, bloch the IP for 45 minutes?

I'm pretty new to scripting and some of the more advanced functions but i understand a good example!

Regards


/ip firewall filter add chain=input src-address="YOURIPORSUBNET" action=accept
/ip firewall filter add chain=input action=drop

For mutiple input ip/subnets execute first rule as many times as you have ip/subnets that has to communicate with router directly.
Alternatively, you can use this:
/ip firewall filter add chain=input action=drop dst-port=21
/ip firewall filter add chain=input action=drop dst-port=22
/ip firewall filter add chain=input action=drop dst-port=23
/ip firewall filter add chain=input action=drop dst-port=80
/ip firewall filter add chain=input action=drop dst-port=8291
instead of the drop rule above to drop only "auth-type" services.

Putting ip addresses to access-list is still not secure enough (what is somebody guess you user/pass at first time?)


Top
 Profile  
 
 Post subject: Re: Automated blocking of IP addresses
PostPosted: Thu Dec 13, 2007 11:02 am 
Offline
Frequent Visitor
Frequent Visitor
User avatar

Joined: Mon Jun 11, 2007 12:18 pm
Posts: 55
Location: Croatia
I think that it is less likely that someone will guess my username and password at first...

And forgive me, i forgot to say that i must be able to access the router over the internet. I am connected thru DSL so i can't create a rule to give me access based on the IP address.

If i was on a static ip, i wouldn't be asking here.
Is there a way to do this?


Top
 Profile  
 
 Post subject: Re: Automated blocking of IP addresses
PostPosted: Thu Dec 13, 2007 7:17 pm 
Offline
Member Candidate
Member Candidate

Joined: Tue Jun 01, 2004 3:04 pm
Posts: 141
Location: LV
Example in wiki http://wiki.mikrotik.com/wiki/Bruteforc ... %26_SSH%29


Top
 Profile  
 
 Post subject: Re: Automated blocking of IP addresses
PostPosted: Fri Dec 14, 2007 1:46 am 
Offline
Member
Member
User avatar

Joined: Tue Jan 31, 2006 3:37 pm
Posts: 394
Location: Johannesburg, South Africa
The wiki has a great script - you could also just change the ssh port on your router...


Top
 Profile  
 
 Post subject: Re: Automated blocking of IP addresses
PostPosted: Mon Dec 17, 2007 6:50 pm 
Offline
Staff
Staff
User avatar

Joined: Tue Feb 14, 2006 10:46 am
Posts: 2144
Location: Riga, Latvia
i have pptp server enabled, so i can log in from wherever i need and some sites in whitelist, so i do not have to create pptp tunnel to access from these sites.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC + 2 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
MUM Poland and MUM China free REGISTRATION OPEN