Skip to content

sg41/getmac

Repository files navigation

getmac - ICMP MAC Address Resolver

A lightweight utility to discover MAC addresses by sending ICMP echo requests.

Features

  • IPv4 support
  • Raw socket implementation
  • Automatic interface detection
  • Docker container support
  • Comprehensive test suite

Building

Local Build

  1. Install compiler:
    sudo apt install g++
  2. Build:
    make
  3. Run:
    sudo ./getmac <IP_ADDRESS>

Docker Build

  1. Build image:
    make docker_build
  2. Run:
    docker run getmac <IP_ADDRESS>

File Structure

  • getmac.cpp - Main application
  • icmp_mac_resolver.h - Header file
  • icmp_mac_resolver.cpp - Core functionality
  • test_icmp_mac_resolver.cpp - Test cases
  • Makefile - Build automation
  • Dockerfile - Container configuration

Testing

Run the test suite:

make test

Requirements

  • Linux kernel
  • Root privileges (for raw sockets)
  • g++ (C++11 or newer)
  • Docker (optional)

Usage Examples

  1. Basic usage:

    sudo ./getmac 192.168.1.1
  2. Docker usage:

    docker run getmac 10.0.0.1
  3. Run tests:

    make test

Notes

  • Requires CAP_NET_RAW capability in containers
  • Timeout is set to 2 seconds by default
  • Falls back to eth0 if auto-detection fails

License

MIT

About

getmac - simple CLI utility to get MAC address by IP

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published