<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: /etc/hosts in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/etc-hosts/m-p/2636619#M42545</link>
    <description>64 characters which is found in the man page for hostname:&lt;BR /&gt;&lt;BR /&gt;"The name_of_host argument is restricted to MAXHOSTNAMELEN characters as defined in &lt;SYS&gt;."&lt;BR /&gt;&lt;BR /&gt;Typical manspeak assumes that everyone knows where &lt;SYS&gt; is located (it's really in /usr/include/sys/param.h).  The confusion over hostname lengths is historic as there are two major way to ID a system's network name.&lt;BR /&gt;&lt;BR /&gt;The oldest method is uname -n which is the UUCP (Unix-to-Unix CoPy) name. UUCP is protocol used by Unix long before the popular Internet existed and involves automated modem dialing for networking. The UUCP name is limited to 8 characters (man 2 uname, look for UTSLEN).&lt;BR /&gt;&lt;BR /&gt;hostname is a separate name which may be up to 64 characters in length.  So the direct answer to your question is: 64&lt;BR /&gt;&lt;BR /&gt;But the unasked question is: how to handle a short and long name? Start by editing the /etc/rc.config.d/netconf file and adding a new line:&lt;BR /&gt;&lt;BR /&gt;NODENAME=&lt;UNAME value="" up="" to="" 8="" chars=""&gt;&lt;BR /&gt;&lt;BR /&gt;So the netconf file now shows:&lt;BR /&gt;&lt;BR /&gt;HOSTNAME=really_long_hostname&lt;BR /&gt;NODENAME=host8&lt;BR /&gt;&lt;BR /&gt;Now set the new values with:&lt;BR /&gt;&lt;BR /&gt;# /sbin/init.d/hostname start&lt;BR /&gt;&lt;BR /&gt;And test it with:&lt;BR /&gt;&lt;BR /&gt;# uname -n&lt;BR /&gt;# hostname&lt;BR /&gt;&lt;BR /&gt;Then edit /etc/hosts and put both names on the same line for your IP address as in:&lt;BR /&gt;&lt;BR /&gt;12.34.56.78 host8 really_long_hostname&lt;BR /&gt;&lt;BR /&gt;Now test the network resolution with:&lt;BR /&gt;&lt;BR /&gt;# nslookup host8&lt;BR /&gt;# nslookup really_long_hostname&lt;BR /&gt;&lt;BR /&gt;There are a few more details if you are using a DNS server, but the question was for /etc/hosts only. Technically, the largest entry in /etc/hosts includes long domain/organization names, things like abc.mycompany.com so the limit is much larger, but for simple networks, 64 and 8 are the two limits.&lt;/UNAME&gt;&lt;/SYS&gt;&lt;/SYS&gt;</description>
    <pubDate>Sat, 29 Dec 2001 02:21:14 GMT</pubDate>
    <dc:creator>Bill Hassell</dc:creator>
    <dc:date>2001-12-29T02:21:14Z</dc:date>
    <item>
      <title>/etc/hosts</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/etc-hosts/m-p/2636616#M42542</link>
      <description>What is the max length of the host in /etc/hosts?  24 characters or 64 or 8?</description>
      <pubDate>Sat, 29 Dec 2001 00:19:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/etc-hosts/m-p/2636616#M42542</guid>
      <dc:creator>Stew McLeod</dc:creator>
      <dc:date>2001-12-29T00:19:48Z</dc:date>
    </item>
    <item>
      <title>Re: /etc/hosts</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/etc-hosts/m-p/2636617#M42543</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;In unistd.h:&lt;BR /&gt;&lt;BR /&gt;extern int gethostname __((char *, size_t));&lt;BR /&gt;&lt;BR /&gt;man gethostname:&lt;BR /&gt;&lt;BR /&gt;int gethostname(char *hostname, size_t size);&lt;BR /&gt;&lt;BR /&gt;size specifies the length of the hostname array.&lt;BR /&gt;&lt;BR /&gt;In _size_t.h,&lt;BR /&gt;&lt;BR /&gt;#       ifndef _SIZE_T&lt;BR /&gt;#               define _SIZE_T&lt;BR /&gt;_NAMESPACE_STD_START&lt;BR /&gt;                        typedef unsigned long size_t;&lt;BR /&gt;_NAMESPACE_STD_END&lt;BR /&gt;#       endif /** _SIZE_T **/&lt;BR /&gt;&lt;BR /&gt;Thus, based on this interpretation, the maximum length of a hostname entry in /etc/hosts is unsigned long which is 4294967295.&lt;BR /&gt;&lt;BR /&gt;Hope this helps. Regards.&lt;BR /&gt;&lt;BR /&gt;Steven Sim Kok Leong&lt;BR /&gt;Brainbench MVP for Unix Admin&lt;BR /&gt;&lt;A href="http://www.brainbench.com" target="_blank"&gt;http://www.brainbench.com&lt;/A&gt;</description>
      <pubDate>Sat, 29 Dec 2001 01:48:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/etc-hosts/m-p/2636617#M42543</guid>
      <dc:creator>Steven Sim Kok Leong</dc:creator>
      <dc:date>2001-12-29T01:48:34Z</dc:date>
    </item>
    <item>
      <title>Re: /etc/hosts</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/etc-hosts/m-p/2636618#M42544</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;To add on:&lt;BR /&gt;&lt;BR /&gt;man gethostent:&lt;BR /&gt;&lt;BR /&gt;gethostent()           Reads the next line of /etc/hosts, opening the file if necessary.&lt;BR /&gt;&lt;BR /&gt;The gethostent(), gethostbyname(), and gethostbyaddr() functions each return a pointer to a structure of type hostent, defined as follows in &lt;NETDB.H&gt;:&lt;BR /&gt; &lt;BR /&gt;struct hostent {&lt;BR /&gt;               char *h_name;&lt;BR /&gt;               char **h_aliases;&lt;BR /&gt;               int h_addrtype;&lt;BR /&gt;               int h_length;&lt;BR /&gt;               char **h_addr_list;&lt;BR /&gt;           };&lt;BR /&gt;&lt;BR /&gt;Hope this helps. Regards.&lt;BR /&gt;&lt;BR /&gt;Steven Sim Kok Leong&lt;BR /&gt;Brainbench MVP for Unix Admin&lt;BR /&gt;&lt;A href="http://www.brainbench.com" target="_blank"&gt;http://www.brainbench.com&lt;/A&gt;&lt;/NETDB.H&gt;</description>
      <pubDate>Sat, 29 Dec 2001 02:06:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/etc-hosts/m-p/2636618#M42544</guid>
      <dc:creator>Steven Sim Kok Leong</dc:creator>
      <dc:date>2001-12-29T02:06:18Z</dc:date>
    </item>
    <item>
      <title>Re: /etc/hosts</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/etc-hosts/m-p/2636619#M42545</link>
      <description>64 characters which is found in the man page for hostname:&lt;BR /&gt;&lt;BR /&gt;"The name_of_host argument is restricted to MAXHOSTNAMELEN characters as defined in &lt;SYS&gt;."&lt;BR /&gt;&lt;BR /&gt;Typical manspeak assumes that everyone knows where &lt;SYS&gt; is located (it's really in /usr/include/sys/param.h).  The confusion over hostname lengths is historic as there are two major way to ID a system's network name.&lt;BR /&gt;&lt;BR /&gt;The oldest method is uname -n which is the UUCP (Unix-to-Unix CoPy) name. UUCP is protocol used by Unix long before the popular Internet existed and involves automated modem dialing for networking. The UUCP name is limited to 8 characters (man 2 uname, look for UTSLEN).&lt;BR /&gt;&lt;BR /&gt;hostname is a separate name which may be up to 64 characters in length.  So the direct answer to your question is: 64&lt;BR /&gt;&lt;BR /&gt;But the unasked question is: how to handle a short and long name? Start by editing the /etc/rc.config.d/netconf file and adding a new line:&lt;BR /&gt;&lt;BR /&gt;NODENAME=&lt;UNAME value="" up="" to="" 8="" chars=""&gt;&lt;BR /&gt;&lt;BR /&gt;So the netconf file now shows:&lt;BR /&gt;&lt;BR /&gt;HOSTNAME=really_long_hostname&lt;BR /&gt;NODENAME=host8&lt;BR /&gt;&lt;BR /&gt;Now set the new values with:&lt;BR /&gt;&lt;BR /&gt;# /sbin/init.d/hostname start&lt;BR /&gt;&lt;BR /&gt;And test it with:&lt;BR /&gt;&lt;BR /&gt;# uname -n&lt;BR /&gt;# hostname&lt;BR /&gt;&lt;BR /&gt;Then edit /etc/hosts and put both names on the same line for your IP address as in:&lt;BR /&gt;&lt;BR /&gt;12.34.56.78 host8 really_long_hostname&lt;BR /&gt;&lt;BR /&gt;Now test the network resolution with:&lt;BR /&gt;&lt;BR /&gt;# nslookup host8&lt;BR /&gt;# nslookup really_long_hostname&lt;BR /&gt;&lt;BR /&gt;There are a few more details if you are using a DNS server, but the question was for /etc/hosts only. Technically, the largest entry in /etc/hosts includes long domain/organization names, things like abc.mycompany.com so the limit is much larger, but for simple networks, 64 and 8 are the two limits.&lt;/UNAME&gt;&lt;/SYS&gt;&lt;/SYS&gt;</description>
      <pubDate>Sat, 29 Dec 2001 02:21:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/etc-hosts/m-p/2636619#M42545</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2001-12-29T02:21:14Z</dc:date>
    </item>
    <item>
      <title>Re: /etc/hosts</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/etc-hosts/m-p/2636620#M42546</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I guess Bill is right. Had missed out the MAXHOSTNAMELEN.&lt;BR /&gt;&lt;BR /&gt;Steven Sim Kok Leong&lt;BR /&gt;Brainbench MVP for Unix Admin&lt;BR /&gt;&lt;A href="http://www.brainbench.com" target="_blank"&gt;http://www.brainbench.com&lt;/A&gt;</description>
      <pubDate>Sat, 29 Dec 2001 02:30:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/etc-hosts/m-p/2636620#M42546</guid>
      <dc:creator>Steven Sim Kok Leong</dc:creator>
      <dc:date>2001-12-29T02:30:18Z</dc:date>
    </item>
    <item>
      <title>Re: /etc/hosts</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/etc-hosts/m-p/2636621#M42547</link>
      <description>Kelly&lt;BR /&gt;&lt;BR /&gt;All hostnames are limited to 64 characters (A-Z, 1-9) no special characters.&lt;BR /&gt;&lt;BR /&gt;The parameter MAXHOSTNAMELEN is defined in the /sys/param.h file, but it is highly recommended that you do not modify this file.&lt;BR /&gt;&lt;BR /&gt;Good luck.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 31 Dec 2001 15:31:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/etc-hosts/m-p/2636621#M42547</guid>
      <dc:creator>fg_1</dc:creator>
      <dc:date>2001-12-31T15:31:47Z</dc:date>
    </item>
  </channel>
</rss>

