This Go application scans the local network and retrieves detailed information about connected devices. It uses the nmap
tool to scan the network and the net
package to gather additional details such as IPv4, IPv6, hardware address, and default route.
- Scans the local network for connected devices.
- Retrieves detailed information about each device, including:
- IPv4 address
- IPv6 address
- Hardware address (MAC address)
- Default route
- Go (Golang) installed on your system.
nmap
installed and available in your system's PATH.
-
Clone the repository:
git clone https://github.com/yourusername/network-device-scanner.git cd network-device-scanner
-
Install the required dependencies:
go mod tidy
-
Build the application:
go build -o network-device-scanner
-
Run the application:
./network-device-scanner
The main
function initializes the scanning process by retrieving the local IP address and then scanning the network.
func main() {
localIP, err := getLocalIP()
if err != nil {
log.Fatalf("Error getting local IP: %v", err)
}
fmt.Printf("Local IP: %s\n", localIP)
devices, err := scanNetwork(localIP)
if err != nil {
log.Fatalf("Error scanning network: %v", err)
}
displayResults(devices)
}