Allowing exim to run automatically on ports other than 25 and 26

InstaCarma_Tech

Well-Known Member
Apr 22, 2009
227
1
68
Thought of sharing this with you all :)

Allowing exim to run automatically on ports other than 25 and 26

We can achieve this by starting exim on the particular port (say 588) using the following command:

/usr/sbin/exim -oX 588 -bd

But to get this done automatically whenever exim starts, do the following:

1) In /etc/chkserv.d, add a file called exim_588 (to run it on port 588).

Note the underscore there. Do not replace it with hyphen as there is another file exim-26 that uses that. The content of the file would be:

service[exim-588]=588,QUIT,220,/etc/rc.d/init.d/exim stop;/etc/rc.d/init.d/exim stop;/etc/rc.d/init.d/exim stop;/etc/rc.d/init.d/exim start;/usr/sbin/exim -oX 588 -bd

2) Enable it in /etc/chkserv.d/chkservd.conf

exim_588:1

3) Now make the following changes in /etc/init.d/exim. Search for ALTPORT and add the following lines below that:

if [ "`echo $file | awk -F_ '{ print $1 }'`" = "exim" ]; then
ALTPORT2=”`echo $file | awk -F_ ‘{ print $2 }’`”
fi

Again search for it and add these lines:

if [ "$ALTPORT2" != "" -a "`grep \"daemon_smtp_port.* $ALTPORT2\" /etc/exim.conf`" = "" ]; then
echo -n “Starting exim-$ALTPORT2: ”
TMPDIR=/tmp $DAEMONIZE /usr/sbin/exim -bd -oX $ALTPORT2
echo $RESULT
fi

This will ensure that exim runs on port 588 on start. You can also see it enabled in Whm >> Service Manager.
 

Vinayak

Well-Known Member
Jun 27, 2003
288
7
168
Bharat
cPanel Access Level
Root Administrator
Can that method be used to run exim on 25, 26 and 588.

I mean on all the three ports simultaneously.

BTW in my /etc/init.d/exim

These lines already exists
[ -f /usr/sbin/exim ] || exit 0

if [ -e "/etc/chkserv.d" ]; then
for file in `ls /etc/chkserv.d`
do
if [ "`echo $file | awk -F- '{ print $1 }'`" = "exim" ]; then
ALTPORT="`echo $file | awk -F- '{ print $2 }'`"
fi
done
fi
And

# See how we were called.
case "$1" in
start)
# Start daemons.

# EXIM
if [ ! -e "/etc/eximdisable" ]; then
if [ -x "/usr/sbin/clamd" ]; then
echo -n "Starting clamd: "
rm -f /var/clamd
$DAEMONIZE /usr/sbin/clamd
echo
fi
if [ "$ALTPORT" != "" -a "`grep \"daemon_smtp_port.* $ALTPORT\" /etc/exim.conf`" = "" ]; then
echo -n "Starting exim-$ALTPORT: "
TMPDIR=/tmp $DAEMONIZE /usr/sbin/exim -bd -oX $ALTPORT
echo $RESULT
fi
Now where exactly are those lines you mentioned should be added, as ALTPORT itself is in a line and has corresponding lines below that.
 

Infopro

Well-Known Member
May 20, 2003
17,075
524
613
Pennsylvania
cPanel Access Level
Root Administrator
Twitter
Thought of sharing this with you all :)

Allowing exim to run automatically on ports other than 25 and 26

We can achieve this by starting exim on the particular port (say 588) using the following command:

/usr/sbin/exim -oX 588 -bd

But to get this done automatically whenever exim starts, do the following:

1) In /etc/chkserv.d, add a file called exim_588 (to run it on port 588).

Note the underscore there. Do not replace it with hyphen as there is another file exim-26 that uses that. The content of the file would be:

service[exim-588]=588,QUIT,220,/etc/rc.d/init.d/exim stop;/etc/rc.d/init.d/exim stop;/etc/rc.d/init.d/exim stop;/etc/rc.d/init.d/exim start;/usr/sbin/exim -oX 588 -bd

2) Enable it in /etc/chkserv.d/chkservd.conf

exim_588:1

3) Now make the following changes in /etc/init.d/exim. Search for ALTPORT and add the following lines below that:

if [ "`echo $file | awk -F_ '{ print $1 }'`" = "exim" ]; then
ALTPORT2=”`echo $file | awk -F_ ‘{ print $2 }’`”
fi

Again search for it and add these lines:

if [ "$ALTPORT2" != "" -a "`grep \"daemon_smtp_port.* $ALTPORT2\" /etc/exim.conf`" = "" ]; then
echo -n “Starting exim-$ALTPORT2: ”
TMPDIR=/tmp $DAEMONIZE /usr/sbin/exim -bd -oX $ALTPORT2
echo $RESULT
fi

This will ensure that exim runs on port 588 on start. You can also see it enabled in Whm >> Service Manager.
What's different in doing it this way instead of adding port 588 (per your example) to the Service Manager > Exim on another port, option?
 

cPanelDon

cPanel Quality Assurance Analyst
Staff member
Nov 5, 2008
2,544
14
268
Houston, Texas, U.S.A.
cPanel Access Level
DataCenter Provider
As Infopro suggested, without manual modification the Service Manager in WHM can handle adding a custom port for Exim to listen on.

For the addition of multiple non-default ports it is also possible to accomplish simply by using the Advanced Exim Configuration Editor to customize two Exim configuration directives.

Here is an example entry that includes ports 26 and 587 to an existing set of ports 25 and 465:
Code:
daemon_smtp_ports = 25 : 26 : 465 : 587
tls_on_connect_ports = 465
As a precaution, before attempting to use the above please ensure no other customization exists that may modify Exim ports.

Here is the menu path used when entering customized Exim configuration directives:
WHM: Main >> Service Configuration >> Exim Configuration Editor >> Advanced Editor
Documentation: The Advanced Exim Editor

For reference, here is a related configuration file path where entries are stored from the Advanced Exim Configuration Editor; this is also used when WHM builds your updated Exim configuration file ("/etc/exim.conf").
Code:
/etc/exim.conf.local
Exim documentation resource:
Exim Specification: Chapter 13. Starting the daemon and the use of network interfaces