Home
Projects
Downloads
About me
Lang
HR EN

IPrange2access

NAME
iprange2access - Perl script for generating records in format acceptable for sendmail access file from IP range.

SYNOPSIS
iprange2access first_ip_in_range [ - ] last_ip_in_range [ -d [ -v ] [ -e errorcode ] [ -m message ] ] [ -V ] [ -h ]

DESCRIPTION
Sendmail is one of the oldest mail servers for Unix. By default, Sendmail reads access lists from /etc/mail/access file. That file have role of configuration file used for defining mail or IP addresses which should be denied. Beside mail and IP addresses which could be defined in that file, the whole ranges of IP addresses could be defined too. Wrestling with spam, sometimes requires entering a huge number of lines which defines some range of IP addresses. After I entered 7557th line manually (it seems that I am very patient man), I decided that it is the time for writing script which will make this hard job a lot easier. So, I wrote script which can take range of IP addresses and output lines in format acceptable for sendmail access file. The script is written in perl. IPrange2access requires NetAddr::IP perl module which could be found on CPAN pages. Thanks to Daniel Spiljar dspiljar@world.std.com for helping me with perl. Thanks to him, this script is written in perl. At the first place I intented to wrote the script in bash. I beleve that I would spent a little more time and much more lines of code. In the iprange2access distribution you will find two perl scripts. iprange2access script will work with older perl and does not use any additional perl modules while iprange2access2 will work only with perl >= 5.8.0 and the NetAddr::IP perl module installed. By writting those scripts I was actually learning perl. This is the main reason for having two scripts which are doing the same thing. By running make install, only iprange2access script will be installed. If you want to use iprange2access2 script, just copy it to /usr/local/bin directory.

SCREENSHOTS
There is no need for screenshots but the usual output look like this:

$ iprange2access 192.168.14.5 192.168.14.8
192.168.14.5
192.168.14.6
192.168.14.7
192.168.14.8

$ iprange2access 192.168.14.254 - 192.168.17.1
192.168.14.254
192.168.14.255
192.168.15
192.168.16
192.168.17.0
192.168.17.1

$ iprange2access 192.168.12.254-192.168.17.1 -d -v -e 571 -m "No spam wanted"
#<192.168.12.254-192.168.17.1>
192.168.14.254 571 No spam wanted
192.168.14.255 571 No spam wanted
192.168.15 571 No spam wanted
192.168.16 571 No spam wanted
192.168.17.0 571 No spam wanted
192.168.17.1 571 No spam wanted
#</192.168.12.254-192.168.17.1>

DOWNLOAD
IPrange2access download

OPTIONS
-d
This option will tell to script to generate a deny line (format acceptable for sendmail access) Without this option, script will output only IP addresses in range.
-v
This option will result with prepending line #<IP range> on the top and appending line #</IP range> to the end of output. This is useful for recognise IP ranges in sendmail access file. This option make sens only if parameter -d is used too.
-e errorcode
This option can owerride default errorcode which will be used if script is started with -d parameter. Default errorcode is 571.
-m message
This option can owerride default message with reason of bouncing mail from some IP address. This option make sens only if parameter -d is used too. Default message is: Because of previous SPAM activity from your domain, we reject your mail.
-V
This option indicates that iprange2access should print version and exit.
-h
This option indicates that iprange2access should print usage screen and exit.

REQUIREMENTS
This script is using NetAddr::IP perl module which could be found on CPAN pages. If you do not have NetAddr::IP perl module installed, you have to modify the script and set variable MODE to "core".

BUGS
Current version of IPrange2access does not contain known bugs.

FILES
/etc/mail/access - Sendmail's access file

VARIABLES
ERRORCODE_DEFAULT - default errorcode for sendmail access
MESSAGE_DEFAULT - default error message for sendmail access
MODE - you can set it to "core" if you do not have installed NetAddr::IP perl module, otherwise set it to "module"

SEE ALSO
sendmail(8), Sendmail documentation (/usr/share/doc/sendmail)

AUTHORS
Josip Deanovic djosip@linuxpages.org