Linux Automated Hostname and MAC Address Randomization 11-27-2023, 10:27 PM
#1
I am using this code successfully on Ubuntu 22.04 LTS.
First, we set automatic mac randomization, then Hostname randomization. With both randomizations enabled, each time we boot up the system, we get a new hostname and WIFI mac address, appearing as a new computer to any WIFI networks we connect to.
mac randomization:
1. first, Create the file /etc/NetworkManager/conf.d/00-macrandomize.conf and edit it with sudo. Append the following into the file:
2. copy paste this code into your text editor for the macrandomize.conf file:
[device]
wifi.scan-rand-mac-address=yes
[connection]
wifi.cloned-mac-address=random
ethernet.cloned-mac-address=random
connection.stable-id=${CONNECTION}/${BOOT}
3. run this terminal command to restart network manager:
systemctl restart NetworkManager
hostname randomization:
macrandomization.sh :
#!/bin/bash
hostnamectl hostname "$(shuf -n 1 /home/USER/Desktop/Texts/hostnames1.txt)"
macrandomize.service :
[Unit]
Description=Randomize Hostname upon device bootup, before network interface starts.
Before=network-pre.target
[Service]
Type=oneshot
ExecStart=/bin/bash /usr/bin/macrandomize.sh
[Install]
WantedBy=network-pre.target
Thank you and enjoy
First, we set automatic mac randomization, then Hostname randomization. With both randomizations enabled, each time we boot up the system, we get a new hostname and WIFI mac address, appearing as a new computer to any WIFI networks we connect to.
mac randomization:
1. first, Create the file /etc/NetworkManager/conf.d/00-macrandomize.conf and edit it with sudo. Append the following into the file:
2. copy paste this code into your text editor for the macrandomize.conf file:
[device]
wifi.scan-rand-mac-address=yes
[connection]
wifi.cloned-mac-address=random
ethernet.cloned-mac-address=random
connection.stable-id=${CONNECTION}/${BOOT}
3. run this terminal command to restart network manager:
systemctl restart NetworkManager
hostname randomization:
macrandomization.sh :
#!/bin/bash
hostnamectl hostname "$(shuf -n 1 /home/USER/Desktop/Texts/hostnames1.txt)"
macrandomize.service :
[Unit]
Description=Randomize Hostname upon device bootup, before network interface starts.
Before=network-pre.target
[Service]
Type=oneshot
ExecStart=/bin/bash /usr/bin/macrandomize.sh
[Install]
WantedBy=network-pre.target
Thank you and enjoy
![Smile Smile](https://sinister.ly/images/smilies/set/smile.png)
(This post was last modified: 11-27-2023, 10:48 PM by EliteWizard42.)