- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- /etc/hosts
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2001 04:19 PM
12-28-2001 04:19 PM
/etc/hosts
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2001 05:48 PM
12-28-2001 05:48 PM
Re: /etc/hosts
In unistd.h:
extern int gethostname __((char *, size_t));
man gethostname:
int gethostname(char *hostname, size_t size);
size specifies the length of the hostname array.
In _size_t.h,
# ifndef _SIZE_T
# define _SIZE_T
_NAMESPACE_STD_START
typedef unsigned long size_t;
_NAMESPACE_STD_END
# endif /** _SIZE_T **/
Thus, based on this interpretation, the maximum length of a hostname entry in /etc/hosts is unsigned long which is 4294967295.
Hope this helps. Regards.
Steven Sim Kok Leong
Brainbench MVP for Unix Admin
http://www.brainbench.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2001 06:06 PM
12-28-2001 06:06 PM
Re: /etc/hosts
To add on:
man gethostent:
gethostent() Reads the next line of /etc/hosts, opening the file if necessary.
The gethostent(), gethostbyname(), and gethostbyaddr() functions each return a pointer to a structure of type hostent, defined as follows in
struct hostent {
char *h_name;
char **h_aliases;
int h_addrtype;
int h_length;
char **h_addr_list;
};
Hope this helps. Regards.
Steven Sim Kok Leong
Brainbench MVP for Unix Admin
http://www.brainbench.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2001 06:21 PM
12-28-2001 06:21 PM
Re: /etc/hosts
"The name_of_host argument is restricted to MAXHOSTNAMELEN characters as defined in
Typical manspeak assumes that everyone knows where
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).
hostname is a separate name which may be up to 64 characters in length. So the direct answer to your question is: 64
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:
NODENAME=
So the netconf file now shows:
HOSTNAME=really_long_hostname
NODENAME=host8
Now set the new values with:
# /sbin/init.d/hostname start
And test it with:
# uname -n
# hostname
Then edit /etc/hosts and put both names on the same line for your IP address as in:
12.34.56.78 host8 really_long_hostname
Now test the network resolution with:
# nslookup host8
# nslookup really_long_hostname
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.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2001 06:30 PM
12-28-2001 06:30 PM
Re: /etc/hosts
I guess Bill is right. Had missed out the MAXHOSTNAMELEN.
Steven Sim Kok Leong
Brainbench MVP for Unix Admin
http://www.brainbench.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-31-2001 07:31 AM
12-31-2001 07:31 AM
Re: /etc/hosts
All hostnames are limited to 64 characters (A-Z, 1-9) no special characters.
The parameter MAXHOSTNAMELEN is defined in the /sys/param.h file, but it is highly recommended that you do not modify this file.
Good luck.