Obtaining a server IP address from hostname

how to find ip address from hostname
get ip from hostname linux
how to find ip address of server using command prompt
how to get ip address of another computer remotely
find ip address from computer name on network
how to get a name from an ip address
how to find device name from ip address
ping computer name to get ip address

When performing an NSURLRequest to a hostname, is it possible to obtain the IP address of the server that the response came from?

The NSURL method:

- (NSString *)host;

simply returns the hostname, and I see no way of obtaining the IP address from any of the other NSURL methods.

Perhaps there is a way of performing a host lookup before inititing the NSURLRequest?

You can use the system call gethostbyname() to resolve a hostname then use the returning structure to get the ip address. Have a look at inet_ntop() for this last part.


struct hostent *hostentry;
hostentry = gethostbyname("google.com");
char * ipbuf;
ipbuf = inet_ntoa(*((struct in_addr *)hostentry->h_addr_list[0]));

Finding the Host Name, IP Address or Physical Address of your , Finding the Host Name, IP Address or Physical Address of your machine. Windows 7 Instructions: First, click on your Start Menu and type cmd in the search box  Querying DNS. 1. Click the Windows Start button, then "All Programs" and "Accessories." Right-click on "Command Prompt" and choose "Run as Administrator." 2. Type "nslookup %ipaddress%" in the black box that appears on the screen, substituting %ipaddress% with the IP address for which you want to

I was asking a question regarding

"how to get IP from hostname in unix\linux?"

but found this question in a different context which is not for Unix I guess, let me correct if I am wrong

since this question already been asked so I am fearing to avoid asking the same question marked as duplicated by stack overflow team.

Quest: how to get IP from hostname in unix\linux?

Ans: the two commands over there

  1. ping host_name


ping -s google.co.in
PING google.co.in: 56 data bytes
64 bytes from dfw06s48-in-f3.1e100.net ( icmp_seq=0. time=2.477 ms
64 bytes from dfw06s48-in-f3.1e100.net ( icmp_seq=1. time=1.415 ms
64 bytes from dfw06s48-in-f3.1e100.net ( icmp_seq=2. time=1.712 ms
  1. nslookup host_name


nslookup google.co.in

Non-authoritative answer:
Name:   google.co.in

How to Find a Hostname for an IP Address, You can find the hostname of any computer with a public IP address by passing the address to any Domain Name System (DNS) server. However, since the  How to get Server IP Address and Hostname in Java. Last Updated on July 16th, 2017 by App Shah 4 comments. In Java, you can use InetAddress.getLocalHost () to get the Ip Address of the current Server running the Java app and InetAddress.getHostName () to get Hostname of the current Server name. CrunchifyGetIPHostname.java.

#import <arpa/inet.h>

- (BOOL)resolveHost:(NSString *)hostname {
    Boolean result;
    CFHostRef hostRef;
    CFArrayRef addresses;
    NSString *ipAddress = nil;
    hostRef = CFHostCreateWithName(kCFAllocatorDefault, (__bridge 
    CFStreamError *error = NULL;
    if (hostRef) {
        result = CFHostStartInfoResolution(hostRef, kCFHostAddresses, error); 
        if (result) {
            addresses = CFHostGetAddressing(hostRef, &result);
    if (result) {
        CFIndex index = 0;
        CFDataRef ref = (CFDataRef) CFArrayGetValueAtIndex(addresses, index);

        int port=0;
        struct sockaddr *addressGeneric;

        NSData *myData = (__bridge NSData *)ref;
        addressGeneric = (struct sockaddr *)[myData bytes];

        switch (addressGeneric->sa_family) {
            case AF_INET: {
                struct sockaddr_in *ip4;
                char dest[INET_ADDRSTRLEN];
                ip4 = (struct sockaddr_in *)[myData bytes];
                port = ntohs(ip4->sin_port);
                ipAddress = [NSString stringWithFormat:@"%s", inet_ntop(AF_INET, &ip4->sin_addr, dest, sizeof dest)];

        case AF_INET6: {
            struct sockaddr_in6 *ip6;
            char dest[INET6_ADDRSTRLEN];
            ip6 = (struct sockaddr_in6 *)[myData bytes];
            port = ntohs(ip6->sin6_port);
            ipAddress = [NSString stringWithFormat:@"%s", inet_ntop(AF_INET6, &ip6->sin6_addr, dest, sizeof dest)];
            ipAddress = nil;
    NSLog(@"%@", ipAddress);
    if (ipAddress) {
        return YES;
    } else {
        return NO;

[self resolveHost:@"google.com"]

How to find the IP address of a website or server, Learn three methods of finding the IP address of your server or website. and then type the relevant domain name or the server hostname. If you know the name of the SMTP server you can easily retrieve the SMTP server IP address by following the below steps:-. Click on the “ Start ” menu, type “ Run ” press enter then type “ cmd ” press enter (type without quotes) A command prompt will open in a new window. Type ping space smtp server name.

How to find IP Address from hostname in Windows , Here are the top 4 ways of getting an IP address from hostname in Linux or UNIX Linux Servers. also, a limitation of the hostname is that you can not find the IP  To get reverse DNS lookup working your will have to set up your nameserver / DNS-server in a way, that it is authoritative for 192.168.1.* and create zones / zonefiles with the DNS data (ip => hostname). I guess you are under the (false) impression, that a nameserver that knows "hostname => ip" magically knows "ip => hostname" either.

How to get Server IP Address and Hostname in Java • Crunchify, In Java, you can use InetAddress.getLocalHost() to get the Ip Address of the current Server running the Java app and InetAddress. How to determine your computer's hostname and hardware (MAC) address. In a network environment, nodes (network enabled equipment or objects on the network) have unique identifiers. The MAC address is the physical address of a network interface.

Hostname to IP address Lookup, This tool will provide you the ip address(es) of the supplied hostname. Hostname to IP Address Lookup. This tool will provide you the IP address (or addresses, if applicable) of the hostname (ie www.yahoo.com) that you enter below.

  • Note that inet_ntoa is deprecated and you should use inet_ntop in stead to support IPv6 addresses.
  • Just in case you want to see all the ip addresses you will need to run a loop on hostentry->h_addr_list[i] to display all of them.
  • Use getaddrinfo() instead of gethostbyname(). It allows for IPV6 and caters for cases where multiple IP addresses are returned