Top
Whitelist or Blacklist per IP on Zimbra Server - Batch File - Techy Help
fade
3729
post-template-default,single,single-post,postid-3729,single-format-standard,eltd-core-1.2.1,flow-ver-1.7,eltd-smooth-scroll,eltd-smooth-page-transitions,ajax,eltd-blog-installed,page-template-blog-standard,eltd-header-type2,eltd-sticky-header-on-scroll-up,eltd-default-mobile-header,eltd-sticky-up-mobile-header,eltd-menu-item-first-level-bg-color,eltd-dropdown-slide-from-left,eltd-header-style-on-scroll,wpb-js-composer js-comp-ver-6.7.0,vc_responsive
Whitelist or Blacklist per IP on Zimbra Server - Batch File

Whitelist or Blacklist per IP on Zimbra Server – Batch File

Whitelist or Blacklist per IP on Zimbra Server – Batch File, are you getting many spam requests from IP addresses? Do you want to block or allow IPs instantly? It’s been one hectic task for Email Administrators when they need to manage IP based whitelist and blacklist. Well here is the hassle free solution…!!!

 

Check out my other Zimbra Batch files:

Zimbra User Management

Zimbra Group / Distribution Lists Management

 

You will have to apply and modify some of the changes to get this work for you on your Zimbra Open Source Collaboration Server. Here is the guide that you need to follow first before going further below. Click HERE

 

 

I believe you have changed your required files and successfully setup RBL Override and Postfix Blacklist setup.

 

This is my guaranty, this batch file neither will affect any of your server operation nor it will modify any core configurations. It will only do the things that you are asking it to do!

 

 

Here are the basic requirements that you need when you use this batch file:

 

  • Install PUTTY on your windows PC where you will be using this batch file. (Get PUTTY – Free SSH and telnet Client for Windows – HERE)
  • Only use installer / setup of Putty, not the standalone Putty EXE
  • After installing Putty, just connect your Zimbra mail server first time using Putty from your Windows PC with ROOT User ID so that Putty can negotiate and accept ECDSA key fingerprint. Once done exit Putty.

 

My Zimbra Version - Release 8.7.3_GA_1750 (Centos 7 x64 - FOSS Edition)

 

Copy / Paste below batch file in notepad or any text editor.

Save as .bat file, modify below stated two lines and start using it confidently…!!!
Here is the batch file that can fulfill your whitelist and blacklist setup instantly, yes just about giving it 10 seconds. That’s hell faster yea..!!!

 

 

You only have to change following in batch file nothing else:

Line No: 9 — srv=Your Server’s IP

Line No: 11 — pws=Your Server’s ROOT User Password

 

@echo off
SETLOCAL EnableDelayedExpansion
color 1f
mode con: cols=90 lines=35
title Zimbra Server Management Script - By: Ketan Aagja
set zmp=/opt/zimbra/bin/zmprov
 
::Change your zimbra server IP below
set srv=MY ZIMBRA SERVER IP
:: Change your zimbra server password below
set pws=ROOT PASSWORD
SET STR=">> /opt/zimbra/conf/postfix_blacklist"
FOR /F "usebackq tokens=*" %%A IN (`ECHO %STR%`) DO set wht=%%~A
SET STR1=">> /opt/zimbra/conf/postfix_rbl_override"
FOR /F "usebackq tokens=*" %%A IN (`ECHO %STR1%`) DO set wht1=%%~A
cls
echo 			    Designed by : KETAN AAGJA
echo.
echo.
echo 		   ****** PLEASE SELECT APPROPRIATE OPERATION ******
echo. 	
echo.
echo.
echo.
echo.
echo.
echo.
echo				  PRESS 1 - WHITELIST IP ON ZIMBRA SERVER
echo. 
echo.
echo.
echo. 
echo.
echo. 	
echo.
echo.
echo				  PRESS 2 - BLACKLIST IP ON ZIMBRA SERVER
echo.
echo.
echo.
echo.  	
echo.
echo.
echo.
echo.


set /p vid=SELECT AN OPTION :        
echo.
echo.
echo.

cls

IF %vid%==1 GOTO white
IF %vid%==2 GOTO black
IF NOT DEFINED %vid% GOTO away


:white
cls
echo.
echo.
echo 			    *** PLEASE ENTER IP ADDRESS ***
echo. 	
echo.
echo.
echo. 
echo.
echo.
echo.
echo. 	
echo.
echo.
echo.
echo. 	
echo.
echo.
echo.
set /p vid1= IP ADDRESS :        
echo.
echo.
cls
echo.
echo.
echo.
echo.
IF EXIST %TMP%\white.log del /F %TMP%\white.log
echo echo "!vid1! OK" !wht1! >> %TMP%\white.log
echo /opt/zimbra/common/sbin/postmap /opt/zimbra/conf/postfix_rbl_override >> %TMP%\white.log
"C:\Program Files (x86)\PuTTY\putty.exe" -ssh root@%srv% -pw %pws% -m %TMP%\white.log
CLS
color 2f
echo. 	
echo.
echo.
echo 	             *** !vid1! HAS BEEN WHITELISTED ***
echo. 	
echo.
echo.
echo. 
echo.
echo.
echo.
echo. 	
echo.
echo.
echo.
echo. 	
echo.
echo.
echo.
echo 			  *** PRESS ANY KEY TO EXIT ***
pause >nul
exit


:black
cls
echo.
echo.
echo 		      *** PLEASE ENTER IP ADDRESS ***
echo. 	
echo.
echo.
echo. 
echo.
echo.
echo.
echo. 	
echo.
echo.
echo.
echo. 	
echo.
echo.
echo.
set /p vid1= IP ADDRESS :     
echo.
echo.
IF EXIST %TMP%\black.log del /F %TMP%\black.log
echo echo "!vid1! REJECT" !wht! >> %TMP%\black.log
echo /opt/zimbra/common/sbin/postmap /opt/zimbra/conf/postfix_blacklist >> %TMP%\black.log
"C:\Program Files (x86)\PuTTY\putty.exe" -ssh root@%srv% -pw %pws% -m %TMP%\black.log
CLS
color 2f
echo.
echo.
echo.
echo 	     *** %VID1% HAS BEEN BLACKLISTED ***
echo. 	
echo.
echo.
echo. 
echo.
echo.
echo.
echo. 	
echo.
echo.
echo.
echo. 	
echo.
echo.
echo.
echo 			   *** PRESS ANY KEY TO EXIT ***
pause >nul
exit


:away
color 1f
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo             			*** GO AWAY BAD GUY ***
echo. 	
echo.
echo.
echo. 
echo.
echo.

ping -n 4 127.0.0.1 >nul

Do write me or share your views/suggestions on how simply this is saving your time and helping you manage Zimbra users.





Ketan Aagja
No Comments

Post a Comment