Koozali.org: home of the SME Server

cloning a mac address

rkosiorek1

cloning a mac address
« on: January 11, 2006, 04:45:01 PM »
my isp is Cogeco Cable. i have a static IP. the way this works with cogeco is that thier DHCP server binds my static IP to the mac address of the nic attached to the modem.

presently i an using a Linksys rounter and that IP is bound to the mac of the Linksys router.

i am trying to replace the linksys with sme 6.0.1. since the mac is different i can't connect. is there any way to get the SME server to spoof the address of the Linksys?

Offline gregswallow

  • *
  • 651
  • +1/-0
cloning a mac address
« Reply #1 on: January 12, 2006, 01:45:29 AM »
Check if eth0 or eth1 is your external interface with:
ifconfig

I'll assume it's eth1...then substitute the x's for whatever you want:
ifconfig eth1 down hw ether xx:xx:xx:xx:xx:xx
ifconfig eth1 up

...you might also have to reboot after that.

rkosiorek1

cloning a mac address
« Reply #2 on: January 12, 2006, 03:19:18 AM »
would not the ifconfig setting be lost after a reboot? is there a way to make this change persistant?

Offline gregswallow

  • *
  • 651
  • +1/-0
cloning a mac address
« Reply #3 on: January 12, 2006, 10:05:04 PM »
Hmm, yah it is lost.  I didn't realize that.

I remember changing the mac address on old (ISA) realtek nic's with their DOS setup/diagnostic program.  I don't think they have that for the newer cards.

A quick google found this page:
http://www.scyld.com/ethercard_diag.html#pci-diags
..with the same sort of programs for linux, and for newer pci cards.

The realtek 8139 is pretty common - if you can find one of those cards you could try this program:
http://mirror.contribs.org/smeserver/contribs/gswallow/misc/rtl8139-diag
(just uploading now)

./rtl8139-diag --help
will tell you:
 To change the persistent EEPROM settings
    -H  --new-hwaddr 01:23:45:67:89:ab
        Set a new hardware station address.  Typically disabled for safety.
   -w  --write-EEPROM    Actually write the new settings into the EEPROM.

This for sure works - I just tested with a Realtek 8139b PCI NIC and the change took place after the reboot.

Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
cloning a mac address
« Reply #4 on: January 13, 2006, 12:46:36 AM »
Quote from: "rkosiorek1"
would not the ifconfig setting be lost after a reboot? is there a way to make this change persistant?


You'll need a line with:

MACADDR=xx:xx:xx:xx:xx:xx

in ifcfg-eth0 or ifcfg-eth1 in /etc/sysconfig/network-scripts. You'll want to put it there via a custom template.

fbx

cloning a mac address
« Reply #5 on: May 06, 2006, 04:51:52 PM »
First post, and first time using SME server custom templates for a MAC change. Newbie. Virgin.

I am installing SME 7pre3 and attempting to use my Linksys FVS318's MAC similiarly. I understand the concept of the custom template - and this change - but I'm a little confused with the form this change should take.

I have tried adding something like this:

"MACADDR=xx:xx:xx:xx:xx:xx\n".

in the if ($is_external) section of /etc/e-smith/templates-custom/etc/sysconfig/network-scripts/ifcfg-ethX/90otherparams which doesn't seem to work even after expanding the template (to /etc/sysconfig/network-scripts/ifcfg-eth1). This holds true whether I try entering it inside or outside of the return.

I've also tried returning this value to a new file in the above directory, calling it 15MACADDR, and subsequently attempting larger numbers to position it's usage between other ifcfg-ethX files; still no joy.

I'm a bit frustrated and humbled about this. Seems like it should be rather easy, but I'm scratching my head. Any help would be appreciated as to position, filename, coding or, well, everything else I might be doing wrong. Thanks.

Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
cloning a mac address
« Reply #6 on: May 06, 2006, 04:56:44 PM »
Quote from: "fbx"
... which doesn't seem to work even after expanding the template (to /etc/sysconfig/network-scripts/ifcfg-eth1).


Please define "doesn't work". Do you mean that the text doesn't get included in the ifcfg-eth1 file, or the network connection doesn't work correctly afterwards? If the former, then please show what you are putting in your custom template.

fbx

cloning a mac address
« Reply #7 on: May 06, 2006, 05:52:15 PM »
Thanks for the quick response, Charlie!

OK, for now, I have the external going to an internal port on the FVS318. It does receive an IP from DHCP on the 318, and ifconfig -a yields the actual MAC of the NIC, not the MACADDR I've returned in 90otherparams.

Here is the entire /etc/e-smith/templates-custom/etc/sysconfig/network-scripts/ifcfg-ethX/90otherparams file right now:

{
    use esmith::util;

    if ($ifup_this_device eq "no")
    {
   # Need syntactically valid IP address to avoid complaints
   # from init.d/network script
   return "IPADDR=1.1.1.1";
    }

    if ($is_external)
    {
   # We are now running a supervised dhcpcd - setting the BOOTPROTO to "none"
   # allows the supervised dhcpcd to do the work without fighting with ifup
   return "BOOTPROTO=none" if ($ExternalDHCP eq "on");

   my ($network, $broadcast) = esmith::util::computeNetworkAndBroadcast ($ExternalIP, $ExternalNetmask);

   return "BOOTPROTO=none\n" .
        "MACADDR=<MAC I want in xx:xx form>\n".
        "IPADDR=$ExternalIP\n" .
        "NETMASK=$ExternalNetmask\n" .
        "NETWORK=$network\n" .
        "BROADCAST=$broadcast";
    }
    return "" unless ($is_internal);

    my ($network, $broadcast) = esmith::util::computeNetworkAndBroadcast ($LocalIP, $LocalNetmask);

    return "BOOTPROTO=none\n" .
    "IPADDR=$LocalIP\n" .
    "NETMASK=$LocalNetmask\n" .
    "NETWORK=$network\n" .
    "BROADCAST=$broadcast";
}



The /etc/sysconfig/network-scripts/ifcfg-eth1 file is as follows:
#------------------------------------------------------------
# DO NOT MODIFY THIS FILE! It is updated automatically by the
# SME Server software. Instead, modify the source template in
# an /etc/e-smith/templates-custom directory. For more
# information, see http://www.e-smith.org/custom/
#
# copyright (C) 1999-2003 Mitel Networks Corporation
#------------------------------------------------------------


TYPE=Ethernet
DEVICE=eth1
USERCTL=no
ONBOOT=no
PEERDNS=no

IPV6INIT=no

IPADDR=1.1.1.1




Obviously, I'm doing something wrong here....are there steps I should repeat, or is the coding wrong?

fbx

cloning a mac address
« Reply #8 on: May 11, 2006, 12:56:00 PM »
Anyone? Anyone? Bueller?  :-D

Seriously, if anyone can help with this, I would greatly appreciate it. If more information is needed, let me know and I'll provide it.

Offline Boris

  • *
  • 783
  • +0/-0
cloning a mac address
« Reply #9 on: May 11, 2006, 06:51:55 PM »
After modifying custom template, did you actualy EXPAND the template, to rebuild the config file?
#/sbin/e-smith/expand-template /etc/sysconfig/network-scripts/ifcfg-ethX
...

fbx

cloning a mac address
« Reply #10 on: May 13, 2006, 05:27:38 AM »
Actually, I expanded it using /sbin/e-smith/expand-template /etc/sysconfig/network-scripts/ifcfg-eth1

I used this because the usage was /sbin/e-smith/expand-template /path/to/file/to/expand

After a pause, the prompt returned. The file /etc/sysconfig/network-scripts/ifcfg-eth1 did not change. No change after reboot either.


I have also tried /sbin/e-smith/expand-template /etc/sysconfig/network-scripts/ifcfg-ethX, and get error after error. It ends with the fantabulous "Template processing failed" as a last error.

No cookie for me, eh?

Offline Boris

  • *
  • 783
  • +0/-0
cloning a mac address
« Reply #11 on: May 15, 2006, 09:23:26 PM »
>>Here is the entire /etc/e-smith/templates-custom/etc/sysconfig/network-scripts/ifcfg-ethX/90otherparams<<

Was it ifcfg-ethX or ifcfg-eth1 in the path?
...

Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
cloning a mac address
« Reply #12 on: May 16, 2006, 03:05:27 AM »
Quote from: "fbx"


...
    if ($is_external)
    {
   # We are now running a supervised dhcpcd - setting the BOOTPROTO to "none"
   # allows the supervised dhcpcd to do the work without fighting with ifup
   return "BOOTPROTO=none" if ($ExternalDHCP eq "on");
....
Obviously, I'm doing something wrong here....are there steps I should repeat, or is the coding wrong?


The section I've left in shows why your change doesn't get into ifcfg-eth1. It also shows why it doesn't matter anyway - the "supervised dhcpcd" will not use the MACADDR=xx:xx:... line anyway. Sorry I didn't realise that earlier.

You would need to edit /service/dhcpcd/run and insert:

  ip link set dev eth1 address xx:xx:...

But why do you want to do this anyway? Can't you just contact your ISP and tell them you have a new router with different MAC address?

fbx

cloning a mac address
« Reply #13 on: May 19, 2006, 02:40:57 AM »
Boris -

It was ethX in the path.

Charlie -

Bummer. I may give the /service/dhcpd/run thing a try in the near future.

I wanted to try this a) for the geek fun of it, and b) because the last four people I know who contacted my ISP ended up having no connection for several days after receiving some fairly horrid support. I know, it's probably not like that all the time, and I'd probably fair better than those folks (as they aren't technical), but it does make me loathe having to call them.

Thanks for now, however. When I try the "ip link set dev eth1 address", I'll return to report how I faired.