Reputation: 29
I'm on a Mac computer. I have a vagrant VM with Postfix installed that doesn't send e-mails when Vagrant's DNS Host resolver is turned on. The Nat DNS Host resolver fixes all sorts of errors that WordPress spits out without the host resolver so I need it. How can I fix Postfix without causing WordPress to start acting funny?
Code in Vagrantfile causing the problem:
config.vm.provider "virtualbox" do |v|
v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
end
Upvotes: 2
Views: 1364
Reputation: 601
I would add this as a comment, but I do not have enough reputation points to do so. However, I still want to contribute to this issue for any future users since I spent significantly more time then I wanted/needed to on this.
On a Ubuntu 14.04 vagrant box I had the same issue as the OP. Through testing I found that updating /etc/resolv.conf
allowed me to have postfix hit our exchange server and still have local NAT DNS resolve for our local dev sites. So something like:
sudo echo "nameserver 8.8.8.8" >> /etc/resolv.conf; sudo service postfix restart;
Oddly, for my configuration/OS updating /var/spool/postfix/etc/resolv.conf
did not work.
I also added this to the Vagrantfile for future use:
config.vm.provision "shell", run: "always", inline: <<-SHELL
sudo echo nameserver 8.8.8.8 >> /etc/resolv.conf
sudo service postfix restart
SHELL
Upvotes: 3
Reputation: 29
Edit Postfix DNS settings to use a DNS setting that is that affected by the Vagrant DNS setting.
To change settings globally, edit /etc/resolv.conf and put in your custom DNS IP (8.8.8.8 is Google's DNS server). This probably will make using the Vagrant shared DNS setting pointless.
To take advantage of both settings (the DNS resolving and a DNS setting for Postfix that works), do something like this:
cd /var/spool/postfix/etc
sed -i 's/nameserver 10.0.2.3/nameserver 8.8.8.8/g' resolv.conf
This changes the DNS server that Postfix uses to 8.8.8.8.
Upvotes: 0