我已经在我的 Mac(Mojave)上使用自制软件为 laravel 安装了代客泊车。根据laravel 的文档,我现在应该能够 ping *.test,但是当我不断收到以下错误时:
ping:无法解析 foobar.test:未知主机
似乎是 dnsmasq 的问题。我已经遵循了这里的所有建议,但似乎没有任何帮助。
# Content of '/Users/<username>/.config/valet/dnsmasq.conf'
address=/.test/127.0.0.1
listen-address=127.0.0.1
我可以看到 .test 的解析器似乎设置正常。下面是输出scutil --dns
DNS configuration
resolver #1
search domain[0] : default
nameserver[0] : 192.168.1.1
if_index : 6 (en0)
flags : Request A records
reach : 0x00020002 (Reachable,Directly Reachable Address)
resolver #2
domain : local
options : mdns
timeout : 5
flags : Request A records
reach : 0x00000000 (Not Reachable)
order : 300000
resolver #3
domain : 254.169.in-addr.arpa
options : mdns
timeout : 5
flags : Request A records
reach : 0x00000000 (Not Reachable)
order : 300200
resolver #4
domain : 8.e.f.ip6.arpa
options : mdns
timeout : 5
flags : Request A records
reach : 0x00000000 (Not Reachable)
order : 300400
resolver #5
domain : 9.e.f.ip6.arpa
options : mdns
timeout : 5
flags : Request A records
reach : 0x00000000 (Not Reachable)
order : 300600
resolver #6
domain : a.e.f.ip6.arpa
options : mdns
timeout : 5
flags : Request A records
reach : 0x00000000 (Not Reachable)
order : 300800
resolver #7
domain : b.e.f.ip6.arpa
options : mdns
timeout : 5
flags : Request A records
reach : 0x00000000 (Not Reachable)
order : 301000
resolver #8
domain : test
nameserver[0] : 127.0.0.1
flags : Request A records, Request AAAA records
reach : 0x00030002 (Reachable,Local Address,Directly Reachable Address)
DNS configuration (for scoped queries)
resolver #1
search domain[0] : default
nameserver[0] : 192.168.1.1
if_index : 6 (en0)
flags : Scoped, Request A records
reach : 0x00020002 (Reachable,Directly Reachable Address)
我还可以看到 dnsmasq 似乎运行正常。这是来自的输出brew services list
:
dnsmasq started root /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
httpd started root /Library/LaunchDaemons/homebrew.mxcl.httpd.plist
mysql started root /Library/LaunchDaemons/homebrew.mxcl.mysql.plist
nginx started root /Library/LaunchDaemons/homebrew.mxcl.nginx.plist
php started root /Library/LaunchDaemons/homebrew.mxcl.php.plist
php@7.1 started root /Library/LaunchDaemons/homebrew.mxcl.php@7.1.plist
php@7.2 started root /Library/LaunchDaemons/homebrew.mxcl.php@7.2.plist
我尝试过的其他事情:
- 在阻止请求的情况下禁用我的防火墙。
- 使用以下命令重新启动 dnsmasq(多次):
sudo brew services restart dnsmasq
- 使用重新安装代客
valet install
- 检查 /etc/hosts 中是否没有冲突的路径
有人有其他建议吗?
编辑:输出sudo brew services restart --verbose dnsmasq
`Stopping `dnsmasq`... (might take a while)
==> Successfully stopped `dnsmasq` (label: homebrew.mxcl.dnsmasq)
==> Generated plist for dnsmasq:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>homebrew.mxcl.dnsmasq</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/opt/dnsmasq/sbin/dnsmasq</string>
<string>--keep-in-foreground</string>
<string>-C</string>
<string>/usr/local/etc/dnsmasq.conf</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
</dict>
</plist>
/bin/launchctl enable system/homebrew.mxcl.dnsmasq
/bin/launchctl bootstrap system /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
==> Successfully started `dnsmasq` (label: homebrew.mxcl.dnsmasq)
编辑2:
我想我现在正在取得进展。我在 console.app 中检查了 dnsmasq,我看到了错误消息:
failed to open pidfile /usr/local/var/run/dnsmasq/dnsmasq.pid: No such file or directory
...导致我来到这里。原来我丢失了dnsmasq
文件夹,cd /usr/local/var/run/
所以我跑了sudo mkdir dnsmasq
,现在 ping 实际上返回以下响应:
PING foobar.test (127.0.0.1): 56 data bytes
Request timeout for icmp_seq 0
Request timeout for icmp_seq 1
Request timeout for icmp_seq 2
Request timeout for icmp_seq 3
Request timeout for icmp_seq 4
Request timeout for icmp_seq 5
Request timeout for icmp_seq 6
Request timeout for icmp_seq 7
...
我不确定这意味着什么或它现在是否有效。
当我在浏览器中访问 foobar.test 时,This site can’t be reached
即使我已经创建了一个具有该名称的项目并使用valet link foobar
.
编辑 3:
通过关闭隐身模式(如此处所述),我现在可以正常工作,但是当我在浏览器中导航到 foobar.test 时仍然可以正常This site can’t be reached
工作。
运行时出现以下错误curl foobar.test --verbose
* Rebuilt URL to: foobar.test/
* Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to foobar.test (127.0.0.1) port 80 (#0)
> GET / HTTP/1.1
> Host: foobar.test
> User-Agent: curl/7.54.0
> Accept: */*
>
* Recv failure: Connection reset by peer
* Closing connection 0
curl: (56) Recv failure: Connection reset by peer
编辑 4
输出cat /usr/local/etc/dnsmasq.conf | grep -i interface
:
# 10.1.2.3 to 192.168.1.1 port 55 (there must be an interface with that
# specified interfaces (and the loopback) give the name of the
# interface (eg eth0) here.
# Repeat the line for more than one interface.
#interface=
# Or you can specify which interface _not_ to listen on
#except-interface=
# If you want dnsmasq to provide only DNS service on an interface,
#no-dhcp-interface=
# even when it is listening on only some interfaces. It then discards
# working even when interfaces come and go and change address. If you
# want dnsmasq to really bind only the interfaces it is listening on,
#bind-interfaces
# that these two Ethernet interfaces will never be in use at the same
# Always give the InfiniBand interface with hardware address