macchanger
Linux

Changer l’adresse MAC avec macchanger sous CentOS

Il y a plusieurs raison pour changer l’adresse MAC réel d’une carte réseau, parmi ces raisons vous souhaitez ne pas montrer l’adresse réelles de votre carte réseau sur un réseau public.

Dans cette article nous allons voir comment changer l’adresse MAC sous CentOS 7/8 avec macchanger.

Méthode 1 : L’outil Macchanger

Installer macchanger :

Macchanger est un outil qui permet de changer l’adresse MAC réelle d’une carte réseau d’une façon simple.

Installer d’abord le package avec macchanger et vu que ce package n’est pas présent sur les dépôts par défaut, nous allons l’installer depuis le code source sur github :

https://github.com/alobbs/macchanger/releases

macchanger

Installer ensuite le package avec les commandes ci-dessous :

[root@node1 ~]# tar xzf macchanger-1.7.0.tar.gz

[root@node1 ~]# ll
total 396
-rw-------. 1 root root    1265 Apr 27  2021 anaconda-ks.cfg
drwxr-xr-x. 6  501 wheel   4096 Jan  1  2014 macchanger-1.7.0
-rw-r--r--. 1 root root  396848 Dec  8 02:50 macchanger-1.7.0.tar.gz

Si vous recontrez une erreur de complication comme montré ci-dessous, il suffit d’installer les outils de compilation :

[root@node1 ~]# cd macchanger-1.7.0/
[root@node1 macchanger-1.7.0]# ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether make supports nested variables... (cached) yes
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/root/macchanger-1.7.0':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
[root@node1 macchanger-1.7.0]# yum groupinstall "Development Tools"

Une fois installé continuez la compilation :

[root@node1 macchanger-1.7.0]# ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether make supports nested variables... (cached) yes
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc understands -c and -o together... yes
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating src/Makefile
config.status: creating data/Makefile
config.status: creating doc/Makefile
config.status: creating config.h
config.status: executing depfiles commands
[root@node1 macchanger-1.7.0]# make
make  all-recursive
make[1]: Entering directory `/root/macchanger-1.7.0'
Making all in src
make[2]: Entering directory `/root/macchanger-1.7.0/src'
  CC       mac.o
  CC       maclist.o
  CC       netinfo.o
  CC       main.o
  CCLD     macchanger
make[2]: Leaving directory `/root/macchanger-1.7.0/src'
Making all in data
make[2]: Entering directory `/root/macchanger-1.7.0/data'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/root/macchanger-1.7.0/data'
Making all in doc
make[2]: Entering directory `/root/macchanger-1.7.0/doc'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/root/macchanger-1.7.0/doc'
make[2]: Entering directory `/root/macchanger-1.7.0'
make[2]: Leaving directory `/root/macchanger-1.7.0'
make[1]: Leaving directory `/root/macchanger-1.7.0'
[root@node1 macchanger-1.7.0]# make install
Making install in src
make[1]: Entering directory `/root/macchanger-1.7.0/src'
make[2]: Entering directory `/root/macchanger-1.7.0/src'
 /usr/bin/mkdir -p '/usr/local/bin'
  /usr/bin/install -c macchanger '/usr/local/bin'
make[2]: Nothing to be done for `install-data-am'.
make[2]: Leaving directory `/root/macchanger-1.7.0/src'
make[1]: Leaving directory `/root/macchanger-1.7.0/src'
Making install in data
make[1]: Entering directory `/root/macchanger-1.7.0/data'
make[2]: Entering directory `/root/macchanger-1.7.0/data'
make[2]: Nothing to be done for `install-exec-am'.
 /usr/bin/mkdir -p '/usr/local/share/macchanger'
 /usr/bin/install -c -m 644 OUI.list wireless.list '/usr/local/share/macchanger'
make[2]: Leaving directory `/root/macchanger-1.7.0/data'
make[1]: Leaving directory `/root/macchanger-1.7.0/data'
Making install in doc
make[1]: Entering directory `/root/macchanger-1.7.0/doc'
make[2]: Entering directory `/root/macchanger-1.7.0/doc'
make[2]: Nothing to be done for `install-exec-am'.
 /usr/bin/mkdir -p '/usr/local/share/info'
 /usr/bin/install -c -m 644 ./macchanger.info '/usr/local/share/info'
 install-info --info-dir='/usr/local/share/info' '/usr/local/share/info/macchanger.info'
make[2]: Leaving directory `/root/macchanger-1.7.0/doc'
make[1]: Leaving directory `/root/macchanger-1.7.0/doc'
make[1]: Entering directory `/root/macchanger-1.7.0'
make[2]: Entering directory `/root/macchanger-1.7.0'
make[2]: Nothing to be done for `install-exec-am'.
 /usr/bin/mkdir -p '/usr/local/share/man/man1'
 /usr/bin/install -c -m 644 macchanger.1 '/usr/local/share/man/man1'
make[2]: Leaving directory `/root/macchanger-1.7.0'
make[1]: Leaving directory `/root/macchanger-1.7.0'

Enfin notre package est bien intstallé :

[root@node1 macchanger-1.7.0]# macchanger --help
GNU MAC Changer
Usage: macchanger [options] device

  -h,  --help                   Print this help
  -V,  --version                Print version and exit
  -s,  --show                   Print the MAC address and exit
  -e,  --ending                 Don't change the vendor bytes
  -a,  --another                Set random vendor MAC of the same kind
  -A                            Set random vendor MAC of any kind
  -p,  --permanent              Reset to original, permanent hardware MAC
  -r,  --random                 Set fully random MAC
  -l,  --list[=keyword]         Print known vendors
  -b,  --bia                    Pretend to be a burned-in-address
  -m,  --mac=XX:XX:XX:XX:XX:XX  Set the MAC XX:XX:XX:XX:XX:XX

Report bugs to https://github.com/alobbs/macchanger/issues

Changement de l’adresse MAC :

D’abord affichez l’adresse MAC avec la commande ci-dessous :

[root@LinuxOS ~]# ip link show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
    link/ether 00:0c:29:a9:88:47 brd ff:ff:ff:ff:ff:ff

Si vous souhaitez attribuer une adresse MAC aléatoire, taper la commande ci-dessous :

[root@node1 ~]# macchanger -r ens33
Current MAC:   00:0c:29:a9:88:47 (VMware, Inc.)
Permanent MAC: 00:0c:29:a9:88:47 (VMware, Inc.)
New MAC:       f2:03:a0:22:9b:e3 (unknown)

Ou bien attribuez une adresse IP statique avec la commande ci-dessous :

[root@node1 ~]# macchanger --mac=k0:02:c0:55:8j:ee ens33
Current MAC:   f2:03:a0:22:9b:e3 (unknown)
Permanent MAC: 00:0c:29:a9:88:47 (VMware, Inc.)
New MAC:       00:02:c0:55:08:ee (Bencent Tzeng Industry Co., Ltd.)
[root@linuxos ~]# ip link show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
    link/ether 00:0c:29:e0:24:5f brd ff:ff:ff:ff:ff:ff

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *