# Remote Connection to Sendmail



## sporkit (May 5, 2010)

Hi guys,

Trying to get sendmail to accept connections from any domain and am having some real troubles.  A few questions.


```
Bash >telnet localhost 25
Trying 127.0.0.1...
Connected to localhost.rcn.com.
Escape character is '^]'.
220 sporkit.hopto.org ESMTP Sendmail 8.14.3/8.14.3; Wed, 5 May 2010 16:58:40 -0500 (CDT)
quit
221 2.0.0 sporkit.hopto.org closing connection
Connection closed by foreign host.

Bash >hostname
sporkit.hopto.org
```

I can access the server through localhost no problem.  What is up with the rcn.com hostname though?  They're not even my isp anymore.  You can see my hostname is set as sporkit.hopto.org.  I've looked for where this configuration can be changed, but am not seeing anything.


```
Bash >telnet 127.0.0.1 25
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 sporkit.hopto.org ESMTP Sendmail 8.14.3/8.14.3; Wed, 5 May 2010 16:58:48 -0500 (CDT)
quit
221 2.0.0 sporkit.hopto.org closing connection
Connection closed by foreign host.
```

Connecting through 127.0 I can still access the server.


```
Bash >telnet 192.168.1.155 25
Trying 192.168.1.155...
telnet: connect to address 192.168.1.155: Connection refused
telnet: Unable to connect to remote host
Bash >
```

155 is the address of my server itself.  So I believe this request bonces from my router back to the box.  Shouldn't I be able to connect to my box like this?  Where can I allow 192.168.1.1 to connect?  How can I open up sendmail to receive from anybody?

I believe my ISP is blocking incoming on port 25, so I would first like to verify connectivity before I go accusing them of blocking my traffic.

Any help appreciated! Thanks!


----------



## crsd (May 5, 2010)

sporkit said:
			
		

> Hi guys,
> 
> Trying to get sendmail to accept connections from any domain and am having some real troubles.  A few questions.
> 
> ...



Check /etc/hosts


> ```
> Bash >telnet 127.0.0.1 25
> Trying 127.0.0.1...
> Connected to localhost.
> ...



Sendmail listens on 127.0.0.1 only by default. You need to add sendmail_enable="YES" to /etc/rc.conf to make sendmail listen to network as well.


----------



## sporkit (May 6, 2010)

crsd said:
			
		

> Check /etc/hosts
> 
> 
> Sendmail listens on 127.0.0.1 only by default. You need to add sendmail_enable="YES" to /etc/rc.conf to make sendmail listen to network as well.



I COULD SHOOT MYSELF......

I've been compiling and configuring /etc/mail/freebsd.mc for two days now.  I've had this working in the past and knew I was doing something stupid.

Here's a question.  Where's the line between configuring something in rc.conf and the system leaving it up the program's respective configuration files?  I looked through the documentation for sendmail in the freebsd docs, but never came across this.  What should have tipped me off to set it there?


----------



## crsd (May 6, 2010)

rc.sendmail(8), linked from rc.conf(5), but I have to agree that it isn't that easy to find that info.

And it would be easier/more correct to run `make` once in /etc/mail and to edit your `hostname`.mc instead.


----------



## z662 (May 16, 2011)

crsd said:
			
		

> Sendmail listens on 127.0.0.1 only by default. You need to add
> 
> 
> 
> ...



Are you sure about that?  I have not modified sendmail or its config in any way and have a pretty clean/fresh install of 8.2.  When running *sockstat -4l* It shows sendmail listening remotely.

See output below.


```
[brad@moon /usr/home/brad]$ sockstat -4l
USER     COMMAND    PID   FD PROTO  LOCAL ADDRESS         FOREIGN ADDRESS      
root     sendmail   1160  4  tcp4   127.0.0.1:25          *:*
```


----------



## DutchDaemon (May 17, 2011)

The local address shows it's bound to localhost. Nothing 'remote' can connect to localhost.


----------



## z662 (May 17, 2011)

Is this thread's response not accurate? Or am I failing to understand something?

http://forums.freebsd.org/showthread.php?t=23831

The way I understood it was that although it was currently bound to 127.0.0.1, since it has '*:*' in the foreign address section it is still listening for remote connections.


----------



## z662 (May 17, 2011)

Alright so I HOPE I figured it out.  Please let me know if it's not the case.  If there is no asterisk under local address, and foreign address is '*:*' that means the service is NOT listening remotely.   True?  If not, then I'm still confused based on my above post.

Or is it just simply, if the service has an address bound to 127.0.0.1 then it is only listening locally and all duplicate entries appearing in sockstat -4l are really same socket sharing the same PID?  E.g


```
[brad@moon ~]$ sockstat -4l
USER     COMMAND    PID   FD PROTO  LOCAL ADDRESS         FOREIGN ADDRESS
brad     ssh        1657  4  tcp4   127.0.0.1:6667        *:*
root     sendmail   1160  4  tcp4   127.0.0.1:25          *:*
root     ntpd       929   20 udp4   *:123                 *:*
root     ntpd       929   22 udp4   192.168.0.104:123     *:*
root     ntpd       929   25 udp4   127.0.0.1:123         *:*
```

Meaning that ntpd is only listening locally, and the entries for PID 929 are just listed since the socket is bound locally.

...Shouldn't this stuff be in the manpage?:\


----------



## SirDice (May 17, 2011)

A local address of *:<someport> means it's listening on _all_ addresses of the host. If it's <ipaddress>:<someport> it's listening on that specific IP address.

Localhost or 127.0.0.1 can only connect to/from 127.0.0.0/8. This traffic will never enter or leave a host.

There's no place like 127.0.0.1 :e


----------



## z662 (May 17, 2011)

Maybe I am wording my question wrong, I am more confused about the duplicate entries I guess, and the '*:*' showing in foreign, while it shows a connection in local too.  So for the output in my above post, Is ntpd ONLY listening on local, hence the 127.0.0.1:123 entry, which would take precedence over the '*:*' in foreign?  Again I was under the impression from the similar thread I opened up that the asterisks under foreign meant it was listening on all IP's.   Sorry for the confusion but I really need to understand this output.  Thanks


----------



## DutchDaemon (May 17, 2011)

Just *forget* the 'Foreign Address' column. No one uses it for anything anyway. What is under 'Local Address' is what matters. If something only listens on 127.0.0.1 no one 'external' can connect to it using any of the server's physical interfaces (e.g. LAN, WAN). Again: just omit the 'Foreign Address' column, so it won't confuse you. It'll always be there and always look like that.


----------

