1824915 Members
3702 Online
109677 Solutions
New Discussion юеВ

Length of hostname

 
SOLVED
Go to solution
Juan Gonzalez_2
Frequent Advisor

Length of hostname

How many characters long can the name of a unix server be? I have read 16 characters long. I have found different answers.
14 REPLIES 14
Christopher Caldwell
Honored Contributor

Re: Length of hostname

64:

The sethostname() system call sets the name of the host processor to
name, which has a length of namelen characters. At system boot time
sethostname() is normally executed by the hostname command (see
hostname(1)) in the /sbin/init.d/hostname script. Host names are
limited to MAXHOSTNAMELEN characters, as defined in .


$ grep MAXHOSTNAMELEN /usr/include/sys/param.h
#define MAXHOSTNAMELEN 64 /* max length of hostname */
Ian Kidd_1
Trusted Contributor

Re: Length of hostname

While the maximum allowable length of the hostname is 64 characters long, it is recommended that you shouldn't exceed 8.

For example, you want the `uname` command to be able to display the entire hostname. uname uses utsname which is defined in usr/include/sys/utsname.h as: #define UTSLEN 9
this is a 9 character null-terminated string (per the man pages). I've read (but am not positive) that the maximum is 8 because of 8 characters + null.

There's other issues I've read about (UUCP, etc.) for having a hostname longer than 8 characters, so it might be best sticking with the recommended length if you can.
If at first you don't succeed, go to the ITRC
harry d brown jr
Honored Contributor

Re: Length of hostname

I would never bless any system name over 8 characters, as a matter of just being stubborn.

You actually COULD have code that might fail if you exceed 8 characters, but like the limit says (64), if you wish to go beyond 8 characters, that's your choice :-)

live free or die
harry
Live Free or Die
Scott Van Kalken
Esteemed Contributor
Solution

Re: Length of hostname

I tried this for fun once on a 10.20 box a while ago. Gave it a 30 character hostname.

GSP was only half working.

SDUX nearly had a heart attack, and some other things didn't work (like uname).

The biggest show stopper I found was SDUX though.

Ravi_8
Honored Contributor

Re: Length of hostname

Hi,

you can have any length for hostname, but while displaying it shows only first 8 characters,
never give up
Jean-Louis Phelix
Honored Contributor

Re: Length of hostname

hi,

It's definitly 8 if you don't want to go in big troubles ... Consider MAXHOSTNAMELEN (64)as the maximum length for fully qualified hostnames (host.domain.com) and UTSLEN (8+1) for real hostnames displayed by uname -n command.

Regards.

It works for me (┬й Bill McNAMARA ...)
donne007
Regular Advisor

Re: Length of hostname

HI
The system Takes character's up to infinity but while displaying it shows only 8 characters. since Unmae displays only 8 chars ..
Cheers
Asif
Ravi_8
Honored Contributor

Re: Length of hostname

Hi, again

The Software Distributor tools (swinstall, etc.) use the system's hostname, and uname value interchangeably, and since the uname value is restricted to 8 characters, the SD tools would fail if the hostname is longer than 8.
never give up
Steven E. Protter
Exalted Contributor

Re: Length of hostname

This is one area where Linux is ahead of HP-UX.

My web server for my web hosting biz at home runs Linux. The main server host name is jerusalem, my favorite city. That's nine characters btw

I tried that with an HP-UX box and had issues with swinstall and Ignite. That server is now called Moriah (the Temple Mount).

8 character limit is the way to go with HP-UX and thats 11.11 btw.

Steve
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Steven E. Protter
Exalted Contributor

Re: Length of hostname

This is one area where Linux is ahead of HP-UX.

My web server for my web hosting biz at home runs Linux. The main server host name is jerusalem, my favorite city. That's nine characters btw

I tried that with an HP-UX box and had issues with swinstall and Ignite. That server is now called Moriah (the Temple Mount).

8 character limit is the way to go with HP-UX and thats 11.11 btw.

Yes, it was stupid to try and name two servers I work with the same thing, but that's not how it happened. The jerusalem box at home went in after I figured out I couldn't use it at work.

Steve
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Paul Sperry
Honored Contributor

Re: Length of hostname

I'd stick with 8 characters.
MANOJ SRIVASTAVA
Honored Contributor

Re: Length of hostname

Hi


you can take help from this thread


http://bizforums.itrc.hp.com/cm/QuestionAnswer/1,,0xe90957bd90a9d611abdb0090277a778c,00.html
"The answer for your question can be found from:
# man hostname
The max. limit will be defined in /usr/include/sys/param.h with the parameter - MAXHOSTNAMELEN. This is 64.

However, It is strongly recommended to keep your hostname up to 8 characters. Because the UUCP nodename is restricted to 8 characters and it automatically accepts the value from the set hostname. "


Manoj Srivastava
Shannon Petry
Honored Contributor

Re: Length of hostname

For compatability sake with other systems, no matter how long the OS states the hostname can be you do not want to exceed 8 characters.

Even some of the newer systems coming out have hard limite built in to help the windows people conform to the standards, instead of defining their own. again........


if you need long names, setup DNS and make good domain/sub-domain names. This way legacy systems and systems that support only 8 characters can still function.
Here are a few systems not supporting more than 8 characters.
OS/400, MVS, WinNT3.5, Windows 3.1, DOS, MacOS less than 9, SCO Unix, Most Unices older than 4 years.

Regards,
Shannon
Microsoft. When do you want a virus today?
Juan Gonzalez_2
Frequent Advisor

Re: Length of hostname

Thanks to everyone information for all the good feed back.