Can we set hostname using the DHCP ?

Posted on 2009-02-15
Last Modified: 2013-12-27
Suppose I have modified my /etc/hosts and /etc/nodename as 'foo'
and at DHCP server my IP address bound to my MAC address and associated hostname is 'bar'

so when I request from DHCP for auto host configuration, will my hostname would be changed from 'foo' to 'bar' ??
Question by:beer9
    LVL 10

    Expert Comment

    No, dhclient (The DHCP Client daemon) does not set your hostname to what it receives in a lease (by default).

    LVL 10

    Expert Comment

    If you want custom host names bound to specific IP's use an internal DNS server...
    - add that server into the DHCP lease
    - add the hosts into the DNS records
    LVL 22

    Accepted Solution

    Actually, Solaris does set the hostname of the system from what it receives in the DHCP
    request, if the DHCP server supplies one. In some of the initial releases of Solaris this was
    a problem, because many DHCP servers do not supply one, and the /etc/nodename file was
    only used if DHCP was not. As a result, the hostname became set to "unknown", which was
    the default hostname used when DHCP did not supply a hostname.  It took awhile before
    Solaris was modified to use what was in /etc/nodename as a default instead of "unknown".
    Since many people wanted the /etc/nodename to override what it got from DHCP, different
    versions of Solaris have used different algorithms to ultimately set the hostname.

    However, you may find that in many cases Solaris (10 and before at least, not sure about
    OpenSolaris) may not pick up a host name when other systems do. While DHCP can
    supply a hostname, in many Windows networks it does not, relying on the Windows naming
    service to provide the hostname. If that is the case, Solaris will not pick up the hostname and
    will end up using the default.
    LVL 40

    Expert Comment

    please see the file /etc/default/dhcpagent which contains some info in this regard and a parameter

    Author Closing Comment

    Thanks blu!

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Join & Write a Comment

    My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (, discussed installing the Solaris Operating S…
    Installing FreeBSD… FreeBSD is a darling of an operating system. The stability and usability make it a clear choice for servers and desktops (for the cunning). Savvy?  The Ports collection makes available every popular FOSS application and packag…
    Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
    In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now