MTA errors at startup

Hi to you all, I'm back to home after several months in a 'strange land' and reconfigured my machines (and virtual machines) to connect back to my network. However I made a mistake somewhere in a VM FreeBSD installation.

About one month ago I upgraded the system from 9.0-RELEASE to 9.1-RELEASE with freebsd-update. All went well, but I guess I turned off the host in the while (I wasn't at home, when I come back I turned off the machine), but all worked ok, there was only one file (in /etc) I merged by hand, the automatic merge left it with both old (9.0) and new (9.1) text.

On Saturday (a few days ago) I reconfigured the IP address to use the DHCP on my network and all works ok, apache22 is up and works ok, the DNS resolution works ok (named on my home server), but there are MTA errors (sendmail?) at start-up I don't understand. I never touched the sendmail configuration, I adjusted /etc/resolv.conf, /etc/rc.conf and /etc/hosts.

So, attached files are: last (this morning) dmesg -a result and today messages from /var/log/messages.

uname -a
Code:
FreeBSD beta.freethread.lan 9.1-RELEASE-p4 FreeBSD 9.1-RELEASE-p4 #0: Mon Jun 17 11:38:17 UTC 2013
root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC  i386

Thanks in advance for your suggestions.

dmesg
messages
 
Looks like something is already occupying port 25. Can you be starting more than one MTA, or Sendmail twice? What does sockstat -l4p25 produce? Also, have you re-run the proper make commands in /etc/mail to update your .cf files?
 
Yes, it seems port 25 is not free when the MTA is binding to it. I ran nmap twice.

nmap -sV -v -v -v localhost
Code:
Starting Nmap 6.25 ( http://nmap.org ) at 2013-07-25 13:00 CEST
NSE: Loaded 19 scripts for scanning.
Initiating Ping Scan at 13:00
Scanning localhost (198.153.192.3) [4 ports]
Completed Ping Scan at 13:00, 0.21s elapsed (1 total hosts)
Initiating Parallel DNS resolution of 1 host. at 13:00
Completed Parallel DNS resolution of 1 host. at 13:00, 0.21s elapsed
DNS resolution of 1 IPs took 0.21s. Mode: Async [#: 1, OK: 0, NX: 1, DR: 0, SF: 0, TR: 1, CN: 0]
Initiating SYN Stealth Scan at 13:00
Scanning localhost (198.153.192.3) [1000 ports]
Discovered open port 80/tcp on 198.153.192.3
Completed SYN Stealth Scan at 13:01, 21.77s elapsed (1000 total ports)
Initiating Service scan at 13:01
Scanning 1 service on localhost (198.153.192.3)
Completed Service scan at 13:01, 6.43s elapsed (1 service on 1 host)
NSE: Script scanning 198.153.192.3.
NSE: Starting runlevel 1 (of 1) scan.
Nmap scan report for localhost (198.153.192.3)
Host is up (0.10s latency).
Scanned at 2013-07-25 13:00:59 CEST for 29s
Not shown: 998 filtered ports
PORT    STATE  SERVICE VERSION
80/tcp  open   http    nginx 0.8.54
443/tcp closed https

Read data files from: /usr/local/share/nmap
Service detection performed. Please report any incorrect results at http://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 29.94 seconds
           Raw packets sent: 3015 (132.636KB) | Rcvd: 18 (724B)

nmap -sV -v -v -v beta.freethread.lan
Code:
Starting Nmap 6.25 ( http://nmap.org ) at 2013-07-25 13:02 CEST
NSE: Loaded 19 scripts for scanning.
Initiating Parallel DNS resolution of 1 host. at 13:02
Completed Parallel DNS resolution of 1 host. at 13:02, 0.01s elapsed
DNS resolution of 1 IPs took 0.01s. Mode: Async [#: 1, OK: 1, NX: 0, DR: 0, SF: 0, TR: 1, CN: 0]
Initiating SYN Stealth Scan at 13:02
Scanning beta.freethread.lan (192.168.1.100) [1000 ports]
Discovered open port 80/tcp on 192.168.1.100
Discovered open port 22/tcp on 192.168.1.100
Increasing send delay for 192.168.1.100 from 0 to 5 due to 78 out of 259 dropped probes since last increase.
Increasing send delay for 192.168.1.100 from 5 to 10 due to max_successful_tryno increase to 4
Increasing send delay for 192.168.1.100 from 10 to 20 due to max_successful_tryno increase to 5
Increasing send delay for 192.168.1.100 from 20 to 40 due to max_successful_tryno increase to 6
Increasing send delay for 192.168.1.100 from 40 to 80 due to max_successful_tryno increase to 7
Completed SYN Stealth Scan at 13:02, 18.34s elapsed (1000 total ports)
Initiating Service scan at 13:02
Scanning 2 services on beta.freethread.lan (192.168.1.100)
Completed Service scan at 13:02, 1.12s elapsed (2 services on 1 host)
NSE: Script scanning 192.168.1.100.
NSE: Starting runlevel 1 (of 1) scan.
Initiating NSE at 13:02
Completed NSE at 13:03, 1.10s elapsed
Nmap scan report for beta.freethread.lan (192.168.1.100)
Host is up (0.00045s latency).
Scanned at 2013-07-25 13:02:39 CEST for 21s
Not shown: 998 closed ports
PORT   STATE SERVICE    VERSION
22/tcp open  ssh        OpenSSH 5.8p2_hpn13v11 (FreeBSD 20110503; protocol 2.0)
80/tcp open  tcpwrapped
Service Info: OS: FreeBSD; CPE: cpe:/o:freebsd:freebsd

Read data files from: /usr/local/share/nmap
Service detection performed. Please report any incorrect results at http://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 21.75 seconds
           Raw packets sent: 1286 (56.584KB) | Rcvd: 2576 (108.260KB)

Scanning localhost the IP address is 198.153.192.3 (Symantec?) while scanning beta.freethread.lan the IP address is 192.168.1.100 (right). Here there's something strange (I don't have any Symantec products installed on machines in my network (FreeBSD and Windows).

I never touched sendmail configuration files, well I don't exactly remember, what I have perhaps done was changing some alias in /etc/mail/aliases and then ran newaliases more than one year ago.

UPDATE
I forgot this
sockstat -l4p25
Code:
USER     COMMAND    PID   FD PROTO  LOCAL ADDRESS         FOREIGN ADDRESS
It say none.
 
Can't you just run sockstat(1) on the host itself as suggested by DD? Using nmap is like hitting the problem with a hammer when more suitable tools are available.
 
kpa said:
Can't you just run sockstat(1) on the host itself as suggested by DD?

Yes, it's at the end of my previous post (edited). It returns nothing.

kpa said:
Using nmap is like hitting the problem with a hammer when more suitable tools are available.

Eh eh, my toolbox is full of hammers :) However I don't know what are the appropriate commands to run to solve this, the strange thing is the localhost IP address.
 
I get the feeling it's not so much the SMTP port but the address which is causing the problems:

Code:
Jul 25 11:11:17 beta sm-mta[810]: daemon Daemon0: problem creating SMTP socket
Jul 25 11:11:22 beta sm-mta[810]: NOQUEUE: SYSERR(root): opendaemonsocket: daemon Daemon0: cannot bind: Can't assign requested address

And I remember reading more often about daemons which create some problems during startup whenever you're using DHCP. So if you happen to have configured DHCP in /etc/rc.conf using the DHCP keyword you might want to try and change that into SYNCDHCP. For more information on that see the FreeBSD handbook on DHCP.
 
freethread said:
However I don't know what are the appropriate commands to run to solve this, the strange thing is the localhost IP address.
Simple; if you need to test if a certain port is open you'd either use sockstat as @DutchDaemon has already shown, or you simply try to make a connection yourself. Don't forget that these daemons all use plain text. So checking the SMTP port could be done as follows:

Code:
smtp2:/home/peter $ telnet localhost 25
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 smtp2.xxx.com ESMTP Postfix
[I]quit[/I]
221 2.0.0 Bye
Connection closed by foreign host.
So something is obviously listening on port 25 on my server.

A better way (in my opinion) is of course using sockstat, as shown in a previous message.
 
Last edited by a moderator:
The output in the first post shows lots of configuration errors. Please show the contents of /etc/rc.conf.
 
ShelLuser said:
And I remember reading more often about daemons which create some problems during startup whenever you're using DHCP. So if you happen to have configured DHCP in /etc/rc.conf using the DHCP keyword you might want to try and change that into SYNCDHCP. For more information on that see the FreeBSD handbook on DHCP.

Oops, I don't have the DHCP client enabled, it's static for the HTTP server.

wblock@ said:
The output in the first post shows lots of config errors. Please show the contents of /etc/rc.conf.

Code:
# rc.conf

# Set dumpdev to "AUTO" to enable crash dumps, "NO" to disable
dumpdev="NO"

#-----------------
# VirtualBox guest
vboxguest_enable="YES"
vboxservice_enable="YES"

#--------------
# Energy saving
#powerd_enable="YES"
#powerd_flags="-a adaptive"

#---------------
# System console
allscreens_flags="MODE_325"
font8x8="swiss-8x8"
font8x14="swiss-8x14"
font8x16="swiss-8x16"
keymap="it.iso.kbd"
keyrate="fast"
moused_enable="NO"

#--------
# Network
hostname="beta.freethread.lan"
ifconfig_em0=" inet 192.168.1.100 netmask 255.255.255.0"
#ifconfig_pcn0=" inet 192.168.1.100 netmask 255.255.255.0"
defaultrouter="192.168.1.1"

#------------
# SSH service
sshd_enable="YES"

#-----------
# NTP client
ntpdate_enable="YES"
ntpdate_flags="freethread.lan"

#---------------------
# httpd Apache service
apache22_enable="YES"

#--------------
# D-Bus service
dbus_enable="YES"

#---------------
# FuseFS service
fusefs_enable="YES"

I have also seen those errors, perhaps the mergemaster left something in /etc/default/rc.conf, I'm checking all /etc files for errors (that I'm able to recognize).
 
When using a static IP address, netwait helps to make sure it's up and running before services get started:
/etc/rc.conf
Code:
netwait_enable="YES"
netwait_ip="ip.address.to.ping"
netwait_timeout="60"
netwait_if="em0"
netwait_if_timeout="60"

As far as the service(8) errors, check for /etc/rc.local, or an entry in the system /etc/crontab or root's crontab. Something, probably a script, is trying to use service(8) to start or restart all those services.
 
Ok, thanks for netwait, I will try it soon.

The service errors are related to my command # service -e | sort -f to see if sendmail was running (it's running). However I guess I have not restored all DNS and IP address configurations:

# host localhost
Code:
localhost.192.168.1.5 has address 198.153.192.3

The routable IP is from Symantec NortonDNS (forwarded by my DNS). The name localhost.192.168.1.5 I guess is derived from the hosts file:

Code:
127.0.0.1      localhosts localhosts.freethread.lan
::1            localhosts localhosts.freethread.lan

Both the domain name freethread.lan and my home server alpha.freethread.lan have IP 192.168.1.5.
 
Add the standard localhost entries back to /etc/hosts:

Code:
::1                     localhost localhost.my.domain
127.0.0.1               localhost localhost.my.domain

It's better not to mess with those because there are many places where it is assumed that localhost equals 127.0.0.1 or ::1 (IPv6) and vice versa.
 
kpa said:
Add the standard localhost entries back to /etc/hosts:

Code:
::1                     localhost localhost.my.domain
127.0.0.1               localhost localhost.my.domain

It's better not to mess with those because there are many places where it is assumed that localhost equals 127.0.0.1 or ::1 (IPv6) and vice versa.

Yes, but /etc/hosts state to replace my.domain with my network domain name:
Code:
# Host Database
#
# This file should contain the addresses and aliases for local hosts that
# share this file.  [B]Replace 'my.domain' below with the domainname of your
# machine[/B].
#
# In the presence of the domain name service or NIS, this file may
# not be consulted at all; see /etc/nsswitch.conf for the resolution order.

The resolv.conf is:
Code:
search 192.168.1.5
nameserver 192.168.1.5

The nsswitch.conf is:
Code:
group: compat
group_compat: nis
[b]hosts: dns files[/b]
networks: files
passwd: compat
passwd_compat: nis
shells: files
services: compat
services_compat: nis
protocols: files
rpc: files

I am tempted to remove at all
Code:
localhost.freethread.lan
or
Code:
localhost.my.domain
from /etc/hosts.

Thanks @kpa I will try to restore it, but I still have to try netwait as suggested by @wblock.
 
Last edited by a moderator:
I solved this in some way that I will explain later. First of all, sorry @kpa about mine post (#11)

Code:
127.0.0.1      localhosts localhosts.freethread.lan
::1            localhosts localhosts.freethread.lan

and your post (#12)

Code:
::1                     localhost localhost.my.domain
127.0.0.1               localhost localhost.my.domain

I made a mistake (localhosts instead of localhost), anyhow I written directly by hand and not copied from file, in file it was localhost. I'm sorry, didn't catch your correction.

Solution:

I modified the /etc/hosts file this way

Code:
::1                     localhost       # localhost.freethread.lan
127.0.0.1               localhost       # localhost.freethread.lan

that is, I commented the 'domained' localhost.

I restored the default /etc/nsswitch.conf file

Code:
group: compat
group_compat: nis
[B]hosts: files dns[/B]
networks: files
passwd: compat
passwd_compat: nis
shells: files
services: compat
services_compat: nis
protocols: files
rpc: files

Now it works, but before I mark this thread solved I appreciate your comments about this.

As a last note, before and after the solution, the result of some host commands was/is:

# host localhost
Code:
localhost.192.168.1.5 has address 198.153.192.3

# host localhost.freethread.lan
Code:
localhost.freethread.lan has address 127.0.0.1

# host localhost.
Code:
localhost has address 127.0.0.1
localhost has IPv6 address ::1

That's not what I expect from the first command, but now the MTA is quiet. Thanks.
 
Last edited by a moderator:
Back
Top