Koozali.org: home of the SME Server

Deny access

Offline Stefano

  • *
  • 10,894
  • +3/-0
Re: Deny access
« Reply #15 on: April 07, 2016, 11:12:56 AM »
try and test, we can't tell you which is the best way :)

Offline smnirosh

  • *****
  • 329
  • +0/-0
  • Learning never ends
Re: Deny access
« Reply #16 on: April 07, 2016, 01:28:52 PM »
Note that AllowHosts/DenyHosts are only effective for external IP, not for clients from the LAN

important to me. bcos i want to deny a clinet who is in the Lan. but not joined to the domain. (The client gets the ip from DHCP server.) thanks

Offline smnirosh

  • *****
  • 329
  • +0/-0
  • Learning never ends
Re: Deny access
« Reply #17 on: April 07, 2016, 01:30:10 PM »
I will try this with iptable. if any problem, will contact you

Offline Stefano

  • *
  • 10,894
  • +3/-0
Re: Deny access
« Reply #18 on: April 07, 2016, 01:52:05 PM »
IMO you're using a wrong approach
Anyway, if you decide for the iptables way, please be aware you must use the templates/fragments way

Offline smnirosh

  • *****
  • 329
  • +0/-0
  • Learning never ends
Re: Deny access
« Reply #19 on: April 07, 2016, 02:19:38 PM »
My godness. I don't know how to use templates/fragments way.

Offline Stefano

  • *
  • 10,894
  • +3/-0
Re: Deny access
« Reply #20 on: April 07, 2016, 02:20:37 PM »
well, the wiki is there.. and if you search here you'll find a zillions of examples :-)

Offline Daniel B.

  • *
  • 1,700
  • +0/-0
    • Firewall Services, la sécurité des réseaux
Re: Deny access
« Reply #21 on: April 07, 2016, 02:27:34 PM »
Fail2ban can be used to ban hosts manually, and it should work for lan clients too. Install the contrib as detailed in the wiki, then create your rules:

Code: [Select]
db fail2ban set bad_client_1 ban Host 192.168.18.12 UnbanTimestamp 9999999999
signal-event fail2ban-update

The UnbanTimestamp is just a ridiculously high value so the rule will never be deleted. You can also specify Port and Protocol if you only want to deny a single service, eg:

Code: [Select]
db fail2ban set bad_client_1 ban Host 192.168.18.12 UnbanTimestamp 9999999999 Port 8089 Protocol tcp
signal-event fail2ban-update
C'est la fin du monde !!! :lol:


Offline Stefano

  • *
  • 10,894
  • +3/-0
Re: Deny access
« Reply #23 on: April 07, 2016, 02:28:50 PM »
well, Dani's suggestion is really easy and powerfull

chapeau :-)

Offline Stefano

  • *
  • 10,894
  • +3/-0
Re: Deny access
« Reply #24 on: April 07, 2016, 02:33:35 PM »

Offline janet

  • *****
  • 4,812
  • +0/-0
Re: Deny access
« Reply #25 on: April 07, 2016, 03:15:12 PM »
ok stefano it seems helpful. But for me, can i go for a "Deny" term instead of Allow? like iptables ?

Here is the FAQ (there is a link at top of forums)
https://wiki.contribs.org/SME_Server:Documentation:FAQ

Within the FAQ is this section on Firewall
https://wiki.contribs.org/SME_Server:Documentation:FAQ:Section05

Plesae read all of this, some of it may apply to your situation.

Especially see
https://wiki.contribs.org/SME_Server:Documentation:FAQ:Section05#Block_outgoing_IPs_or_mac_addresses
&
https://wiki.contribs.org/SME_Server:Documentation:FAQ:Section05#Block_outgoing_ports

If you want to do something else, then you will need to create your own iptables rules, using custom templates.
Anything is (usually) possible in Linux, you just have to learn how to do it (which typically means reading & learning).


....and make sure you read this
https://forums.contribs.org/index.php/topic,46036.0/all.html
« Last Edit: April 07, 2016, 03:19:17 PM by janet »
Please search before asking, an answer may already exist.
The Search & other links to useful information are at top of Forum.

Offline smnirosh

  • *****
  • 329
  • +0/-0
  • Learning never ends
Re: Deny access
« Reply #26 on: April 07, 2016, 11:57:40 PM »
Dear all,

as explained in the janet's comment, i renamed 40DenyRiffRaff with 20DenyRiffRaff. It works.
If anybody helps me, could i know what is this 40;20;10 meaning?

thanks very much again

Offline janet

  • *****
  • 4,812
  • +0/-0
Re: Deny access
« Reply #27 on: April 08, 2016, 01:05:54 AM »
smnirosh

It defines the order in which the template fragments are processed
eg you should not turn something off after previously turning it on, so you move the turn on commands after the turn off comnands have happened by changing the fragment numerical name.
See
https://wiki.contribs.org/Template_Tutorial

Also see the Developers Manual re templates, link in documentation section on main contribs.org Wiki page, link to Wiki at top of Forums.
Please search before asking, an answer may already exist.
The Search & other links to useful information are at top of Forum.

Offline smnirosh

  • *****
  • 329
  • +0/-0
  • Learning never ends
Re: Deny access
« Reply #28 on: April 08, 2016, 07:33:59 AM »
Thanks very much janet. I will refer these links to get more infor.