Configure sendmail to use alternate port

Installing and maintaining the FreeBSD Ports Collection or FreeBSD Packages (i.e. third party software).

Configure sendmail to use alternate port

Postby UncleBob » 28 Jul 2009, 14:21

Hi, (not sure if I'm posting to the right place thou)

I've been trying to move sendmail from 25 port to something else. I've added the following to the master config:

DAEMON_OPTIONS(`Port=2525, Name=MTA')

Afterwards I compiled new .cf file and restarted sendmail.

It worked, coz when I telnet to port 2525 I can see sendmail there, but the problem is that it still listens to port 25.

Is there any way to configure sendmail to free port 25?
UncleBob
Junior Member
 
Posts: 2
Joined: 28 Jul 2009, 14:14

Postby DutchDaemon » 28 Jul 2009, 14:59

I've tried some alternatives (also involving shutting down the 'submit' side of Sendmail), but it looks like defining 'MTA' anywhere in your .mc file (even with an alternative port) will always open port 25.
User avatar
DutchDaemon
Old Fart
 
Posts: 10464
Joined: 16 Nov 2008, 20:17
Location: The Netherlands

Postby DutchDaemon » 28 Jul 2009, 15:11

A last alternative was to omit MTA entirely and take the submit route:

/etc/rc.conf
Code: Select all
sendmail_submit_enable="YES"
sendmail_enable="NO"


sendmail.mc
Code: Select all
FEATURE(`no_default_msa')
DAEMON_OPTIONS(`Port=2525, Name=MSA, M=E')


[cmd=]/etc/rc.d/sendmail forcestart[/cmd]

Result:
Code: Select all
# sockstat -4p 25     
USER     COMMAND    PID   FD PROTO  LOCAL ADDRESS         FOREIGN ADDRESS     
root     sendmail   81354 5  tcp4   *:25                  *:*
root     sendmail   81329 3  tcp4   127.0.0.1:25          *:*
# sockstat -4p 2525
USER     COMMAND    PID   FD PROTO  LOCAL ADDRESS         FOREIGN ADDRESS     
root     sendmail   81354 3  tcp4   *:2525                *:*


Looks like port 25 is very much hardcoded.
User avatar
DutchDaemon
Old Fart
 
Posts: 10464
Joined: 16 Nov 2008, 20:17
Location: The Netherlands

Postby DutchDaemon » 28 Jul 2009, 15:22

Hm, doing it straight up seems to have some result:

/etc/rc.conf
Code: Select all
sendmail_enable="YES"
sendmail_flags="-L sm-mta -bd -q30m -ODaemonPortOptions=Port=2525"


(nothing special in .mc)

Code: Select all
# sockstat -4p 2525
USER     COMMAND    PID   FD PROTO  LOCAL ADDRESS         FOREIGN ADDRESS     
root     sendmail   81578 3  tcp4   *:2525                *:*
# sockstat -4p 25
USER     COMMAND    PID   FD PROTO  LOCAL ADDRESS         FOREIGN ADDRESS     
root     sendmail   81329 3  tcp4   127.0.0.1:25          *:*


The latter (localhost:25) is needed for handling system email anyway, but your external port 25 will be freed.

If you really want to kill local mail handling:

/etc/rc.conf
Code: Select all
sendmail_enable="YES"
sendmail_flags="-L sm-mta -bd -q30m -ODaemonPortOptions=Port=2525"
sendmail_submit_enable="NO"
User avatar
DutchDaemon
Old Fart
 
Posts: 10464
Joined: 16 Nov 2008, 20:17
Location: The Netherlands

Postby UncleBob » 29 Jul 2009, 08:24

Wow,

Thank you for your time! I'll try this approach.

There will be antispam proxy on external port 25, so I guess localhost:25 is fine to leave for sendmail.
UncleBob
Junior Member
 
Posts: 2
Joined: 28 Jul 2009, 14:14

Postby SirDice » 29 Jul 2009, 09:15

UncleBob wrote:There will be antispam proxy on external port 25, so I guess localhost:25 is fine to leave for sendmail.

In that case simply running sendmail in local-submit-only mode should do. Just have the anti-spam proxy deliver it's mail to localhost:25.

Setting sendmail_enable="NO" in /etc/rc.conf will make sendmail run in local-submit-only mode.
Senior UNIX Engineer at Unix Support Nederland
Experience is something you don't get until just after you need it.
User avatar
SirDice
Old Fart
 
Posts: 16185
Joined: 17 Nov 2008, 16:50
Location: Rotterdam, Netherlands


Return to Installation and Maintenance of FreeBSD Ports or Packages

Who is online

Users browsing this forum: martino and 3 guests