# Class: Hosts

## LuCI .network. Hosts

The `LuCI.network.Hosts` class encapsulates host information aggregated from multiple sources and provides convenience functions to access the host information by different criteria.

#### new LuCI.network.Hosts()

network.js, line 1714

### Methods

#### getHostnameByIP6Addr(ipaddr){null|string}

network.js, line 1811

  Lookup the hostname associated with the given IPv6 address.

  Name | Type | Description
  --- | --- | ---
  `ipaddr` | string | The IPv6 address to lookup.

  ##### Returns:

  Type | Description
  --- | ---
  null | string | Returns the hostname associated with the given IPv6 or `null` if no matching host could be found or if no hostname is known for the corresponding host.

#### getHostnameByIPAddr(ipaddr){null|string}

network.js, line 1775

  Lookup the hostname associated with the given IPv4 address.

  Name | Type | Description
  --- | --- | ---
  `ipaddr` | string | The IPv4 address to lookup.

  ##### Returns:

  Type | Description
  --- | ---
  null | string | Returns the hostname associated with the given IPv4 or `null` if no matching host could be found or if no hostname is known for the corresponding host.

#### getHostnameByMACAddr(mac){null|string}

network.js, line 1730

  Lookup the hostname associated with the given MAC address.

  Name | Type | Description
  --- | --- | ---
  `mac` | string | The MAC address to lookup.

  ##### Returns:

  Type | Description
  --- | ---
  null | string | Returns the hostname associated with the given MAC or `null` if no matching host could be found or if no hostname is known for the corresponding host.

#### getIP6AddrByMACAddr(mac){null|string}

network.js, line 1760

  Lookup the IPv6 address associated with the given MAC address.

  Name | Type | Description
  --- | --- | ---
  `mac` | string | The MAC address to lookup.

  ##### Returns:

  Type | Description
  --- | ---
  null | string | Returns the IPv6 address associated with the given MAC or `null` if no matching host could be found or if no IPv6 address is known for the corresponding host.

#### getIPAddrByMACAddr(mac){null|string}

network.js, line 1745

  Lookup the IPv4 address associated with the given MAC address.

  Name | Type | Description
  --- | --- | ---
  `mac` | string | The MAC address to lookup.

  ##### Returns:

  Type | Description
  --- | ---
  null | string | Returns the IPv4 address associated with the given MAC or `null` if no matching host could be found or if no IPv4 address is known for the corresponding host.

#### getMACAddrByIP6Addr(ipaddr){null|string}

network.js, line 1829

  Lookup the MAC address associated with the given IPv6 address.

  Name | Type | Description
  --- | --- | ---
  `ipaddr` | string | The IPv6 address to lookup.

  ##### Returns:

  Type | Description
  --- | ---
  null | string | Returns the MAC address associated with the given IPv6 or `null` if no matching host could be found or if no MAC address is known for the corresponding host.

#### getMACAddrByIPAddr(ipaddr){null|string}

network.js, line 1793

  Lookup the MAC address associated with the given IPv4 address.

  Name | Type | Description
  --- | --- | ---
  `ipaddr` | string | The IPv4 address to lookup.

  ##### Returns:

  Type | Description
  --- | ---
  null | string | Returns the MAC address associated with the given IPv4 or `null` if no matching host could be found or if no MAC address is known for the corresponding host.

#### getMACHints(preferIp6){Array.<Array.<string>>}

network.js, line 1857

  Return an array of (MAC address, name hint) tuples sorted by MAC address.

  Name | Type | Default | Description
  --- | --- | --- | ---
  `preferIp6` | boolean | false | optional Whether to prefer IPv6 addresses (`true`) or IPv4 addresses (`false`) as name hint when no hostname is known for a specific MAC address.

  ##### Returns:

  Type | Description
  --- | ---

  Array.<Array.<string>>

  Returns an array of arrays containing a name hint for each found MAC address on the system. The array is sorted ascending by MAC. Each item of the resulting array is a two element array with the MAC being the first element and the name hint being the second element. The name hint is either the hostname, an IPv4 or an IPv6 address related to the MAC address. If no hostname but both IPv4 and IPv6 addresses are known, the `preferIP6` flag specifies whether the IPv6 or the IPv4 address is used as hint.