Koozali.org: home of the SME Server

Obsolete Releases => SME Server 7.x => Topic started by: beckynet on March 27, 2009, 08:43:03 PM

Title: Help ! Clone Mac Address on WAN Interface
Post by: beckynet on March 27, 2009, 08:43:03 PM
I've find this topic, but the SME structure have changed.

http://forums.contribs.org/index.php/topic,16551.msg

I use a cable modem, and my provider provide address for a specified Mac Address.

How can I clone mine on the Wan Interface

Thanks a Lot

Olivier Beeckmans
Title: Re: Help ! Clone Mac Address on WAN Interface
Post by: maounique on March 27, 2009, 09:18:27 PM
I presume is it the standard eth1 for external connection and you do not have it swapped:

ifdown eth1
ifconfig eth1 hw ether XX:XX:XX:XX:XX:XX
ifup eth1
ifconfig eth1

Do it first by hand to test if it works and you can connect, then make a custom template as per the example in the thread you linked. That should be for the /etc/e-smith/templates/custom/etc/rc.d/rc.local
Of course, you may make this modification elsewhere, that is how i do my stuff so I can have it all in the same place since it is very hard to remember what changes i made in which server since I have so many to look after.
Last line can be omitted in the template, it is just to check if the address changed.
Quick and dirty, but simple and should work.
M
Title: Re: Help ! Clone Mac Address on WAN Interface
Post by: Stefano on March 27, 2009, 09:24:50 PM
hi

try this:

1) create /etc/e-smith/templates-custom/etc/sysconfig/network-scripts/ifcfg-ethX directory
Code: [Select]
mkdir -p /etc/e-smith/templates-custom/etc/sysconfig/network-scripts/ifcfg-ethX

2) copy the right fragment into it
Code: [Select]
cp /etc/e-smith/templates/etc/sysconfig/network-scripts/ifcfg-ethX/90otherparams /etc/e-smith/templates-custom/etc/sysconfig/network-scripts/ifcfg-ethX/
NOTE: it's one line

3) edit the fragment
Code: [Select]
pico /etc/e-smith/templates-custom/etc/sysconfig/network-scripts/ifcfg-ethX/90otherparams

and modify in this way:

Code: [Select]
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 " .
        "IPADDR=$ExternalIP " .
        "MACADDR=AA:BB:CC:DD:EE:FF " .
        "NETMASK=$ExternalNetmask " .
        "NETWORK=$network " .
        "BROADCAST=$broadcast";
    }

DO NOT TOUCH the rest of file

save and close it with Ctrl-X

now I would do
Code: [Select]
signal-event post-upgrade
signal-event reboot

should work :)

HTH
Ciao
Stefano
Title: Re: Help ! Clone Mac Address on WAN Interface
Post by: maounique on March 27, 2009, 09:37:24 PM
By the book !
:)
M
Title: Re: Help ! Clone Mac Address on WAN Interface
Post by: beckynet on March 27, 2009, 10:49:38 PM
Thanks for this quick and complete respons.

Olivier Beeckmans
Title: Re: Help ! Clone Mac Address on WAN Interface
Post by: beckynet on April 03, 2009, 03:25:51 PM
Hi Stefano,

I've try your solution that don't run.

I've selected for my external Address (eth1 is the external Interface) :
Use DHCP (send ethernet address as client identifier)

But when the External DHCP Server provide one IP address, the MAC ADDRESS send is the real physical address not the address provide in the script.

content of the ifcfg-eth1 after creation of custom template and signal-event post-upgrade
I don't see any MACADDRESS Param
Code: [Select]
TYPE=Ethernet
DEVICE=eth1


USERCTL=no
ONBOOT=no
PEERDNS=no

IPV6INIT=no

IPADDR=1.1.1.1

I've try that manually edit it
Code: [Select]
TYPE=Ethernet
DEVICE=eth1


USERCTL=no
ONBOOT=no
PEERDNS=no

IPV6INIT=no

IPADDR=1.1.1.1
MCADDRESS=AA:BB:CC:DD:EE:FF

The result is the same

if I do (with or without the custom template)

Code: [Select]
#ifdown eth1
#ifup eth1

after that the network is unreachable  :???:

What must I do ? Must I edit the dhcp client of SME ? where is it ?

Thanks a lot

Olivier Beeckmans
Title: Re: Help ! Clone Mac Address on WAN Interface
Post by: Stefano on April 03, 2009, 03:31:07 PM
ok.. try this:

Code: [Select]
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
   if ($ExternalDHCP eq "on") {
         return "BOOTPROTO=none" .
          "MACADDR=AA:BB:CC:DD:EE:FF ";
   }
   my ($network, $broadcast) = esmith::util::computeNetworkAndBroadcast ($ExternalIP, $ExternalNetmask);

   return "BOOTPROTO=none " .
        "IPADDR=$ExternalIP " .
        "NETMASK=$ExternalNetmask " .
        "NETWORK=$network " .
        "BROADCAST=$broadcast";
    }


and let us know..

thank you
ciao
Stefano
Title: Re: Help ! Clone Mac Address on WAN Interface
Post by: uniqsys on April 03, 2009, 03:55:52 PM
Ciao Stefano,

Once you get this working, I would like to create a How To on this.

Grazie tante, va bene.
Title: Re: Help ! Clone Mac Address on WAN Interface
Post by: beckynet on April 03, 2009, 04:03:53 PM
That don't run  :sad:

The physical Mac Address is used.

Thanks for your quick respons

Olivier Beeckmans

Title: Re: Help ! Clone Mac Address on WAN Interface
Post by: beckynet on April 04, 2009, 08:11:36 PM
Hey, SME Guru !

I really need a solution to modify the Mac Address send by the DHCP Client of my WAN Interface (eth1).

My Internet Provider don't allow traffic on other Mac Address

Thanks a Lot

Olivier Beeckmans
Title: Re: Help ! Clone Mac Address on WAN Interface
Post by: Stefano on April 04, 2009, 09:06:34 PM
Olivier..

ask your ISP to modify its setting to the new MAC.. it seems to me the only alternative.

then create a NFR in bugzilla for such a function

Thank you
ciao
Stefano
Title: Re: Help ! Clone Mac Address on WAN Interface
Post by: CharlieBrady on April 04, 2009, 09:17:00 PM
My Internet Provider don't allow traffic on other Mac Address

Then they are not providing you with what you are paying them for. Get them to change their MAC assignment, or find another ISP.
Title: Re: Help ! Clone Mac Address on WAN Interface
Post by: beckynet on April 04, 2009, 09:56:41 PM
The company changed ownership. If I change something I have to do a less advantageous contract.

I have a upload bandwidth up to 2 Mb, If I must resign a new contract I am down to 768Kb. And I pay 3 times more expensive for that.
No other provider can provide me with this bandwidth at the current price.

That is why I really need.

What grieves me most is that Windows can do it easily. And that under SME seems to be impossible.

Olivier Beeckmans
Title: Re: Help ! Clone Mac Address on WAN Interface
Post by: CharlieBrady on April 05, 2009, 06:10:21 AM
What grieves me most is that Windows can do it easily. And that under SME seems to be impossible.

It's possible, but you'll need to work out how to do it. Perhaps adding something like:

send dhcp-client-identifier 1:0:a0:24:ab:fb:9c;

to /var/lib/dhcp/dhclient-eth1.conf will do it.
Title: Re: Help ! Clone Mac Address on WAN Interface
Post by: beckynet on April 05, 2009, 10:45:41 AM
Hello Charlie Brady,

I've try with : (For the Test I use a SME Server as DHCP server, and he must give IP 10.0.0.31 to Mac Address 00:16:17:b2:bd:58)

send dhcp-client-identifier "mbsrv001"; Original

lease 10.0.0.180 {
  starts 0 2009/04/05 08:08:23;
  ends 1 2009/04/06 08:08:23;
  binding state active;
  next binding state free;
  hardware ethernet 00:c0:df:10:60:54;
  uid "mbsrv001";
  client-hostname "mbsrv001";


send dhcp-client-identifier 00:16:17:b2:bd:58; Mac Address I want to send to request a DHCP lease

lease 10.0.0.193 {
  starts 0 2009/04/05 07:41:14;
  ends 1 2009/04/06 07:41:14;
  binding state active;
  next binding state free;
  hardware ethernet 00:c0:df:10:60:54;
  uid "\000\026\027\262\275X";
  client-hostname "mbsrv001";


send dhcp-client-identifier "00:16:17:b2:bd:58"; Mac Address I want to send to request a DHCP lease

lease 10.0.0.174 {
  starts 0 2009/04/05 07:34:18;
  ends 1 2009/04/06 07:34:18;
  tstp 1 2009/04/06 07:34:18;
  binding state active;
  next binding state free;
  hardware ethernet 00:c0:df:10:60:54;
  uid "00:16:17:b2:bd:58";
  client-hostname "mbsrv001";

This way is not concluant...

Thanks for your respons

Olivier Beeckmans
Title: Re: Help ! Clone Mac Address on WAN Interface
Post by: CharlieBrady on April 06, 2009, 08:53:42 PM
This way is not concluant...

I'm sorry, but "concluant" is not a word in English, and I do not know what you are trying to tell us. I'm also not sure what MAC address you want to "clone" to your WAN interface. Is it the MAC of a NIC? If so, can you not just use that NIC in your SME server?
Title: Re: Help ! Clone Mac Address on WAN Interface
Post by: beckynet on April 06, 2009, 10:42:11 PM
this solution is not functional, sorry I speak usually french...

It's the mac Address that I want to clone. This Mac address is from a HOME cable/router, and I can't use his Nic.

Or I have to desolder and solder it on a PCI board  and write some drivers :???:

Thanks a Lot

Olivier Beeckmans

Title: Re: Help ! Clone Mac Address on WAN Interface
Post by: CharlieBrady on April 06, 2009, 11:03:11 PM
It's the mac Address that I want to clone. This Mac address is from a HOME cable/router, and I can't use his Nic.

OK. And do you know whether you need to use the MAC address for Layer 2 ethernet addressing, or just as the client identifier for DHCP, or do you need to do both?

I also do not understand the narrative of your testing, which you say "is not functional". You have shown some DHCP leases but I do not know what you hoped or expected to see, or how what you did see is different from your expectations.
Title: Re: Help ! Clone Mac Address on WAN Interface
Post by: CharlieBrady on April 06, 2009, 11:08:58 PM
if I do (with or without the custom template)

Code: [Select]
#ifdown eth1
#ifup eth1

after that the network is unreachable  :???:

You should not use ifdown and ifup with eth1. In SME server, the eth1 interface is controlled by /service/wan/run (which will chain to /var/service/wan/run.dhclient when the dhcp client is enabled).

You will need to use a custom template to modify /var/service/wan/dhclient.config if you wish to use a different MAC with eth1, and modify /var/lib/dhcp/dhclient-eth1.conf if you wish to use a different client identifier.
Title: Re: Help ! Clone Mac Address on WAN Interface
Post by: beckynet on April 07, 2009, 05:13:15 PM
Quote
I also do not understand the narrative of your testing, which you say "is not functional". You have shown some DHCP leases but I do not know what you hoped or expected to see, or how what you did see is different from your expectations.

In fact it is the answer to the solution you have proposed.

It's possible, but you'll need to work out how to do it. Perhaps adding something like:

send dhcp-client-identifier 1:0:a0:24:ab:fb:9c;

to /var/lib/dhcp/dhclient-eth1.conf will do it.

00:16:17:b2:bd:58  is the Mac Address that the DHCP server should be show to give the proper lease

if I write send dhcp-client-identifier 00:16:17:b2:bd:58; in  /var/lib/dhcp/dhclient-eth1.conf (SME2)

SME1 as DHCP-Server (beckysrv001) <---> SME2 as DHCP-Client (mbsrv001)

Code: [Select]
beckysrv001 /var/lib/dhcp/dhcpd.leases (SME1)
lease 10.0.0.193 {
  starts 0 2009/04/05 07:41:14;
  ends 1 2009/04/06 07:41:14;
  binding state active;
  next binding state free;
  hardware ethernet 00:c0:df:10:60:54;
  uid "\000\026\027\262\275X";
  client-hostname "mbsrv001";

if I write send dhcp-client-identifier "00:16:17:b2:bd:58"; in  /var/lib/dhcp/dhclient-eth1.conf (SME2)

Code: [Select]
beckysrv001 /var/lib/dhcp/dhcpd.leases (SME1)
lease 10.0.0.174 {
  starts 0 2009/04/05 07:34:18;
  ends 1 2009/04/06 07:34:18;
  tstp 1 2009/04/06 07:34:18;
  binding state active;
  next binding state free;
  hardware ethernet 00:c0:df:10:60:54;
  uid "00:16:17:b2:bd:58";
  client-hostname "mbsrv001";

You can see that the real physical HwAddress (00:c0:df:10:60:54) is used and not wich I want to clone 00:16:17:b2:bd:58.

why I say the solution is not functional

In fact I want my network card appears as 00:16:17:b2:bd:58 and not as 00:c0:df:10:60:54 his real HwAddr.

This is what we call the Mac Address Cloning. Many Windows Network Drivers or Home Router can do that.

Olivier Beeckmans


Title: Re: Help ! Clone Mac Address on WAN Interface
Post by: Stefano on April 07, 2009, 05:24:32 PM
beckynet:

as Chalie said:
Quote
You will need to use a custom template to modify /var/service/wan/dhclient.config if you wish to use a different MAC with eth1, and modify /var/lib/dhcp/dhclient-eth1.conf if you wish to use a different client identifier.
you have to modify other templates..

Ciao
Stefano
Title: Re: Help ! Clone Mac Address on WAN Interface
Post by: beckynet on April 08, 2009, 10:45:53 PM
I've try to edit directly the file /var/service/wan/dhclient.config

as this :

Code: [Select]
/sbin/modprobe eth0
/sbin/modprobe eth1
/sbin/ifconfig eth1 up mtu 1500 hw ether 00:16:17:b2:bd:58

interface=eth1

I've reboot the server and nothing was changed

eth1      Link encap:Ethernet  HWaddr 00:04:75:BF:6C:EB
          inet addr:10.0.0.31  Bcast:10.0.0.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1662 errors:0 dropped:0 overruns:1 frame:0
          TX packets:1093 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:351095 (342.8 KiB)  TX bytes:861371 (841.1 KiB)
          Interrupt:185 Base address:0xe880

The real physical address is used no cloning or spoofing

Olivier Beeckmans
Title: Re: Help ! Clone Mac Address on WAN Interface
Post by: CharlieBrady on April 09, 2009, 12:06:32 AM
Try:

/sbin/ip link set dev eth1 address 00:16:17:b2:bd:58
Title: Re: Help ! Clone Mac Address on WAN Interface
Post by: beckynet on April 09, 2009, 05:29:06 PM
Hello CharlieBrady,

I've try

Code: [Select]
/sbin/ip link set dev eth1 address 00:16:17:b2:bd:58
signal-event reboot

No change Physical address is used

Thanks for your respons

Olivier Beeckmans
Title: Re: Help ! Clone Mac Address on WAN Interface
Post by: CharlieBrady on April 09, 2009, 06:37:30 PM
No change

Well, that's hardly surprising - you changed the MAC on eth1 and then rebooted - losing your change. Put the "ip link ..." command in /var/service/wan/dhclient.config (via a custom template).
Title: Re: Help ! Clone Mac Address on WAN Interface
Post by: william_syd on April 10, 2009, 06:18:50 AM
I've try to edit directly the file /var/service/wan/dhclient.config

--SNIP--

The real physical address is used no cloning or spoofing

Olivier Beeckmans

Try this...

Code: [Select]
cd /etc/e-smith/templates/var/service/wan/dhclient.config/
Code: [Select]
mkdir -p /etc/e-smith/templates-custom/var/service/wan/dhclient.config
Code: [Select]
cp device /etc/e-smith/templates-custom/var/service/wan/dhclient.config/device
Code: [Select]
cd /etc/e-smith/templates-custom/var/service/wan/dhclient.config
Code: [Select]
vi device
Edit the file as such. Your MTU may remain at 1500.
Save the file.

Code: [Select]
{
    my $device = $ExternalInterface{Name} || "eth1";
    $OUT .= "/sbin/modprobe eth0\n";
    $OUT .= "/sbin/modprobe eth1\n" if $device eq "eth1";
    if ($device eq "eth0.4094")
    {
        $OUT .=
            "/sbin/modprobe 8021q\n" .
            "/sbin/vconfig add eth0 4094\n";
    }
    $OUT .= "/sbin/ifconfig $device down\n";
    $OUT .= "/sbin/ifconfig $device mtu 576 hw ether 00:16:17:b2:bd:58\n";
    $OUT .= "/sbin/ifconfig $device up\n\n";
    $OUT .= "interface=$device\n";
}

Code: [Select]
expand-template /var/service/wan/dhclient.config
Code: [Select]
signal-event reboot
Confirm with ifconfig eth1 and route -n

If you have no IP or default gateway,

dhclient eth1 and kill the PID of the already running client.

Recheck, Reboot, Recheck.

What I now see....

[root@sme7vm dhclient.config]# ifconfig eth0
eth0      Link encap:Ethernet  HWaddr 00:16:17:B2:BD:58 
          inet addr:211.123.123.123  Bcast:211.123.123.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:576  Metric:1
          RX packets:2706 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2406 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:857179 (837.0 KiB)  TX bytes:402247 (392.8 KiB)
          Interrupt:177 Base address:0x2000


Yes, my eth0 and eth1 are swapped.