Sobes.tech
Senior

How to find out the MAC address of the public DNS server 8.8.8.8?

sobes.tech AI

Answer from AI

MAC address is the physical address of a network interface in a local network. The public DNS server 8.8.8.8 is a remote host on the internet, and it is impossible to directly find out its MAC address because MAC addresses are not transmitted through routers and are only visible within the local network.

Attempting to obtain the MAC address of 8.8.8.8, for example via ARP, will not work because ARP only operates within a single network segment.

In Go, you can attempt to perform an ARP request, but it will only succeed for devices within the local network. For remote IPs, this is impossible.

Example of attempting to get a MAC address in a local network (not for 8.8.8.8):

package main

import (
    "fmt"
    "github.com/mdlayher/arp"
    "net"
)

func main() {
    iface, _ := net.InterfaceByName("eth0")
    client, _ := arp.Dial(iface)
    ip := net.ParseIP("192.168.1.1")
    hwAddr, err := client.Resolve(ip)
    if err != nil {
        fmt.Println("Error:", err)
        return
    }
    fmt.Println("MAC address:", hwAddr)
}

But this will not work for 8.8.8.8. As a result, it is impossible to find out the MAC address of a public DNS server due to network protocol limitations.