Set the value reported for a network card MAC address.
This program demonstrates the use of LD_PRELOAD to override the value returned by the library call. The library call in question is ioctl. When called with cmd set to SIOCGIFHWADDR, we override the value returned by the system call with the value from an environment variable.
To use the program, first set the environment variable
HWADDR_interface to the MAC address you would
like to be returned. For example, to set eth0 to 11:22:33:44:55:66, do
HWADDR_eth0=11:22:33:44:55:66 export HWADDR_eth0
Then set LD_PRELOAD to the absolute path of fakeif.so and call your test program.
Peter Benie <email@example.com>