1753787 Members
7306 Online
108799 Solutions
New Discussion юеВ

Re: HOSTNAME/LENGTH

 
SOLVED
Go to solution
Nobody's Hero
Valued Contributor

HOSTNAME/LENGTH

Can someone tell me what the max limit is for a UNIX hostname and where that is defined?

Thanks,
RPM
UNIX IS GOOD
10 REPLIES 10
Jeff Schussele
Honored Contributor
Solution

Re: HOSTNAME/LENGTH

Hi Robert,

Although the max length for an HP hostname is 64 chars, due to the limitations of UUCP & the uname command, it's STRONGLY recommended to keep it <= 8.

The hostname length is not defined in a config file anywhere that I'm aware of other than being hardcoded in a library somewhere.

Rgds,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
Pete Randall
Outstanding Contributor

Re: HOSTNAME/LENGTH

Though you can have longer, 8 characters is the realistic limit. You invite all kinds of problems exceeding 8.

Pete

Pete
James R. Ferguson
Acclaimed Contributor

Re: HOSTNAME/LENGTH

Hi Robert:

'hostname' and 'uname' should be the same and therefore cannot exceed 8-characters. The length of the 'uname' structure is defined in '/usr/include/sys/utsname.h'in '_SYS_NMLN' (see man 2 'uname'). Since this is a 9-character, null-terminated string, the maximum, safe, hostname size is eight (8).

Regards!

...JRF...

Victor_5
Trusted Contributor

Re: HOSTNAME/LENGTH

Generally, it is <=8.
Sridhar Bhaskarla
Honored Contributor

Re: HOSTNAME/LENGTH

Hi,

The max limit for nodename (uname -n) length is 8 which is UTSLEN -1 as defined in utsname.h. It is recommended to set hostname equal to nodename.

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
S.K. Chan
Honored Contributor

Re: HOSTNAME/LENGTH

You already got the answer for it's max limit from the rest. it's defined in /usr/include/sys/utsname.h.
# cd /usr/include/sys
# grep SYS_NMLN utsname.h
Look for the string that says "define _SYS_NMLN"
Sajid_1
Honored Contributor

Re: HOSTNAME/LENGTH

hello,

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.
learn unix ..
Sajid_1
Honored Contributor

Re: HOSTNAME/LENGTH

hello,

Read this document for more information about hostname set more than 8 characters:
http://support2.itrc.hp.com/service/cki/docDisplay.do?docLocale=en_US&docId=200000046860426

Doc ID - S3100000646
learn unix ..