How can I have Postfix use /etc/hosts before doing a DNS lookup?

I have in /etc/hosts:  burritos

If I ping I get I can also telnet burritos 25 and I can deliver mail through mail from, rcpt to, data commands.

I have Postfix configured to deliver mail for locally, but it forwards mail for to server burritos.

The problem is Postfix does a DNS lookup regardless. It does not look into /etc/hosts. I don't have an A record for because I want it to only receive mail internally. I don't run a DNS server internally (which could obviously fix the problem, but is more complication than I'd like.)

/etc/host.conf says:
order hosts,bind
multi on
nospoof on
spoofalert on

I don't want to disable DNS lookups entirely. I just want for Postfix to check /etc/hosts first. Is that possible?

Who is Participating?
bevhostConnect With a Mentor Commented:

Basically there is a file /etc/postfix/transport which contains a list of domain anmes and where the mail for thos domains should be routed to.  This routing table overrides and DNS settings.    smtp:[]

The [] brakets around the name tells the smtpd process not to try to look up the MX record for the target.
means send mail for to the MX record for    smtp:[]
means send mail for to the A record for    smtp:[]
means send mail for to server at

if you change the transport file you must
# postmap transport
# postfix reload

If you receive mail from external sources and you want to relay to transport destinations then you also need this in your file

relay_domains = $transport_maps

for the transport file to do anything you need this in your

transport_maps = hash:/etc/postfix/transport

check /etc/nsswitch.conf and look for a line similar to

hosts:      files dns

which should check /etc/hosts first then dns
edit your /etc/nsswitch.conf file

change this line
hosts:      dns nis files

put files first
Worried about phishing attacks?

90% of attacks start with a phish. It’s critical that IT admins and MSSPs have the right security in place to protect their end users from these phishing attacks. Check out our latest feature brief for tips and tricks to keep your employees off a hackers line!

omarfarid:  good timing :-)
same minute :)
:) same answer
Why not just have the transport table use the IP address instead of a name:
eg:    smtp:[]

Then you don't need to mess with the name resolution on your machine.
omniumnetworkingAuthor Commented:
My /etc/nsswitch.conf already contains:
hosts:          files nis dns

I had checked that too.

I don't have anything on my transport table, so you'd have to be more specific.

on re-reading that I notice a few typos, but you get the idea (I hope)
For anyone reading this question who has sendmail instead of postfix,
The transport file is called /etc/mail/mailertable
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.