mirror of https://github.com/fail2ban/fail2ban
test 1st howto
parent
c4b165290c
commit
fc044efe4d
|
@ -0,0 +1,60 @@
|
||||||
|
To test it, you do not need to install fail2ban at all.
|
||||||
|
|
||||||
|
You can create a standalone test instance parallel to your stock fail2ban (fail2ban works without installation):
|
||||||
|
- download or git checkout a 10th branch, e. g. to directory `/tests/f2b10`:
|
||||||
|
```bash
|
||||||
|
git clone --branch 0.10 https://github.com/fail2ban/fail2ban.git /tests/f2b10
|
||||||
|
```
|
||||||
|
- `cd /tests/f2b10`
|
||||||
|
- if you will use python3, first execute `./fail2ban-2to3` (don't do that if `python --version` returns 2.x)
|
||||||
|
- if you want, you can execute the test suite (works only on clean copy, as long as you do not made some customisation, resp. no *.local files was created):
|
||||||
|
```bash
|
||||||
|
PYTHONPATH=. ./bin/fail2ban-testcases --fast --no-network
|
||||||
|
```
|
||||||
|
- create separate directory `run` for your files this fail2ban instance uses:
|
||||||
|
```bash
|
||||||
|
mkdir run
|
||||||
|
```
|
||||||
|
- create `./config/fail2ban.local` and write there this another paths:
|
||||||
|
```
|
||||||
|
[Definition]
|
||||||
|
logtarget = /tests/f2b10/run/fail2ban.log
|
||||||
|
socket = /tests/f2b10/run/fail2ban.sock
|
||||||
|
pidfile = /tests/f2b10/run/fail2ban.pid
|
||||||
|
dbfile = /tests/f2b10/run/fail2ban.sqlite3
|
||||||
|
```
|
||||||
|
- create `./config/jail.local` and write there your own customizations only, e. g. your backend, enable there your jails, etc.:
|
||||||
|
```
|
||||||
|
[DEFAULT]
|
||||||
|
backend = pyinotify
|
||||||
|
default_backend = pyinotify
|
||||||
|
[sshd]
|
||||||
|
enabled = true
|
||||||
|
[pam-generic]
|
||||||
|
enabled = true
|
||||||
|
```
|
||||||
|
- copy your fail2ban database (contains last positions inside logs, current bans, etc.):
|
||||||
|
```bash
|
||||||
|
cp /var/lib/fail2ban/fail2ban.sqlite3 /tests/f2b10/run/fail2ban.sqlite3
|
||||||
|
```
|
||||||
|
- [important] stop original stock fail2ban `service fail2ban stop` or `fail2ban-client stop`
|
||||||
|
- define alias for your new test fail2ban instance:
|
||||||
|
```bash
|
||||||
|
alias f2b10="sudo PYTHONPATH=$(pwd) $(pwd)/bin/fail2ban-client -c $(pwd)/config/"
|
||||||
|
```
|
||||||
|
- start your test fail2ban instance:
|
||||||
|
```bash
|
||||||
|
#sudo PYTHONPATH=. ./bin/fail2ban-client -c $(pwd)/config/ start
|
||||||
|
f2b10 start
|
||||||
|
```
|
||||||
|
- to stop this fail2ban instance:
|
||||||
|
```bash
|
||||||
|
#sudo PYTHONPATH=. ./bin/fail2ban-client -c $(pwd)/config/ stop
|
||||||
|
f2b10 stop
|
||||||
|
```
|
||||||
|
- path for configs `/tests/f2b10/config` (corresponds to `/etc/fail2ban`)
|
||||||
|
- path for log `/tests/f2b10/run/fail2ban.log`
|
||||||
|
|
||||||
|
Easy and without any installation...
|
||||||
|
|
||||||
|
**[Important] you should always shutdown your original version before you start this standalone instance and vice versa**
|
Loading…
Reference in New Issue