libmacouflage is a Golang library for setting the MAC address for network interfaces on Linux-based operating systems.
The reason for implementing these functions as a library is to make it easy to develop command-line and GUI applications for managing MAC addresses. We at Subgraph will use this library in our own macouflage command-line/GUI application as well as in other places. But others are free to use the library as they wish.
It supports different modes of operation such as those already available in GNU Mac Changer. It also supports a "popular" mode, similar to what is available in the macchiato project.
The data for the "popular" mode is in fact derived from the macchiato project. libmacouflage uses a JSON database that is generated based off the data in macchiato. Scripts to generate the database are hosted in the ouiner project.
The ouiner database ships with libmacouflage so that is available to client programs based on libmacouflage. It is embedded in the libmacouflage object binary using go-bindata.
libmacouflage includes unit tests. Most functions will pass the existing tests without any special caveats. However, setting a MAC address on an interface has a few caveats:
- Only the root user can set a MAC address
- The target network interface must be down to set the MAC address
- Setting a completely random MAC address fails sometimes on certain ranges, which is why it is better to enable the "burned-in address" setting to avoid these ranges, however, specific tests that do not set "burned-in address" may fail as a result
Take down the network interface (eth0 is used as an example):
$ sudo ip link set eth0 down
Then run the tests (interface is specified via the TEST_INTERFACE environment variable):
$ sudo TEST_INTERFACE=eth0 GOPATH=<your_gopath> go test
NOTE: GOPATH should point to the GOPATH for your regular user account or dependencies such as the testify test-suite will not be found
For each network interface:
$ sudo ip link set <interface> down
Then run the tests:
$ sudo GOPATH=<your_gopath> go test