mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-04-19 13:32:24 +00:00
fail2ban - ban and unban an IP Address
This commit is contained in:
parent
0df85cc3d9
commit
39ef172b87
1 changed files with 30 additions and 8 deletions
38
x-ui.sh
38
x-ui.sh
|
@ -1358,10 +1358,12 @@ iplimit_main() {
|
|||
echo -e "${green}\t2.${plain} Change Ban Duration"
|
||||
echo -e "${green}\t3.${plain} Unban Everyone"
|
||||
echo -e "${green}\t4.${plain} Ban Logs"
|
||||
echo -e "${green}\t5.${plain} Real-Time Logs"
|
||||
echo -e "${green}\t6.${plain} Service Status"
|
||||
echo -e "${green}\t7.${plain} Service Restart"
|
||||
echo -e "${green}\t8.${plain} Uninstall Fail2ban and IP Limit"
|
||||
echo -e "${green}\t5.${plain} Unban an IP Address"
|
||||
echo -e "${green}\t6.${plain} Ban an IP Address"
|
||||
echo -e "${green}\t7.${plain} Real-Time Logs"
|
||||
echo -e "${green}\t8.${plain} Service Status"
|
||||
echo -e "${green}\t9.${plain} Service Restart"
|
||||
echo -e "${green}\t10.${plain} Uninstall Fail2ban and IP Limit"
|
||||
echo -e "${green}\t0.${plain} Back to Main Menu"
|
||||
read -p "Choose an option: " choice
|
||||
case "$choice" in
|
||||
|
@ -1389,7 +1391,7 @@ iplimit_main() {
|
|||
3)
|
||||
confirm "Proceed with Unbanning everyone from IP Limit jail?" "y"
|
||||
if [[ $? == 0 ]]; then
|
||||
fail2ban-client set 3x-ipl unban --all
|
||||
systemctl restart fail2ban
|
||||
truncate -s 0 "${iplimit_banned_log_path}"
|
||||
echo -e "${green}All users Unbanned successfully.${plain}"
|
||||
iplimit_main
|
||||
|
@ -1403,18 +1405,38 @@ iplimit_main() {
|
|||
iplimit_main
|
||||
;;
|
||||
5)
|
||||
tail -f /var/log/fail2ban.log
|
||||
read -rp "Enter the IP address you want to ban: " ban_ip
|
||||
if [[ $ban_ip =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
||||
fail2ban-client set 3x-ipl banip "$ban_ip"
|
||||
echo -e "${green}IP Address ${ban_ip} has been banned successfully.${plain}"
|
||||
else
|
||||
echo -e "${red}Invalid IP address format! Please try again.${plain}"
|
||||
fi
|
||||
iplimit_main
|
||||
;;
|
||||
6)
|
||||
service fail2ban status
|
||||
read -rp "Enter the IP address you want to unban: " unban_ip
|
||||
if [[ $unban_ip =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
||||
fail2ban-client set 3x-ipl unbanip "$unban_ip"
|
||||
echo -e "${green}IP Address ${unban_ip} has been unbanned successfully.${plain}"
|
||||
else
|
||||
echo -e "${red}Invalid IP address format! Please try again.${plain}"
|
||||
fi
|
||||
iplimit_main
|
||||
;;
|
||||
7)
|
||||
systemctl restart fail2ban
|
||||
tail -f /var/log/fail2ban.log
|
||||
iplimit_main
|
||||
;;
|
||||
8)
|
||||
service fail2ban status
|
||||
iplimit_main
|
||||
;;
|
||||
9)
|
||||
systemctl restart fail2ban
|
||||
iplimit_main
|
||||
;;
|
||||
10)
|
||||
remove_iplimit
|
||||
iplimit_main
|
||||
;;
|
||||
|
|
Loading…
Reference in a new issue