Posts tagged ‘vmware’

29 November, 2013

OSX, VMWare, CentOS, and postfix

by gorthx

(Original title: “mail server arrrgh”)

I’m running VMWare Fusion on my Mac. I often run multiple VMs for testing Postgres on various OSes, and decided it would be fun if I could get system emails from the guests on the mac host. Yeah, “it would be fun”. Even though I was working with Postfix, this task gave me flashbacks to my sendmail experiences many years ago.

This is what I had to do to get it working. This isn’t in the order I did all the steps; there was a ton of trial, error, and wtfery that went on here. Also, this is on a machine that’s behind a few firewalls; probably not something you want to configure on a server that actually has a port open on the Internet. Although it seems that most of the mailserver-related footguns are no longer enabled by default. Caveat Emptor, or something.

Host: Mac OSX Lion 10.7.5
Guests: CentOS 6.4
VMWare: Fusion 4.1.3

Set up postfix on the mac host; starting with the instructions here:

This “worked” in that the simple “telnet to port 25” test worked (see “Useful tools and commands” below), but I had to make some additional changes to receive mail from my guest OSes.

On the Mac host, I made some changes to /etc/postfix/
myhostname = princess
mydomain = localdomain
mydestination = $myhostname, $myhostname.$mydomain, localhost.$mydomain, localhost, mailhost.$mydomain
inet_interfaces =,
mynetworks =,

The value for inet_interfaces is the IP of my vmware interface, obtained from ifconfig. You want the vmware8 interface and it should be a 192.168 address. I just added the whole vmware subnet to mynetworks parameter. You can read more about these parameters in; it is surprisingly well-commented.

I also commented out imap_submit_cred_file line as discussed here I’m not going to bother with this for local use.

‘postfix reload’ did not apply these changes for me; I had to explicitly stop and restart it1:
postfix stop
postfix start

On the guest:
First, I added the vmware host IP to /etc/hosts: princess princess.localdomain mailhost mailhost.localdomain

This worked via the ‘telnet to port 25’ test method, but regular email wasn’t getting delivered; in fact, it was bouncing. Looking into the mail queue, I discovered it was trying to use a completely different IP for its mailhost.

I checked out the ‘hosts’ value in /etc/nsswitch.conf (just grep hosts /etc/nsswitch.conf) and determined that it was set to ‘files dns’, which ordinarily indicates that /etc/hosts should override dns from the vmware dns server. That wasn’t what was happening. A bit of investigation revealed that postfix was already running2, so I had to dink with it on the guests as well.

Fixed by editing /etc/postfix/ (on the guest) to include this:
relayhost = mailhost.localdomain


Thanks to mjm for keeping me sane during this.

Useful tools/commands:
‘postfix status’ # see what postfix thinks it’s doing and get its pid, since the processes aren’t named postfix and therefor ‘ps -ef | grep post’ won’t show them :)

netstat -an | grep ‘\.25 ‘ # see if anything’s listening on port 25:
(master *) :::-->netstat -an | grep '\.25 '
tcp4 0 0 *.* LISTEN
tcp4 0 0 *.* LISTEN

mailq # see status of queued mail messages

[tail|vi|whatever] /var/log/mail.log # see connections, postfix startup/reload, etc

SMTP test program, something like this

You may want this as well:

1 – I’ve since been told it’s better to use launchctl to control processes.
2 – This surprised me, given the other things that are locked down/not available on the CentOS default.

19 October, 2012

My “dev” environment

by gorthx

I’ve been using VMs a lot lately at my new gig. (VMWare, which is a bit slow and crashy for me on the mac.) It’s nice to know that I can muck about with things without having to worry about possibly having to completely rebuild my machine.

Here’s my standard minimal setup, when I’m building a VM from scratch:

Install OS (usually CentOS or Ubuntu), then:
– create a user for yourself if you did a server install
– add yourself to the sudoers file :)
– my personal .rc files

Additional apps/setup:
– VMWare tools:
./ –default
(sometimes seems to require a restart)
– monofur
– configure your terminal profile
– synaptic/yum package manager
– any updates
– vim, if it’s not already installed
– Ubuntu: gconf-editor, then fix the dang window buttons!
– ntp
– git (include command-completion – obtain from repo)
– wireshark
– rrdtool
– trapgen
– latest postgres

Important notes:
You have to re-install VMWare tools after every kernel upgrade.
Snapshots are *not* backups, you actually don’t want to keep them lying around.