Simple tool check informations from domain name with golang
Tags: go, ip, tooling, docker
Published: 2022-09-20 16:49:09

## **LOOKUP**

**LOOKUP** is a simple tool check IP informations, CNAME, NS(Name Server), A records, MX records, TXT records with **Go**.

```bash
     /\/| __   /\/| __
    |/\/ /_/  |/\/ /_/
      ___     ___
     / _ \   / _ \
    | (_) | | (_) |
     \___/   \___/
```

*Full source code in [here](https://github.com/ductnn/lookup)*

## Fundamental

- **CNAME**: is a *Canonical Name Record* or *Alias Record*. A type of resource record in the *Domain Name System* (DNS), that specifies that one domain name is an alias of another canonical domain name.

- **A and AAAA Record**: An A and AAAA record are actually primary DNS records. They associate a domain name with a specific IP address.

- **TXT Record** : A TXT record (short for text record) is a type of resource record in the *Domain Name System* (DNS) used to provide the ability to associate arbitrary text with a host or other name, such as human readable information about a server, network, data center, or other accounting information.

- **MX(Mail Exchanger) Record**: A mail exchanger record (MX record) specifies the mail server responsible for accepting email messages on behalf of a domain name. It is a resource record in the Domain Name System (DNS). It is possible to configure several MX records, typically pointing to an array of mail servers for load balancing and redundancy.

- **NameServer**: Nameserver is a server on the internet specialized in handling queries regarding the location of a domain name's various services. Nameservers are a fundamental part of the Domain Name System (DNS). They allow using domains instead of IP addresses.

## Install
First, install [golang](https://go.dev/doc/install).

Then, clone from soucre code and setup:

```sh
git clone https://github.com/ductnn/lookup.git
cd lookup
go get
```

## Usage

### Without docker

Run command:

```
go run main.go
# Enter domain you want to check.
# Example
google.com
```

  <p align="center">
    <img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wwgutf9lzyn2zurvqxrz.png" width="500">
  </p>

Check result:

**CNAME**

  <p align="center">
    <img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ke94axjrf7gyh0xy4ilq.png" width="500">
  </p>

**TXT records**

  <p align="center">
    <img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4uxg29yxmktjg0gzhuo9.png" width="500">
  </p>

**IP informations**

  <p align="center">
    <img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k786b1jt9jslbblm8wga.png" width="500">
  </p>

**Name Servers**

  <p align="center">
    <img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/al30gza180hlgq6zol9z.png" width="500">
  </p>

**MX records**

  <p align="center">
    <img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rygxueyo98scdr44c1h3.png" width="500">
  </p>

### With docker

Check [Dockerfile](Dockerfile) and build with command:

```sh
docker build -t <your-image> -f Dockerfile .
```

or pulls my image in [here](https://hub.docker.com/r/ductn4/loo), and run *container*

```sh
docker run -it ductn4/loo
```

### With file binary

You can down file *binary* in [here](bin/loo) for running tool:

```sh
# Download file bin to your local
chmod +x loo
./loo
# And check result ...
```

Test with **facebook.com**:

```sh
➜  bin git:(master) ✗ ./loo

     /\/| __   /\/| __
    |/\/ /_/  |/\/ /_/
      ___     ___
     / _ \   / _ \
    | (_) | | (_) |
     \___/   \___/


Enter subdomain or domain name:
facebook.com

CNAME
+---------------------+--------------+---------------+
| DOMAIN OR SUBDOMAIN |    DOMAIN    |     CNAME     |
+---------------------+--------------+---------------+
| facebook.com        | facebook.com | facebook.com. |
+---------------------+--------------+---------------+

TXT records
+--------------+----------------------------------------------------------------------+
|    DOMAIN    |                             TXT RECORDS                              |
+--------------+----------------------------------------------------------------------+
| facebook.com | google-site-verification=A2WZWCNQHrGV_TWwKh6KHY90tY0SHZo_RnyMJoDaG0s |
+              +----------------------------------------------------------------------+
|              | v=spf1                                                               |
|              | redirect=_spf.facebook.com                                           |
+              +----------------------------------------------------------------------+
|              | google-site-verification=sK6uY9x7eaMoEMfn3OILqwTFYgaNp4llmguKI-C3_iA |
+              +----------------------------------------------------------------------+
|              | google-site-verification=wdH5DTJTc9AYNwVunSVFeK0hYDGUIEOGb-RReU6pJlY |
+--------------+----------------------------------------------------------------------+

IP Informations
+--------------+------------------------------------+------------------+------------------+------------------------+
|    DOMAIN    |                 IP                 | CITY AND COUNTRY |     LOCATION     |      ORGANIZATION      |
+--------------+------------------------------------+------------------+------------------+------------------------+
| facebook.com | 31.13.75.35                        | Hong             | 22.2783,114.1747 | AS32934 Facebook,      |
|              |                                    | Kong, HK         |                  | Inc.                   |
+              +------------------------------------+------------------+------------------+                        +
|              | 2a03:2880:f15a:83:face:b00c:0:25de | Dublin,          | 53.3331,-6.2489  |                        |
|              |                                    | IE               |                  |                        |
+--------------+------------------------------------+------------------+------------------+------------------------+

Name Servers
+--------------+--------------------+
|    DOMAIN    |    NAME SERVERS    |
+--------------+--------------------+
| facebook.com | b.ns.facebook.com. |
+              +--------------------+
|              | d.ns.facebook.com. |
+              +--------------------+
|              | a.ns.facebook.com. |
+              +--------------------+
|              | c.ns.facebook.com. |
+--------------+--------------------+

MX Records
+--------------+-----------------------------+
|    DOMAIN    |         MX RECORDS          |
+--------------+-----------------------------+
| facebook.com | smtpin.vvv.facebook.com.    |
|              | 10                          |
+--------------+-----------------------------+
```

Okkk! Thank you for reading 😍 🤩 🥳