Go Back   MacRumors Forums > Apple Systems and Services > OS X > Mac OS X Server, Xserve, and Networking

Reply
 
Thread Tools Search this Thread Display Modes
Old Aug 11, 2011, 01:19 PM   #1
vigu360
macrumors member
 
Join Date: Oct 2009
Location: Canada
How to remove .local suffix from name?

When I ssh or do something with the Mac I need to enter <MacName>.local . Is there a way I can change it to just <MacName> (eg server.local --> server)? In unix we need to change /etc/hosts/ file what's the equivalent in Mac OS X?
vigu360 is offline   1 Reply With Quote
Old Aug 11, 2011, 02:36 PM   #2
jtara
macrumors 65816
 
Join Date: Mar 2009
Quote:
Originally Posted by vigu360 View Post
In unix we need to change /etc/hosts/ file what's the equivalent in Mac OS X?
It's....



.... drumroll.....

/etc/hosts
jtara is offline   3 Reply With Quote
Old Aug 11, 2011, 08:58 PM   #3
jtara
macrumors 65816
 
Join Date: Mar 2009
However, a better way to do this is on your router, if it supports a hosts table. I use OpenWRT, which does.
jtara is offline   -1 Reply With Quote
Old Aug 12, 2011, 04:00 AM   #4
Tazjin
macrumors newbie
 
Join Date: Aug 2010
Quote:
Originally Posted by vigu360 View Post
In unix we need to...
You are aware that the OS X Kernel (Darwin) is UNIX, right?
Tazjin is offline   0 Reply With Quote
Old Aug 12, 2011, 11:09 AM   #5
Darth.Titan
macrumors 68020
 
Darth.Titan's Avatar
 
Join Date: Oct 2007
Yes OS X does have an /etc/hosts file, but it won't solve the OP's problem.

OP, in Terminal, try:
Code:
sudo scutil --set HostName your_new_hostname
Darth.Titan is offline   1 Reply With Quote
Old Aug 12, 2011, 02:37 PM   #6
jtara
macrumors 65816
 
Join Date: Mar 2009
Quote:
Originally Posted by Darth.Titan View Post
Yes OS X does have an /etc/hosts file, but it won't solve the OP's problem.
Actually, upon re-reading, it's not clear exactly WHAT the OPs problem actually is. Can you be more specific?

FROM what computer TO what computer? And what is the OS on each computer?

.local isn't a part of your host name. It's the TLD used by ZeroConf. ZeroConf is a "distributed DNS" scheme that allows each machine in a local network to provide it's OWN "DNS". This is quite apart from the standard DNS system.

So, changing the host name on the destination computer isn't going to get rid of the .local, because .local ISN'T part of that host name.

Any local machine that has ZeroConf enabled and is set-up to advertise services can be accessed in the .local domain.

If you want to have a non-zeroconf local domain, you can do so, you just can't call it .local. For example, I use .lan. You either need a DNS server on your network or you can set this up in local /etc/hosts (or equivalent) files on each machine.

You can also have hosts that don't have a TLD, which I THINK is what the OP is asking for. Again, this requires that you have either a local DNS server (I have one on my router) or that you make entries in /etc/hosts on each computer.
jtara is offline   0 Reply With Quote
Old Aug 12, 2011, 04:00 PM   #7
Darth.Titan
macrumors 68020
 
Darth.Titan's Avatar
 
Join Date: Oct 2007
Quote:
Originally Posted by jtara View Post
.local isn't a part of your host name.
I beg to differ. Typing "hostname" into the Terminal gets me Mac-Pro.local
It is indeed part of the host name.

However the rest of your post is spot on. The OP removing the .local from his hostname is not going to magically make his computer visible on the network by typing just the name. A DNS on the network would be the only thing to do aside from editing all the other /hosts files on the network.
Darth.Titan is offline   1 Reply With Quote
Old Aug 12, 2011, 04:48 PM   #8
Alrescha
macrumors 65816
 
Join Date: Jan 2008
Location: Boston, MA
If the OP doesn't want to have to type the 'local' part of the hostname, then I suggest that the solution is to add 'local' to the search domain in /etc/resolv.conf.

A.
Alrescha is offline   1 Reply With Quote
Old Aug 12, 2011, 06:32 PM   #9
jtara
macrumors 65816
 
Join Date: Mar 2009
Quote:
Originally Posted by Darth.Titan View Post
I beg to differ. Typing "hostname" into the Terminal gets me Mac-Pro.local
That's because the "hostname" command tags-on the domain. But the domain is NOT part of the hostname.

To display the real hostname, use "hostname -s".

You can also see it in System Preferences, Sharing. It's at the top, "Computer Name".

If you hit edit, you will see the "local hostname", and can edit it. Here you will see the .local TLD, but note that you CANNOT remove .local - it's greyed out. This is because ".local" is NOT part of the computer name! They are just being helpful and showing you how to address the computer on your local subnet. i.e. you need to tag .local onto it.

Setting the host name without "local" using scutil as shown above will set the host name to....


... another drumroll....

exactly what it is currently!

Quote:
It is indeed part of the host name.
No, it isn't. See above.

There does seem to be a lot of confusion about this. Lots of posts on the net asking for the opposite of this. That is, wanting to ADD .local to their hostname. Guess what happens if you try to add .local to your hostname? It gets removed. Otherwise it would be myhost.local.local

I'm assuming these people (wanting to ADD .local) are trying to access their computer from another computer that doesn't have a Bonjour/Zeroconf resolver installed, so doesn't know about the .local TLD. It's never correct to set a hostname with a .local suffix or to have a .local TLD in DNS. .local is reserved for Bonjour/Zeroconf.

---------- Post added at 03:32 PM ---------- Previous post was at 03:30 PM ----------

Quote:
Originally Posted by Alrescha View Post
If the OP doesn't want to have to type the 'local' part of the hostname, then I suggest that the solution is to add 'local' to the search domain in /etc/resolv.conf.

A.
Yes, that's another way to do it.

To clarify, this would need to be done on every OTHER computer in the network. It's telling it "when I use a hostname without a suffix, automatically appened add ".local".
jtara is offline   -1 Reply With Quote
Old Aug 12, 2011, 07:23 PM   #10
throttlemeister
macrumors 6502
 
Join Date: Mar 2009
Location: Netherlands
Let's try to clear up some of the semantic confusion.

A hostname is a name for a host, consisting of an alphanumeric string without dots.

A domain name is a name for a domain, consisting of an alphanumeric string that can contain dots. If it contains dots, it indicates one or more subdomains.

A hostname can be appended by a domain name, with the both of them separated by a dot to create a FQDN (fully qualified domain name).

If you see something like aaaa.bbbb.cccc.dddd.eeee, the hostname is only the aaaa part. The rest of it is the domain, with bbbb being a subdomain of cccc being a subdomain of 'real' domain dddd which is actually a subdomain of TLD eeee. The left most part before the first dot is ALWAYS the hostname, while the right most part after the last dot is ALWAYS the TLD.
__________________
Macbook Pro 2.93 | 8GB | 120GB OWC Extreme Pro + 320GB/7200rpm | 24" LED Cinema Screen
Macbook Pro Retina 2.7 | 16GB | 512MB Flash | 1TB Crucial SSD external over Thunderbolt
throttlemeister is offline   -1 Reply With Quote
Old Aug 12, 2011, 08:08 PM   #11
brand
macrumors 68040
 
brand's Avatar
 
Join Date: Oct 2006
Location: 127.0.0.1
deleted
brand is offline   0 Reply With Quote
Old Aug 13, 2011, 03:54 PM   #12
Alrescha
macrumors 65816
 
Join Date: Jan 2008
Location: Boston, MA
Quote:
Originally Posted by throttlemeister View Post
A hostname is a name for a host, consisting of an alphanumeric string without dots.
This is simply not true. See: http://en.wikipedia.org/wiki/Hostname

or

http://www.ietf.org/rfc/rfc2396.txt

It *might* be true for some very specific cases (e.g. non-TCP/IP based networks), but it is not universally the case.

A.

Last edited by Alrescha; Aug 13, 2011 at 04:02 PM.
Alrescha is offline   0 Reply With Quote
Old Aug 14, 2011, 04:31 PM   #13
throttlemeister
macrumors 6502
 
Join Date: Mar 2009
Location: Netherlands
Quote:
Originally Posted by Alrescha View Post
This is simply not true. See: http://en.wikipedia.org/wiki/Hostname

or

http://www.ietf.org/rfc/rfc2396.txt

It *might* be true for some very specific cases (e.g. non-TCP/IP based networks), but it is not universally the case.

A.
No offense, but you are wrong in that you completely misunderstood what I said. On the internet a hostname may be defined by its FQDN (wikipedia) or its URL/URI/URN (rfc2369) in order to be unique, but on systems (aka physical machines, what we are discussing here) the hostname is the string before the first dot. There is a difference between systems and networks. While a host may be known as a.b.c on the internet, it is generally known as a.b on the local net, but on the system itself it is known as simply a. Knowing this helps to understand why the system behaves as it does, whereas using internet topology to describe a system does not.

We may think in internet terms all the time these days, but this way of drilling down from top level to a specific machine is exactly how TCP/IP networks are designed (just think how DNS works). UNIX systems in particular act and behave this way due to their origins.
__________________
Macbook Pro 2.93 | 8GB | 120GB OWC Extreme Pro + 320GB/7200rpm | 24" LED Cinema Screen
Macbook Pro Retina 2.7 | 16GB | 512MB Flash | 1TB Crucial SSD external over Thunderbolt
throttlemeister is offline   0 Reply With Quote
Old Aug 14, 2011, 04:59 PM   #14
throttlemeister
macrumors 6502
 
Join Date: Mar 2009
Location: Netherlands
Since there is apparently a lot more networking knowledge here than unix, let's get back to the original question that will hopefully clarify my point.

Open Terminal and type hostname.

On my system, this will say something like machine.domain.com (but with my real name and domain of course).

You might be thinking right now "see, that is what I said" but you are wrong. What you are seeing is actually Apple incorrectly setting the hostname. But the system is pretty smart, so when it calls for its hostname, it will strip everything behind the first dot. It is for all intends and purposes, irrelevant.

Now go back to Terminal and type domainname

It will come back empty.

Hmm.

While the system is pretty smart in stripping down the hostname entry to its true system hostname, it has no knowledge about the domain name because it isn't set. When it calls for the domain name of the system, it just gets back an empty string. And it will never ever figure out what additional information is set in the hostname, because it will never ever call the hostname to find the domain name. And when the system gets an empty domain name, it will add .local itself, simply because with a TCP/IP network you have to have a hostname + domain.

If we would go back into my example of machine.domain.com and you would go into Terminal and type hostname machine followed by domainname example.com the machine would correctly identify itself as host 'machine' within the domain 'example.com' with a FQDN machine.domain.com and never show itself as machine.local
__________________
Macbook Pro 2.93 | 8GB | 120GB OWC Extreme Pro + 320GB/7200rpm | 24" LED Cinema Screen
Macbook Pro Retina 2.7 | 16GB | 512MB Flash | 1TB Crucial SSD external over Thunderbolt

Last edited by throttlemeister; Aug 14, 2011 at 05:05 PM.
throttlemeister is offline   0 Reply With Quote
Old Aug 14, 2011, 06:43 PM   #15
Alrescha
macrumors 65816
 
Join Date: Jan 2008
Location: Boston, MA
Quote:
Originally Posted by throttlemeister View Post
Now go back to Terminal and type domainname
I'm sorry, you're just off in the weeds. The 'domainname' command has nothing whatsoever to do with DNS names. It's an old YellowPages/NIS throwback and isn't used for anything any more.*

The 'hostname' command is a call to gethostname() which is all about the DNS names, e.g. xxxx.xxxx.xxxx. A clue is that the documentation for gethostname() tells you that the maximum length is 255 characters, which also happens to be the maximum size of the DNS 'fqdn' as you like to call it.

You are right that in old Unix times before the Internet, hostnames were just the name of the host. But that was back in the days of UUCP (and before) and not relevant now.

The hostname command on modern Unix systems returns the full hostname. It has an option to remove the domain part of the hostname if you like.

Apple isn't setting anything 'incorrectly'.

A.

* Apologies to anyone still using yp/nis

Last edited by Alrescha; Aug 14, 2011 at 06:57 PM.
Alrescha is offline   0 Reply With Quote
Old Aug 14, 2011, 08:18 PM   #16
Alrescha
macrumors 65816
 
Join Date: Jan 2008
Location: Boston, MA
To get back to the original question:

Quote:
Originally Posted by vigu360 View Post
When I ssh or do something with the Mac I need to enter <MacName>.local . Is there a way I can change it to just <MacName> (eg server.local --> server)? In unix we need to change /etc/hosts/ file what's the equivalent in Mac OS X?
1) You can add all the hosts you want to talk to in your /etc/host file(s) on all your machines. Then you can type 'ssh host' and it will work the way you want.

2) You can add Host with Hostname definitions to your .ssh/config files(s), e.g.

Host macname
Hostname xx.xx.xx.xx (can be name or IP address)

Then you can say 'ssh host' (but this will only work for ssh).

3) You can have your DHCP server hand out a default search domain of 'local' (depending on your DHCP server). Normally you would have it hand out yourdomain.tld, but you don't appear to be using an internal DNS server.

If 'local' is your default search domain, then you can type 'ssh host' and it will work the way you want. You can also manually put 'search local' into your /etc/resolv.conf, but if you are using DHCP this probably gets re-written by OS X.

A.
Alrescha is offline   0 Reply With Quote
Old Oct 28, 2014, 03:01 AM   #17
canhaz
macrumors regular
 
Join Date: Jan 2012
Quote:
Originally Posted by Alrescha View Post
If the OP doesn't want to have to type the 'local' part of the hostname, then I suggest that the solution is to add 'local' to the search domain in /etc/resolv.conf.
Quote:
Originally Posted by Alrescha View Post
To get back to the original question:
If 'local' is your default search domain, then you can type 'ssh host' and it will work the way you want. You can also manually put 'search local' into your /etc/resolv.conf, but if you are using DHCP this probably gets re-written by OS X.
This seemed like the nicest way. So I've added "search local" to resolv.conf manually. I've also done it via Network Preferences for my active ethernet connection under the DNS tab. After doing so I noticed my comcast assigned search domain went away and only "search local" remained in my /etc/resolv.conf

However I can't get it to work using "ssh machinename"

"ssh machinename.local" works fine though.

Any ideas? (Im on Yosemite)
__________________
Mac Pro (2013) 6-core | Late 2011 MBP 15" (1680x1050) |OWC 6G SSD | Thunderbolt
Mac Mini i5 | iPhone 6+
canhaz is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > OS X > Mac OS X Server, Xserve, and Networking

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
How to remove Local Disk (under DCIM) jpiszcz iPhone 5 Today 12:15 AM
I have iTunes match- can I remove local music now from HDD? cmm Mac Applications and Mac App Store 10 Mar 11, 2014 07:00 PM
remove ".local" suffix from computer name in sharing? Harrison.S OS X 10.8 Mountain Lion 5 Mar 18, 2013 03:37 AM
How to remove greyed out ".local" suffix from name in mac 10.8.3 Harrison.S Mac OS X Server, Xserve, and Networking 4 Mar 17, 2013 08:49 AM
sorting files by suffix stacyphi Mac Basics and Help 2 Aug 31, 2012 10:08 AM

Forum Jump

All times are GMT -5. The time now is 03:39 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC