Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I am from a Linux background with a fair amount of Windows knowledge too but I find myself in the curious position of having to look after someone's macbook air. I am totally new to OSX.

I would appreciate some guidance to help me understand how the computer's host and domain names are configured when a basic DHCP client networking is being used.

So far, I understand there are several names including a Computer Name and a host name. By default the computer name is a wordy description (like "Fred's MacBook Air") and I have found this prevents the correct host name being published by the DHCP/DNS server. I found changing the computer name to "myhost" fixed this.

I assume the FQDN is obtained from the DHCP server and this sets the search domains to "mydomain.com" - if not then I'd like to understand how is this set - because on the network settings DNS screen it is displayed but greyed out.

The "domainname" command in a terminal returns nothing. The file /etc/resolv.conf has a big banner saying it isn't used. Something is setting the machine's domain name and, here's the rub: it's inserting backslashes into it.

This can be seen on the sharing page for remote logins where it says To log in to this computer remotely, type "ssh myname@myhost.mydomain\.com". It can also be experienced via the mail app because this sends a bad HELO to the SMTP server when sending mail, causing the send to fail (trying to fix this is the original reason I set off down this path of enlightenment).

So, rambling on a bit, I guess my question distils down to

(a) an explanation of host/domain name/network configuration on OSX would be greatly appreciated, and (b) how to I set the domain name so that it does not have backslashes in it ?

share|improve this question

closed as off-topic by Falcon Momot, mdpc, Jenny D, Dave M, kce Jan 31 at 20:53

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions must be relevant to professional system administration. Server Fault is dedicated to professional system and network administrators. End user and enthusiast questions are off-topic (contact your system administrator or hire a professional to help you out). Please see the Help Center for more information." – Falcon Momot, mdpc, Jenny D, Dave M, kce
If this question can be reworded to fit the rules in the help center, please edit the question.

2 Answers 2

I believe the command you want is scutil --set HostName name-of-host
I don't believe Mac OS X sets a standard FQDN hostname by default (just a .local (Bonjour) host name. You can get more detailed information from the man pages of scutil and hostname.
BTW, if you need to flush/reset the DNS cache, do this sudo killall -HUP mDNSResponder

share|improve this answer
    
Am I supposed to set name-of-host to a FQDN? Currently (as reported by scutil --get) it is simply "myhost". Also, I did a scutil --dns and that showed the search domain correctly (e.g. mydomain.com without a backslash) but the sharing screen still shows a backslash. –  starfry Apr 23 '13 at 15:09
    
@starfry On my 10.8 Macbook, I had to use scutil --set HostName host.example.com to set a FQDN and setup a DNS A record (and associated Reverse Mapping) in order for the URL in Sharing preferences to show the hostname in the vnc:// URL. Otherwise it just showed vnc://<my IP address> If you suspect something is corrupted with the network settings you can delete this file and reset them to defaults -- /Library/Preferences/SystemConfiguration/preferences.plist –  race_carr Apr 23 '13 at 22:03
    
Well I tried that and it made no difference (I could use scutil to change HostName to a FQDN but it didn't change what was displayed on the sharing page under remote login and it didn't fix the inability of Mail to send. So, yes, I can set HostName to a FQDN i this way but it didn't resolve my issue. –  starfry Apr 24 '13 at 14:16
    
Sorry that hasn't helped much. I'm stumped as to why the random backslash is showing up. Does the same hostname show up in other Services in the Sharing Preference Pane? Your fallback might be resetting to defaults (blank hostname) as described in my previous comment. –  race_carr Apr 26 '13 at 2:07

there are three scutil --set commands you have to issue:

scutil --set HostName NameOfHost

scutil --set LocalHostName NameOfHost

scutil --set ComputerName NameOfHost

share|improve this answer

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