Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I run a small home network, and have configured my DHCP server to provide a domain name with all responses. My MacBook Air (running 10.7.3) places the provided domain in the DNS search path, but does not set the local domain accordingly. Note, the actual domain name has been replaced with my.example.com in the output below, and IP/MAC addresses have been stripped. Diagnostic information below. I've poked around in System Preferences -> Network -> Wi Fi -> Advanced with no luck, other than statically setting the hostname, which obviously doesn't work if I roam between networks. Does anyone else have any other suggestions?


The search domain is set correctly in /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>
%

However, hostname -f doesn't reflect the domain in the FQDN:

% hostname -f
myhost.local
%

Running tcpdump and forcing a DHCP renewal confirms that option 15 is present in both the DHCP request and reply, but seemingly isn't being used by OS X other than to set the DNS search path.

% 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
share|improve this question
    
What does scutil --get HostName return? I don't configure my hostname, and it returns "not set". If you see man scutil, you'll notice that you're computer name, .local name (Bonjour name) and hostname are apparently not equal. –  ephsmith Aug 19 '12 at 0:10
    
Also of note: /etc/resolv.conf is not used. Check the response you get when checking man /etc/resolv.conf. –  ephsmith Aug 19 '12 at 0:14
    
@ephsmith I get 'not set'. (System now running Mountain Lion, but the behaviour doesn't seem to have changed. –  Murali Suriar Aug 20 '12 at 21:00
    
OS X get's it hostnames from DNS, not from DHCP. If you want to assign proper hostnames, you need to make A/AAAA/PTR entries resolve. –  MacLemon Dec 6 '12 at 11:34
add comment

1 Answer

Not understanding whats exactly your problem. Maybe this can help you.

If you set the search option, in your own config (network->advanced->dns->search domains) or by your dhcp server. You basically eliminate the need to add this part to a fqdn.

Example:

search: foo.com

then,

ping test

would try to resolve test.foo.com

So, in your case that would be test.my.example.com

Futhermore, setting your local name, you can change under:

Sharing -> Edit...

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.