我运行的是小型家庭网络,并且已将DHCP服务器配置为提供具有所有响应的域名。我的MacBook Air(运行10.7.3)将提供的域放在DNS搜索路径中,但没有相应地设置本地域。请注意,在下面的输出中,实际域名已替换为my.example.com,并且IP / MAC地址已被剥离。下面的诊断信息。System Preferences -> Network -> Wi Fi -> Advanced
除了静态设置主机名外,我没有运气,这在网络之间漫游时显然不起作用。还有其他人有其他建议吗?
在/etc/resolv.conf中正确设置了搜索域:
% cat /etc/resolv.conf
#
# Mac OS X Notice
#
# This file is not used by the host name and address resolution
# or the DNS query routing mechanisms used by most processes on
# this Mac OS X system.#
# This file is automatically generated.
#
search my.example.com
nameserver <DNS IP addr>
nameserver <DNS IPv6 addr>
%
但是,hostname -f
不会在FQDN中反映域:
% hostname -f
myhost.local
%
运行tcpdump
并强制进行DHCP更新,可以确认DHCP请求和答复中都存在选项15,但OS X似乎除了设置DNS搜索路径外并未使用该选项。
% sudo tcpdump -n -ien0 -vvvvv udp port 67
tcpdump: listening on en0, link-type EN10MB (Ethernet), capture size 65535 bytes
01:13:25.061622 IP (tos 0x0, ttl 255, id 26061, offset 0, flags [none], proto UDP (17), length 328)
0.0.0.0.68 > 255.255.255.255.67: [udp sum ok] BOOTP/DHCP, Request from <my MAC addr>, length 300, xid 0x463f9f78, Flags [none] (0x0000)
Client-Ethernet-Address <my MAC addr>
Vendor-rfc1048 Extensions
Magic Cookie 0x63825363
DHCP-Message Option 53, length 1: Request
Parameter-Request Option 55, length 9:
Subnet-Mask, Default-Gateway, Domain-Name-Server, Domain-Name
Option 119, LDAP, Option 252, Netbios-Name-Server
Netbios-Node
MSZ Option 57, length 2: 1500
Client-ID Option 61, length 9: "myhost"
Requested-IP Option 50, length 4: <my IP addr>
Lease-Time Option 51, length 4: 7776000
Hostname Option 12, length 8: "myhost"
END Option 255, length 0
PAD Option 0, length 0, occurs 8
01:13:25.068967 IP (tos 0x10, ttl 128, id 0, offset 0, flags [none], proto UDP (17), length 328)
<srv IP addr>.67 > <my IP addr>.68: [udp sum ok] BOOTP/DHCP, Reply, length 300, xid 0x463f9f78, Flags [none] (0x0000)
Your-IP <my IP addr>
Client-Ethernet-Address <my MAC addr>
Vendor-rfc1048 Extensions
Magic Cookie 0x63825363
DHCP-Message Option 53, length 1: ACK
Server-ID Option 54, length 4: <srv IP addr>
Lease-Time Option 51, length 4: 86400
Subnet-Mask Option 1, length 4: <subnet mask>
Default-Gateway Option 3, length 4: <my IP addr>
Domain-Name-Server Option 6, length 4: <DNS IP addr>
Domain-Name Option 15, length 13: "my.example.com"
END Option 255, length 0
PAD Option 0, length 0, occurs 11
^C
2 packets captured
1458 packets received by filter
0 packets dropped by kernel
还要注意:
—
伊夫史密斯2012年
/etc/resolv.conf
不使用。检查检查时得到的响应man /etc/resolv.conf
。
@ephsmith我得到“未设置”。(系统现在正在运行的山狮,但行为似乎并没有发生变化。
—
穆拉利Suriar
OS X从DNS而不是从DHCP获得它的主机名。如果要分配正确的主机名,则需要使A / AAAA / PTR条目解析。
—
MacLemon 2012年
scutil --get HostName
回报?我没有配置主机名,它返回“未设置”。如果看到man scutil
,您会注意到您的计算机名称,.local名称(Bonjour名称)和主机名显然不相等。