find IP address by domain in go

0 votes

I am using below code for an API to find ip address for a given domain:

func IPFinder(c *gin.Context) {
    var domain models.Domain
    c.BindJSON(&domain)
    addr, err := net.LookupIP(domain.DomainName)
    if err != nil {
        c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
    } else {
        c.JSON(http.StatusOK, gin.H{"ip_address": addr})
    }
    return
}

For the below request:

{
    "domain_name": "yahoo.com"
}

getting response as :

{
    "ip_address": [
        "2404:6800:4002:80a::200e",
        "172.217.167.46"
    ]
}

Here this LookupIP method is giving the slice containing ipv4 and ipv6 address of that domain. Is there any other way of any other 3rd party lib in GoLang using which I can get output containing only the ip address like below :

{
    "ip_address": "172.217.167.46"
}

Feb 16, 2022 in Cyber Security & Ethical Hacking by Edureka
• 12,690 points
1,361 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Cyber Security & Ethical Hacking

+1 vote
1 answer

How to find IP address of nodes in my network?

The IP address of the nodes connected ...READ MORE

answered Feb 9, 2019 in Cyber Security & Ethical Hacking by Omkar
• 69,220 points
5,169 views
0 votes
1 answer

how to find hostname using ip address in cmd

To find host name from IP you ...READ MORE

answered Feb 20, 2022 in Cyber Security & Ethical Hacking by Edureka
• 12,690 points
92,536 views
0 votes
1 answer

IP address by Domain Name

The code you provided is accurate. Perhaps ...READ MORE

answered Feb 24, 2022 in Cyber Security & Ethical Hacking by Edureka
• 12,690 points
594 views
0 votes
0 answers

How to find the IP address of the DNS server in Wireshark?

Wireshark is a powerful network analysis tool. ...READ MORE

Mar 10 in Cyber Security & Ethical Hacking by Anupam
• 13,420 points
54 views
0 votes
1 answer

How to find MAC address using IP address?

To find the MAC address, run this ...READ MORE

answered Feb 9, 2019 in Cyber Security & Ethical Hacking by Omkar
• 69,220 points
2,486 views
0 votes
1 answer

Private IP Address Identifier in Regular Expression

I'm assuming you want to match these ...READ MORE

answered Feb 16, 2022 in Cyber Security & Ethical Hacking by Edureka
• 12,690 points
3,701 views
0 votes
0 answers
0 votes
2 answers

Finding local IP addresses using Python's stdlib

import socket s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s ...READ MORE

answered Mar 30, 2020 in Python by anonymous
3,212 views
0 votes
1 answer

how to find ip address in cmd

if you are using windows then there ...READ MORE

answered Feb 26, 2023 in Cyber Security & Ethical Hacking by subhasish

edited Mar 5 47,888 views
0 votes
1 answer

difference between mac address and ip address

MAC Address IP Address MAC Address stands for Media ...READ MORE

answered Feb 8, 2022 in Cyber Security & Ethical Hacking by Edureka
• 13,620 points
1,148 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP