# 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 1791

### Methods

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

network.js, line 1907

  Look up the hostname associated with the given IPv6 address.

  Name | Type | Description
  --- | --- | ---
  `ip6addr` | string | The IPv6 address to look up.

  ##### 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 1858

  Look up the hostname associated with the given IPv4 address.

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

  ##### 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 1807

  Look up the hostname associated with the given MAC address.

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

  ##### 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 1841

  Look up the IPv6 address associated with the given MAC address.

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

  ##### 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 1824

  Look up the IPv4 address associated with the given MAC address.

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

  ##### 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(ip6addr){null|string}

network.js, line 1933

  Look up the MAC address associated with the given IPv6 address.

  Name | Type | Description
  --- | --- | ---
  `ip6addr` | string | The IPv6 address to look up.

  ##### 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 1884

  Look up the MAC address associated with the given IPv4 address.

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

  ##### 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 1966

  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.