You are not logged in.

#1 2006-12-19 19:34:24

gunshot
Member
From: Bulgaria
Registered: 2006-09-01
Posts: 35

(solved) masking eth0 MAC permanently

Hello. My ISP remembers the mac adresses. So to use internet on my linux machine, I mask it with macchanger (as root!):

/etc/rc.d/network stop
macchanger --mac=00:20:ed:6e:b4:34 eth0
/etc/rc.d/network start

An everything goes fine(the mac changes and i have internet)
But when i restart, the mac isstill the old one, and I have to change it again. how to solve this? Maybe add this commands somewhere so arch will execute them every time? But where?

Thank you.

Offline

#2 2006-12-19 22:14:34

byte
Member
From: Düsseldorf (DE)
Registered: 2006-05-01
Posts: 2,046

Re: (solved) masking eth0 MAC permanently

/etc/rc.local is exactly for something like this.


1000

Offline

#3 2006-12-19 22:15:37

mr.MikyMaus
Member
From: disabled
Registered: 2006-03-31
Posts: 285

Re: (solved) masking eth0 MAC permanently

Hello gunshot!

gunshot wrote:

But when i restart, the mac isstill the old one, and I have to change it again. how to solve this? Maybe add this commands somewhere so arch will execute them every time? But where?

You may want to write your own 'daemon', which will handle macchange on boot. As an example you may use the /etc/rc.d/alsa daemon, which does quite similar things to what you want to do...

If you're not experienced in shell scripts then let me know.. If I'll have time, I write it for you wink

-miky


What happened to Arch's KISS? systemd sure is stupid but I must have missed the simple part ...

... and who is general Failure and why is he reading my harddisk?

Offline

#4 2006-12-19 23:00:12

gunshot
Member
From: Bulgaria
Registered: 2006-09-01
Posts: 35

Re: (solved) masking eth0 MAC permanently

Thank you for your help. Your answers were useful and I'll see what I can do myself. If I come to a solution or became stuck, I'll write.

Thank you.

Offline

#5 2006-12-21 10:56:23

gunshot
Member
From: Bulgaria
Registered: 2006-09-01
Posts: 35

Re: (solved) masking eth0 MAC permanently

i've done a new file:
/etc/rc.d/mac_eth0

so when i write (as root):
/etc/rc.d/mac_eth0 start
if sets everything fine

i don't know if this is a right way to do it.
so, if there's a way to start this file (as root) every time the systems starts and you know it, please tell me.

if this shouldn't or can't be done that way, please give me some directions how to do it.

thank you.

Offline

#6 2006-12-21 11:29:26

Bob Day
Member
Registered: 2005-11-26
Posts: 43

Re: (solved) masking eth0 MAC permanently

That is indeed the right way.

To start the daemon every time as root on a system start edit /etc/rc.conf:

DAEMONS=(... mac_eth0 network ...)

I guess  you have to place the mac_eth0 daemon in front of the network daemon!

Offline

#7 2006-12-21 12:49:21

mr.MikyMaus
Member
From: disabled
Registered: 2006-03-31
Posts: 285

Re: (solved) masking eth0 MAC permanently

gunshot wrote:

i don't know if this is a right way to do it.
so, if there's a way to start this file (as root) every time the systems starts and you know it, please tell me.

if this shouldn't or can't be done that way, please give me some directions how to do it.

That is imho the best way to do such things. All you need to do is, as Bob Day wrote, add your mac_eth0 to DAEMONS array in /etc/rc.conf.

It will cause the mac_eth0 script to be called on system startup as root with 'start' parameter and with 'stop' parameter on system shutdown.

It has to be written before 'network' daemon in order to set MAC before network is fired up...

Just  out of curiosity, could you paste that mac_eth0 script here? ;-)

-miky


What happened to Arch's KISS? systemd sure is stupid but I must have missed the simple part ...

... and who is general Failure and why is he reading my harddisk?

Offline

#8 2006-12-21 16:36:34

gunshot
Member
From: Bulgaria
Registered: 2006-09-01
Posts: 35

Re: (solved) masking eth0 MAC permanently

The problem is solved.
Thanks to mr.MikyMaus and Bob Day.

I had 2 errors:
1st. I tried to start the daemont last in rc.conf and to restart the network and this makes no sence
2nd. A minor error in the script

After fixing them everything works PERFECT  big_smile
Here is the code (although I doubt if it would be useful for someone):

/etc/rc.conf

#...
DAEMONS=(syslog-ng !hotplug mac_eth0 network sshd netfs crond xinetd httpd)
#...

/etc/rc.d/mac_eth0

#!/bin/bash

#This file changes the MAC address of eth0

start()
{
        echo "Changing MAC..."
        /usr/local/bin/macchanger --mac=00:20:ed:6e:b4:34 eth0
}

stop()
{
        echo "Macchanger stops"
}

case "$1" in
 start)
  start
 ;;
 stop)
  stop
 ;;
 *)
  echo "Use $0 [start] to change the MAC!"
 ;;
esac
exit 0

Offline

#9 2006-12-21 16:57:51

mr.MikyMaus
Member
From: disabled
Registered: 2006-03-31
Posts: 285

Re: (solved) masking eth0 MAC permanently

I'm glad it works to your satisfaction:)

gunshot wrote:

Here is the code (although I doubt if it would be useful for someone):

I would not be so sure about this. I myself have exactly the same problem with my network card. I have to rewrite MAC everytime prior connecting to network.

The only difference is that I cannot afford such comfort of changing mac on boot because MAC, in my case, has to be rewritten prior to connecting cable to card.

So I have a script which does both MAC change and network start and I run it manually.

But not everyone has to have his MAC rewritten prior to connection. If you'd like to practise some shell coding, you may alter your script to be more portable, like adding some configuration files to /etc/conf.d/ and make it ArchLinux-compilant. I can help with that, if you wish.

And you can be sure you'll make at least a few archers happy, including you ;-)

-miky


What happened to Arch's KISS? systemd sure is stupid but I must have missed the simple part ...

... and who is general Failure and why is he reading my harddisk?

Offline

#10 2006-12-21 18:08:00

gunshot
Member
From: Bulgaria
Registered: 2006-09-01
Posts: 35

Re: (solved) masking eth0 MAC permanently

That's a good idea. That was my first step (maybe second) in bash script writting, so need practice.
what needs to be done is
1. storing the old MAC and an option to restore it (./mac_eth0 stop)
2. dispalying information about the original and the current MAC (./mac_eth0 info)
3. configuration - network adapter and new MAC
4. other stuff, that I don't know smile

When I have time and access to my arch machine, I'll be glad to do it smile (With your help if necessary)

Offline

Board footer

Powered by FluxBB