I have a LAN with IP range 192.168.2.* and the following configuration:
There is a router of address 192.168.2.1
There is a MacOS machine of address 192.168.2.11
There is a vagrant (virtual box) CentOS 7 machine of address 192.168.2.150, with httpd installed and accessible via http://192.168.2.150/index.html
from the MacOS machine using Google Chrome
There is another vagrant (virtual box) CentOS 7 machine of address 192.168.2.250, with dnsmasq installed and configured with host file line 192.168.2.150 test.mysite.com
Here is what worked:
i. In the MacOS machine's system preference, open "Network" and "Advanced", choose "DNS" tab and add the DNS server 192.168.2.250
ii. Access http://test.mysite.com/index.html
from Google Chrome in MacOS, the web page will appear correctly
Here is what did not work:
i. Remove all entries from MacOS's system preference
ii. Open the router's admin page at 192.168.2.1 and set the Primary DNS address to be 192.168.2.250
iii. Access http://test.mysite.com/index.html
from Google Chrome in MacOS, the web page will load for a minute and show an error cannot reach the site (DNS_PROBE_FINISHED_BAD_CONFIG), nslookup on the MacOS machine shows ";; connection timed out; no servers could be reached"
sudo systemctl status dnsmasq
shows localhost.localdomain dnsmasq[7102]: read /etc/hosts - 4 addresses
so hosts file is being read on the dnsmasq site
I think there's something wrong in my dnsmasq.conf but I could not figure out. The current complete conf is shown as below:
domain-needed
bogus-priv
strict-order
listen-address=127.0.0.1,192.168.2.250
conf-dir=/etc/dnsmasq.d,.rpmnew,.rpmsave,.rpmorig
The resolv.conf files is as follows: (192.168.1.1 is the original DNS used by the router and I want to forward anything other than mysite.com back to it)
# Generated by NetworkManager
search ctc
nameserver 192.168.1.1
options single-request-reopen
The hosts file is as follows:
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.2.150 test.mysite.com
192.168.2.200 test2.mysite.com
(There is an extra entry but I don't think it matters here)
I am pretty much stuck at this point. Any help would be appreciated.