Linux check domain ip

How to Find the IP Address of a Website in Linux

Wondering how to get the IP address of a website in Linux? Here are 3 command line utilities to query the DNS and get you the IP address and other details.

How do I find the IP address of a website using Linux terminal?

Finding the public IP address of a website’s server is quite easy. In fact, there are several command line tools you can use to find the IP address of a website.

In an earlier article, I showed you how to find IP address in Linux. In this one, I am going to show you some of those commands here.

Commands to find IP address of a website in Linux

Do note that you might have to install some of these utilities mentioned here. Good news is that they are available in the default repositories of most Linux distributions. You can easily install them using the package manager of your distribution.

Method 1: Get website IP address with dig command

Dig is a DNS lookup utility. The sole purpose of this command is to perform DNS lookup and display the answers returned by the nameserver of the queried website.

A sample output for the dig command looks like this:

dig facebook.com ; > DiG 9.11.3-1ubuntu1.5-Ubuntu > facebook.com ;; global options: +cmd ;; Got answer: ;; ->>HEADER

You can see the IP address of the website in the ‘ANSWER SECTION’.

Facebook has tons of servers and you may see a different IP address based on your geo-location and time. You shouldn’t find it unusual.

Method 2: Use nslookup command to find IP address of website in Linux

Like Dig, nslookup command is also used for querying the DNS records. nslookup stands for ‘name server lookup’.

You might need to install nslookup. If you have sudo access, you can use your Linux distribution’s installation command to install this tool. On Debian and Ubuntu, the command below will install nslookup:

sudo apt install nslookup

Once you have the tool, just use it in the following fashion:

For example, if I try to get the IP address of Facebook.com, this is the output I get:

nslookup facebook.com Server: 127.0.0.53 Address: 127.0.0.53#53 Non-authoritative answer: Name: facebook.com Address: 157.240.25.35 Name: facebook.com Address: 2a03:2880:f10c:83:face:b00c:0:25de

Method 3: Get IP address of website using host command

Like the above two, host is also a DNS lookup utility. But unlike the above two commands, the output of the host command is neat and precise. It just displays the IPv4 and IPv6 addresses of a website.

Sample output would be like this:

host facebook.com facebook.com has address 157.240.13.35 facebook.com has IPv6 address 2a03:2880:f139:83:face:b00c:0:25de facebook.com mail is handled by 10 msgin.vvv.facebook.com.

Method 4: Get website’s IP address with ping command in Linux

Let’s see how to get the IP address of a website with the ping command in Linux.

Ping command is used to check whether the remote host is up or not. You can use either the server’s IP address or the URL. The syntax is pretty much the same.

A sample output for facebook.com looks like this:

ping facebook.com PING facebook.com (157.240.24.35) 56(84) bytes of data. 64 bytes from edge-star-mini-shv-01-sin2.facebook.com (157.240.24.35): icmp_seq=1 ttl=52 time=203 ms 64 bytes from edge-star-mini-shv-01-sin2.facebook.com (157.240.24.35): icmp_seq=2 ttl=52 time=163 ms 64 bytes from edge-star-mini-shv-01-sin2.facebook.com (157.240.24.35): icmp_seq=3 ttl=52 time=248 ms ^C --- facebook.com ping statistics --- 4 packets transmitted, 3 received, 25% packet loss, time 3001ms rtt min/avg/max/mdev = 163.965/205.339/248.902/34.713 ms

You’ll have to use Ctrl+C to stop the ping command.

Conclusion

So, you just saw three networking tools that would give you the same result. I hope this quick Linux tip helped you find a website's IP address in Linux terminal.

If you have any questions or suggestions, please leave a comment below. Don’t forget to subscribe to the newsletter and get all the new tutorials in your inbox, for free.

Источник

How to Get Domain and IP Address Information Using WHOIS Command

WHOIS is a TCP-based query and response protocol that is commonly used to provide information services to Internet users. It returns information about the registered Domain Names, an IP address block, Name Servers and a much wider range of information services.

In Linux, the whois command line utility is a WHOIS client for communicating with the WHOIS server (or database host) which listen to requests on the well-known port number 43, which stores and delivers database content in a human-readable format.

whois command line utility does not come pre-installed on many Linux distributions, run the appropriate command below for your distribution to install it.

# yum install whois #RHEL/CentOS # dnf install whois #Fedora 22+ $ sudo apt install whois #Debian/Ubuntu

How to Find IP Address Information

To get the information about specific IP Address issue the command as shown in the below example.

$ whois 216.58.206.46 # # ARIN WHOIS data and services are subject to the Terms of Use # available at: https://www.arin.net/whois_tou.html # # If you see inaccuracies in the results, please report at # https://www.arin.net/public/whoisinaccuracy/index.xhtml # # # The following results may also be obtained via: # https://whois.arin.net/rest/nets;q=216.58.206.46?showDetails=true&showARIN=false&showNonArinTopLevelNet=false&ext=netref2 # NetRange: 216.58.192.0 - 216.58.223.255 CIDR: 216.58.192.0/19 NetName: GOOGLE NetHandle: NET-216-58-192-0-1 Parent: NET216 (NET-216-0-0-0-0) NetType: Direct Allocation OriginAS: AS15169 Organization: Google LLC (GOGL) RegDate: 2012-01-27 Updated: 2012-01-27 Ref: https://whois.arin.net/rest/net/NET-216-58-192-0-1 OrgName: Google LLC OrgId: GOGL Address: 1600 Amphitheatre Parkway City: Mountain View StateProv: CA PostalCode: 94043 Country: US RegDate: 2000-03-30 Updated: 2017-12-21 Ref: https://whois.arin.net/rest/org/GOGL .

How to Find Domain Information

To get the information about the registered domain, simply issue the following command with the domain name. It will retrieve domain data including availability, ownership, creation, expiration details, name servers, etc.

$ whois google.com Domain Name: GOOGLE.COM Registry Domain ID: 2138514_DOMAIN_COM-VRSN Registrar WHOIS Server: whois.markmonitor.com Registrar URL: http://www.markmonitor.com Updated Date: 2011-07-20T16:55:31Z Creation Date: 1997-09-15T04:00:00Z Registry Expiry Date: 2020-09-14T04:00:00Z Registrar: MarkMonitor Inc. Registrar IANA ID: 292 Registrar Abuse Contact Email: [email protected] Registrar Abuse Contact Phone: +1.2083895740 Domain Status: clientDeleteProhibited https://icann.org/epp#clientDeleteProhibited Domain Status: clientTransferProhibited https://icann.org/epp#clientTransferProhibited Domain Status: clientUpdateProhibited https://icann.org/epp#clientUpdateProhibited Domain Status: serverDeleteProhibited https://icann.org/epp#serverDeleteProhibited Domain Status: serverTransferProhibited https://icann.org/epp#serverTransferProhibited Domain Status: serverUpdateProhibited https://icann.org/epp#serverUpdateProhibited Name Server: NS1.GOOGLE.COM Name Server: NS2.GOOGLE.COM Name Server: NS3.GOOGLE.COM Name Server: NS4.GOOGLE.COM .

The formatting of information will differ based on the WHOIS server used. In addition, one downside of WHOIS is the lack of full access to the data, therefore check out these useful guides for querying DNS information in Linux:

If you have any queries or information about the article that you want to share with us, use the comment form below.

Источник

Domain or IP exists check in Linux

I want to know if a given website or IP address is online or offline. I researched a lot, but all I can find is to install some software or using the ping command. I did this test:

It outputs the expected result, but when I do the following where a website does not ext, the result is almost the same as if website existed, with 0% packet loss. Please see the screenshot attached.

ping -c 5 -n examplesurenotexists.com 

Output of ping

I am confused by this. Is there a better way to do this task?

If you add the -q option, you get a Quiet output, just a line that can be easier and faster to parse or understand.

This is not possible, when a site is down it CANNOT reply to ICMP echo requests (unless something in the middle is intercepting such requests and spoofing replies). Moreover, please note that some machines are intentionally configured to ignore such requests, so this will only work on the machines you have replying to ping requests enabled.

@AdamSiemion, thanks. Just curious to know. If not possible then how peoples do this? there are also lots of services who check website stats.

@MadanSapkota in my previous comment what I wanted to say was that in most cases it works, it is just not 100% reliable method. If you want to check if an HTTP server works ask it for a page, Alfe's answer will tell you how.

1 Answer 1

If you want to know if a website is online of offline, simply check the website:

if curl -s http://www.alfe.de >/dev/null then echo "online" else echo "offline" fi 

Using ping instead would not test the HTTP protocol (which is for websites) but the ICMP protocol; one is merely independent from the other (but of course, if the host is down, both won't work). There are sites which still react on ICMP while the HTTP server is down (this is rather typical) and there are sites which won't react on ICMP although the HTTP server is up and running functioning perfectly well.

Источник

Читайте также:  Postgres server on linux
Оцените статью
Adblock
detector