To permanently change the MAC address on Kali Linux using a script, you can create a startup script that sets the MAC address each time the system boots. Here are the steps:
-
Create the MAC address change script:
- Open a terminal and create a new script file. You can name it
set-mac.sh
.
sudo vim /etc/network/set-mac.sh
- Open a terminal and create a new script file. You can name it
-
Add the following content to
set-mac.sh
:#!/bin/bash # Set the MAC address for the specified network interface # Specify your network interface (e.g., eth0, wlan0) INTERFACE="eth0" # Specify the new MAC address NEW_MAC="AA:AA:AA:AA:AA:22" # Bring the network interface down ip link set dev $INTERFACE down # Change the MAC address ip link set dev $INTERFACE address $NEW_MAC # Bring the network interface up ip link set dev $INTERFACE up
Replace
"eth0"
with your actual network interface name, and00:11:22:33:44:55
with your desired MAC address. -
Make the script executable:
sudo chmod +x /etc/network/set-mac.sh
-
Create a systemd service to run the script at startup:
- Create a new service file in the
/etc/systemd/system
directory. You can name itset-mac.service
.
sudo vim /etc/systemd/system/set-mac.service
- Create a new service file in the
-
Add the following content to
set-mac.service
:[Unit] Description=Set MAC address at startup After=network.target [Service] Type=oneshot ExecStart=/etc/network/set-mac.sh RemainAfterExit=yes [Install] WantedBy=multi-user.target
-
Enable and start the service:
sudo systemctl enable set-mac.service sudo systemctl start set-mac.service
-
Verify the new MAC address:
- After restarting the network service or rebooting the system, check the MAC address to ensure it has been changed.
ip link show $INTERFACE
Replace
$INTERFACE
with your network interface name.
By following these steps, you should have a script and service in place that will change the MAC address permanently on Kali Linux every time the system boots.
Alternative using /etc/rc.local if there is no systemd
If the Busybee bWAPP (Bee-box) environment doesn't use systemd
(and instead might be using init
or upstart
), you can still achieve the goal by using the appropriate initialization system. Here’s an alternative method using the traditional rc.local
script:
Step 1: Create the MAC Address Change Script
-
Open a terminal and create a new script file:
sudo nano /etc/network/set-mac.sh
-
Add the following content to
set-mac.sh
:#!/bin/bash # Set the MAC address for the specified network interface # Specify your network interface (e.g., eth0, wlan0) INTERFACE="eth0" # Specify the new MAC address NEW_MAC="00:11:22:33:44:55" # Bring the network interface down ip link set dev $INTERFACE down # Change the MAC address ip link set dev $INTERFACE address $NEW_MAC # Bring the network interface up ip link set dev $INTERFACE up
Replace
"eth0"
with your actual network interface name, and00:11:22:33:44:55
with your desired MAC address. -
Make the script executable:
sudo chmod +x /etc/network/set-mac.sh
Step 2: Add the Script to rc.local
-
Open the
rc.local
file for editing:sudo nano /etc/rc.local
-
Add the following line to the
rc.local
file before theexit 0
line:/etc/network/set-mac.sh
Ensure the file looks something like this:
#!/bin/sh -e # # rc.local # # This script is executed at the end of each multiuser runlevel. # Make sure that the script will "exit 0" on success or any other # value on error. # # By default this script does nothing. /etc/network/set-mac.sh exit 0
-
Make sure
rc.local
is executable:sudo chmod +x /etc/rc.local
Step 3: Reboot and Verify the MAC Address
-
Reboot the system:
sudo reboot
-
After the system reboots, verify that the MAC address has been changed:
ip link show $INTERFACE
Replace
$INTERFACE
with your actual network interface name.
By using the rc.local
method, you ensure that the MAC address change script runs at startup, achieving the goal without relying on systemd
.