LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-18-2016, 03:10 AM   #1
mangya
Member
 
Registered: Jul 2015
Distribution: CentOS
Posts: 89

Rep: Reputation: Disabled
How to change MAC address at every boot?


Hello All

I'm using latest Kali Linux in VirtialBox environment and want to change MAC address to random on every boot.

This is what I did:
Code:
root@kali:~# crontab -e
And added this line:
Code:
@reboot /usr/bin/macchanger -r eth0
But its not working. What am I doing wrong?

It works on commandline though..

Code:
root@kali:~# macchanger -s eth0
Current MAC:   08:00:27:dd:8b:12 (CADMUS COMPUTER SYSTEMS)
Permanent MAC: 08:00:27:dd:8b:12 (CADMUS COMPUTER SYSTEMS)

root@kali:~# macchanger -r eth0
Current MAC:   08:00:27:dd:8b:12 (CADMUS COMPUTER SYSTEMS)
Permanent MAC: 08:00:27:dd:8b:12 (CADMUS COMPUTER SYSTEMS)
New MAC:       4e:c4:2f:f4:45:77 (unknown)

root@kali:~# macchanger -s eth0
Current MAC:   4e:c4:2f:f4:45:77 (unknown)
Permanent MAC: 08:00:27:dd:8b:12 (CADMUS COMPUTER SYSTEMS)
Thanks
 
Old 10-18-2016, 10:19 PM   #2
mpapet
Member
 
Registered: Nov 2003
Location: Los Angeles
Distribution: debian
Posts: 548

Rep: Reputation: 72
I don't know about the app macchanger. ]
Work out a shell script that generates a valid(!!!) mac address.

Code:
$generate_random_mac_psuedo-code
ip link set dev interface down
ip link set dev interface address $random_mac_address
ip link set dev interface up
I like using at to wait for the OS to get booted. https://linux.die.net/man/1/at

I don't know how systemd has fubar-ed /etc/rc.local, but once upon a time, /etc/rc.local was used to run your boot scripts. Put your AT command in /etc/rc.local that triggers your random mac script.

Last edited by mpapet; 10-18-2016 at 10:21 PM.
 
Old 10-19-2016, 08:54 AM   #3
mangya
Member
 
Registered: Jul 2015
Distribution: CentOS
Posts: 89

Original Poster
Rep: Reputation: Disabled
@mpapet Thanks, but I want to use macchanger only as it have many other options. I want to know why cron job is not working. According to Archi wiki, there is another method - That too not working.

https://wiki.archlinux.org/index.php...ing#macchanger

Thanks
 
Old 10-19-2016, 05:10 PM   #4
Jjanel
Member
 
Registered: Jun 2016
Distribution: any&all, in VBox; Ol'UnixCLI; NO GUI resources
Posts: 999
Blog Entries: 12

Rep: Reputation: 364Reputation: 364Reputation: 364Reputation: 364
crontab -l (tho this is unlikely to show anything wrong). Works here:

Login after adding (copy&paste) your line, and reboot: (before adding, current=perm)

root@host-7-41:~# macchanger -s eth0
Permanent MAC: 00:0c:29:00:07:90 (Vmware, Inc.)
Current MAC: fc:ca:e2:6b:b7:e9 (unknown)
root@host-7-41:~# uname -a
Linux ... 3.12-kali1-amd64 #1 SMP Debian 3.12.6-2kali1 (2014-01-06) x86_64 GNU/Linux
root@host-7-41:~# w
23:01:16 up 1 min, 2 users, load average: 0.19, 0.09, 0.04
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root pts/0 hub1-gw.domain 23:00 4.00s 0.20s 0.00s w
root@host-7-41:~#

Post your `uname -a; w`
 
1 members found this post helpful.
Old 10-20-2016, 09:42 AM   #5
mangya
Member
 
Registered: Jul 2015
Distribution: CentOS
Posts: 89

Original Poster
Rep: Reputation: Disabled
Code:
root@kali:~# uname -a
Linux kali 4.7.0-kali1-amd64 #1 SMP Debian 4.7.5-1kali3 (2016-09-29) x86_64 GNU/Linux

root@kali:~# w
 20:07:36 up 2 min,  1 user,  load average: 0.80, 0.65, 0.27
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
root     tty2     :1               20:06    2:11   5.92s  0.02s /usr/lib/tracker/tracker-extract
 
Old 10-21-2016, 01:48 AM   #6
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,630

Rep: Reputation: 2652Reputation: 2652Reputation: 2652Reputation: 2652Reputation: 2652Reputation: 2652Reputation: 2652Reputation: 2652Reputation: 2652Reputation: 2652Reputation: 2652
you do know that you will need to also change the MAC of the HOST machine

this is a Virtual install of kail

or are you using a usb wireless card
 
1 members found this post helpful.
Old 10-21-2016, 05:17 AM   #7
mangya
Member
 
Registered: Jul 2015
Distribution: CentOS
Posts: 89

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by John VV View Post
you do know that you will need to also change the MAC of the HOST machine

this is a Virtual install of kail

or are you using a usb wireless card
Thanks for replying. I found out that the problem is with VirtualBox. I tried the same-thing in VMWare Player - it works.

Problem solved. Thanks.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
change mac address baby_ Linux - Networking 1 12-30-2009 08:26 AM
How can I change/set the MAC address at boot time under SuSE? Basel Linux - Networking 6 10-20-2006 12:23 AM
How to change MAC address automatically on boot rollo Debian 4 10-16-2006 05:22 PM
OpenBSD: Adding a "lladdr" command to netstart to change MAC address at boot Voltar *BSD 2 04-14-2006 12:41 AM
MAC address change? w9q Linux - Networking 3 09-10-2004 02:42 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:02 PM.

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