Subversion Repositories php-qbpwcf

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
3 liveuser 1
#!/bin/bash
2
 
3
#
4
#	QBPWCF, Quick Build PHP website Component base on Fedora Linux.
5
#    Copyright (C) 2015~2024 Min-Jhin,Chen
6
#
7
#    This file is part of QBPWCF.
8
#
9
#    QBPWCF is free software: you can redistribute it and/or modify
10
#    it under the terms of the GNU General Public License as published by
11
#    the Free Software Foundation, either version 3 of the License, or
12
#    (at your option) any later version.
13
#
14
#    QBPWCF is distributed in the hope that it will be useful,
15
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
16
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
#    GNU General Public License for more details.
18
#
19
#    You should have received a copy of the GNU General Public License
20
#    along with QBPWCF.  If not, see <http://www.gnu.org/licenses/>.
21
#    
22
 
23
#get ip to block
24
read -p 'Please run in root, then enter IP which should be Blocked:' ip;
25
 
26
#check ip repeated
27
ip_repeated=`firewall-cmd --list-all | grep ${ip} | wc -l`;
28
 
29
if [ ${ip_repeated} == 1 ];then
30
 
31
	#comment is blocked
32
	echo "${ip} is blocked.";
33
else
34
	#block ip & reload firewall
35
	firewall-cmd --permanent --add-rich-rule="rule family=ipv4 source address=${ip} reject";
36
	firewall-cmd --complete-reload;
37
 
38
	#comment is blocked
39
	echo "${ip} is blocked.";
40
fi