使用 DNSMASQ 将域名解析为错误 IP

使用 DNSMASQ 将域名解析为错误 IP

我有两台虚拟机,一台装有我的应用程序,它与另一台运行星号(和 centos)的虚拟机通信。应用程序服务器的配置需要指向星号框。为了避免每次在办公室和家里或咖啡店之间移动时都必须更改配置,我想使用 dnsmasq。

我在 Mac 上运行 dnsmasq(根据http://ramonnogueira.wordpress.com/2013/02/09/resolving-vm-hostnames-with-dnsmasq/comment-page-1/#comment-9)。

在 Virtual Box 中,我将 vboxnet1 设置为 10.203.175.1。我的虚拟机肯定是从 dnsmasq 获取其 IP;其 IP 在我指定的范围内。

但是如果我 ping asterisk.vm,它会解析为 10.203.175.1,而不是虚拟机的 IP。知道我可能做错了什么吗?

这是我的 dnsmasq.conf

# Set this to the name of your VirtualBox host-only interface.
# dnsmasq will listen for DHCP and DNS requests on this interface as
# well as the loopback:
interface=vboxnet1

# This option will be forced anyway on OS X so set here to avoid a warning:
bind-interfaces

# Enable the integrated DHCP server, you need
# to supply the range of addresses available for lease and optionally
# a lease time. If you have more than one network, you will need to
# repeat this for each network on which you want to supply DHCP
# service.
# Select a range from the address and netmask shown in VirtualBox's
# host-only network configuration dialog:
dhcp-range=10.203.175.10,10.203.175.20,12h

# The default directory does not exist on OSX and this cause an 
# error when enabling DHCP, set an alternative location here:
dhcp-leasefile=/var/lib/dnsmasq.leases

# Assume anything in the .vm domain is local
#local=/vm/

# Set this (and domain: see below) if you want to have a domain
# automatically added to simple names in a hosts-file.
expand-hosts

# Set the domain for dnsmasq. this is optional, but if it is set, it
# does the following things.
# 1) Allows DHCP hosts to have fully qualified domain names, as long
#     as the domain part matches this setting.
# 2) Sets the "domain" DHCP option thereby potentially setting the
#    domain of all systems configured by DHCP
# 3) Provides the domain part for "expand-hosts"
domain=vm

# This must be the address of you host on the vboxnet0 network
# find this in the VirtualBox host-only network preferences
address=/asterisk.vm/10.203.175.1

答案1

address=/asterisk.vm/10.203.175.1

asterisk.vmdnsmasq 完全按照您的要求执行操作,使用 IP响应请求10.203.175.1。该行应该引用您的虚拟机的 IP。

相关内容