# Postfix localhost not found / resolved

## lostinspace2011

I have two DNS servers on my network. One hosted on my Gentoo Linux server and another provided by my router/modem. When I use the routers one I am able to send and receive emails on my linux server without problems. 

/etc/resolve.conf

```
nameserver 192.168.0.1
```

I then change the file to 

/etc/resolve.conf

```
nameserver 192.168.0.4
```

And now all messages are bounces with error:

 *Quote:*   

> 
> 
> Host or domain name not found. Name service error for name=localhost type=A: Host not found
> 
> 

 

Using the dig command I am able to resolve localhost on both servers:

 *Quote:*   

> bumblebee postfix # dig @192.168.0.1 localhost
> 
> ; <<>> DiG 9.7.1 <<>> @192.168.0.1 localhost
> 
> ; (1 server found)
> ...

 

After some googling I found a suggestion to change

```

bumblebee postfix # postconf -e 'smtp_host_lookup = dns, native'

bumblebee postfix # postconf |grep lookup

...

smtp_host_lookup = dns, native

...

```

Previously it was set to smtp_host_lookup = dns. This fixed the problem, however I don't understand why it didn't work before. Since only DNS was specified and both my DNS servers resolve localhost correctly I am confused on the cause of this issue. Maybe my postfix chroot'd environment didn't have a valid hosts file. I checked and couldn't find on in /var/spool/postfix/. I couldn't even find a etc folder in there. So maybe I am not running chroot'd. 

Any insight into this is truly appreciated.

Thanks in advance

Alex

----------

## lostinspace2011

I played some more with this setting but can't understand what type of DNS query postfix performs which fails. Querying for a specific MX record returns no results so maybe that is it. However in my testing I got this from both DNS servers. 

Adding native to this parameter includes the /etc/nsswitch.conf file. Here is mine. What is strange is that it specifies files (hosts file), mdnsd and then dns as the resolution mechanism so it ends up using my DNS in any case.

```

# /etc/nsswitch.conf:

# $Header: /var/cvsroot/gentoo/src/patchsets/glibc/extra/etc/nsswitch.conf,v 1.1 2006/09/29 23:52:23 vapier Exp $

passwd:      compat

shadow:      compat

group:       compat

# passwd:    db files nis

# shadow:    db files nis

# group:     db files nis

hosts:       files mdnsd dns

networks:    files dns

services:    db files

protocols:   db files

rpc:         db files

ethers:      db files

netmasks:    files

netgroup:    files

bootparams:  files

automount:   files

aliases:     files

bumblebee ~ #

```

Any suggestions on what to look at.

Alex

----------

