LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Configure sendmail to only allow outgoing email from server IP/hostname (https://www.linuxquestions.org/questions/linux-newbie-8/configure-sendmail-to-only-allow-outgoing-email-from-server-ip-hostname-812639/)

bloki 06-07-2010 06:52 AM

Configure sendmail to only allow outgoing email from server IP/hostname
 
Hello.

How do I check/setup that only the server can send mail (maybe by IP or hostname)?

I have a debian server that sends mail through the PHP mail() function with no problems. The server uses sendmail. My concern is how do I make sure only the server itself can send mails through that server. Because it would be bad if spammers would use it as a relay server.


System:
- Debian Lenny
- PHP5
- Apache2
- MySQL 5
- PHPmyadmin
- Sendmail

bathory 06-07-2010 07:18 AM

Hi,

In most distros sendmail is configure to listen only on the local loopback interface. Run:
Code:

netstat -tan|grep 25
and see if it's listening only on 127.0.0.1.
In this case only localhost can use it as a relay to send mail.
You can also use /etc/mail/relay-domains to add the hosts/IPs you want to use your server as a relay.
Another possibility is to use /etc/mail/access to allow relay based on hosts, IPs, the "From:" field, etc

Regards

bloki 06-07-2010 07:31 AM

...
 
Thanks for the quick reply. I did what you said and I get this. Is that ok?

Code:

netstat -tan|grep 25
tcp        0      0 127.0.0.1:25            0.0.0.0:*              LISTEN
tcp        0      0 xxx.xx.xxx.x:567        xx.xx.xxx.xxx:20254    ESTABLISHED


bathory 06-07-2010 07:38 AM

Yes, since it's listening only on 127.0.0.1:25 it can be used from localhost only

Regards

bloki 06-07-2010 07:42 AM

Thank you very much. Have a nice day.


All times are GMT -5. The time now is 07:08 PM.