A lightweight utility to discover MAC addresses by sending ICMP echo requests.
- IPv4 support
- Raw socket implementation
- Automatic interface detection
- Docker container support
- Comprehensive test suite
- Install compiler:
sudo apt install g++
- Build:
make
- Run:
sudo ./getmac <IP_ADDRESS>
- Build image:
make docker_build
- Run:
docker run getmac <IP_ADDRESS>
getmac.cpp- Main applicationicmp_mac_resolver.h- Header fileicmp_mac_resolver.cpp- Core functionalitytest_icmp_mac_resolver.cpp- Test casesMakefile- Build automationDockerfile- Container configuration
Run the test suite:
make test- Linux kernel
- Root privileges (for raw sockets)
- g++ (C++11 or newer)
- Docker (optional)
-
Basic usage:
sudo ./getmac 192.168.1.1
-
Docker usage:
docker run getmac 10.0.0.1
-
Run tests:
make test
- Requires
CAP_NET_RAWcapability in containers - Timeout is set to 2 seconds by default
- Falls back to
eth0if auto-detection fails