LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General > LinuxQuestions.org Member Success Stories
User Name
Password
LinuxQuestions.org Member Success Stories Just spent four hours configuring your favorite program? Just figured out a Linux problem that has been stumping you for months?
Post your Linux Success Stories here.

Notices


Reply
  Search this Thread
Old 09-18-2022, 08:59 PM   #1
starkid
Member
 
Registered: Jan 2012
Posts: 91

Rep: Reputation: Disabled
Red face Automatically change network interface's mac address at boot


This is for presenting a false mac address (the ID of a wired or wireless network card). You might do this to preserve your anonymity online (some public networks track mac addresses).

Make sure some version of cron (I did this with cronie) and macchanger are installed. At the command line, verify the install location of macchanger (aka its full path) with the whereis command (I had to use sudo to find the location):

Code:
sudo whereis macchanger
Get the name of the network interface you want to change:

Code:
ip link show
This shows all the network devices installed in the computer; if you haven't changed the names, the wireless interface names probably start with 'w' and the wired ones probably start with 'e.' The output will look similar to this:

Code:
1: lo: text-you-can-ignore
2: wlan0 text-you-can-ignore
3: wlan1 etc.
4: enp10s0 etc. etc.
The wlan0, wlan1, and enp10s0 are the interface names (the computer has two wireless cards and one Ethernet card in this example).

Create a cron job with sudo aka for the root account (because macchanger must be run with root privileges):

Code:
sudo crontab -e
A file should pop up in your preferred text editor (you can set a preferred editor with the EDITOR environment variable; look it up).

In the file, type:

Code:
@reboot /full/path/to/macchanger -options interface_name
For example
Code:
@reboot /sbin/macchanger -r eth0
gives the network device eth0 a random mac address every time you boot the computer.

Save and close the file.

Check cron man page for running the job at other times/intervals and check macchanger man page for other options.

Optional: If your system has no cron log file and you want to check errors/output of this cron job, create a log file at the same time you create the cron job (or edit the existing cron job by typing
Code:
sudo crontab -e
again:

Code:
@reboot /path/to/macchanger -options interface_name >> /full/path/to/some_textfile > 2>&1
Cron will create some_textfile if it doesn't exist.

Last edited by starkid; 09-18-2022 at 09:29 PM.
 
  


Reply

Tags
anonymity, cron, mac address, network interface



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Change mac address to multicast mac address ubuntuv Linux - Networking 5 01-16-2019 07:21 AM
how do I find what MAC address web pages see as my MAC address rob.rice General 20 05-29-2010 02:08 AM
How to change MAC address automatically on boot rollo Debian 4 10-16-2006 05:22 PM
how to get ip address, broadcast address, mac address of a machine sumeshstar Programming 2 03-12-2005 04:33 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General > LinuxQuestions.org Member Success Stories

All times are GMT -5. The time now is 08:02 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration