Main Content

resolvehost

Resolve network host name or IP address

    Description

    example

    name = resolvehost(host) and name = resolvehost(host,"name") return the name of the specified host, where host is the network name or IP address.

    example

    address = resolvehost(host,"address") returns the address of the specified host.

    example

    [name,address] = resolvehost(host) returns both the name and address of the specified host.

    Examples

    collapse all

    Provide an IP address to view the associated host name.

    name = resolvehost("144.212.244.17")
    name = 
    'www-ahprod.mathworks.com'
    

    You can specify the optional input argument "name" as well.

    name = resolvehost("144.212.244.17","name")
    name = 
    'www-ahprod.mathworks.com'
    

    Specifying the host name instead returns the same host name.

    name = resolvehost("www.mathworks.com")
    name = 
    'www.mathworks.com'
    

    Provide a network host name to view the associated IP address. You must include the input argument "address".

    address = resolvehost("en.wikipedia.org","address")
    address = 
    '208.80.154.224'
    

    Specifying the IP address instead returns the same IP address.

    address = resolvehost("208.80.154.224","address")
    address = 
    '208.80.154.224'
    

    You can view both the network name and IP address of a specified host. You can specify either the name or IP address. In this example, the resolvehost function returns the name and address from the provided host name.

    [name,address] = resolvehost("en.wikipedia.org")
    name = 
    'en.wikipedia.org'
    
    address = 
    '208.80.154.224'
    

    You can also specify the IP address instead.

    [name,address] = resolvehost("208.80.154.224")
    name = 
    'text-lb.eqiad.wikimedia.org'
    
    address = 
    '208.80.154.224'
    

    Input Arguments

    collapse all

    Network host name or IP address, specified as a character vector or string scalar.

    Data Types: char | string

    Output Arguments

    collapse all

    Network name, returned as a character vector.

    IP address, returned as a character vector.

    Version History

    Introduced before R2006a

    See Also

    |