Perl 5 version 32.0 documentation



Net::Domain - Attempt to evaluate the current host's internet name and domain


  1. use Net::Domain qw(hostname hostfqdn hostdomain domainname);


Using various methods attempt to find the Fully Qualified Domain Name (FQDN) of the current host. From this determine the host-name and the host-domain.

Each of the functions will return undef if the FQDN cannot be determined.

  • hostfqdn ()

    Identify and return the FQDN of the current host.

  • domainname ()

    An alias for hostfqdn ().

  • hostname ()

    Returns the smallest part of the FQDN which can be used to identify the host.

  • hostdomain ()

    Returns the remainder of the FQDN after the hostname has been removed.


Graham Barr <>.

Adapted from Sys::Hostname by David Sundstrom <>.

Steve Hay <> is now maintaining libnet as of version 1.22_02.


Copyright (C) 1995-1998 Graham Barr. All rights reserved.

Copyright (C) 2013-2014 Steve Hay. All rights reserved.


This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself, i.e. under the terms of either the GNU General Public License or the Artistic License, as specified in the LICENCE file.