Koozali.org: home of the SME Server

Change mac address permanent

Offline cattledog

  • ***
  • 70
  • +0/-0
Change mac address permanent
« on: June 19, 2016, 10:26:20 AM »
Hi all want to change my wan mac address to a new one so my isp allows my connection but would like this to be permanent not revert back after reboot.

Cheers

yes I have searched but they are older versions of sme and not sure if this would apply to sme9x

Offline Jean-Philippe Pialasse

  • *
  • 2,912
  • +11/-0
  • aka Unnilennium
    • http://smeserver.pialasse.com
Re: Change mac address permanent
« Reply #1 on: June 19, 2016, 05:41:31 PM »
and what are the result of your search ?

Offline cattledog

  • ***
  • 70
  • +0/-0
Re: Change mac address permanent
« Reply #2 on: June 20, 2016, 09:03:39 AM »
and what are the result of your search ?

Nothing relevant for sme9...

Offline Jean-Philippe Pialasse

  • *
  • 2,912
  • +11/-0
  • aka Unnilennium
    • http://smeserver.pialasse.com
Re: Change mac address permanent
« Reply #3 on: June 20, 2016, 09:19:11 AM »
Nothing relevant for sme9...

if it is related to any linux distro based on rpm ( or even any linux) , it might just need some adaptations we might be able to suggest.

Offline Stefano

  • *
  • 10,894
  • +3/-0
Re: Change mac address permanent
« Reply #4 on: June 20, 2016, 09:27:44 AM »
cattledog: please give us the links to the topics you foud.. even if not SME9 related, they can be a good start point


Offline Stefano

  • *
  • 10,894
  • +3/-0
Re: Change mac address permanent
« Reply #6 on: June 20, 2016, 09:42:13 AM »
Quote
yes I have searched but they are older versions of sme and not sure if this would apply to sme9x

please give us the results, thank you (I mean results from contribs.org first)

Offline Jean-Philippe Pialasse

  • *
  • 2,912
  • +11/-0
  • aka Unnilennium
    • http://smeserver.pialasse.com
Re: Change mac address permanent
« Reply #7 on: June 20, 2016, 09:48:54 AM »
https://en.wikibooks.org/wiki/Changing_Your_MAC_Address/Linux

well this is totally adapted to SME !

for a temp change ( assuming your external network is eth0)
Quote
Code: [Select]
    /etc/init.d/networking stop
    ifconfig eth0 hw ether 02:01:02:03:04:08
    /etc/init.d/networking start

Execute "ifconfig eth0" to confirm.

then to get it permanent to reboot :
Quote
In Red Hat Enterprise Linux (RHEL) and other similar systems (Fedora, CentOS, etc.) an easy way to make changes "permanent" across reboots is to add an appropriate entry to the /etc/sysconfig/network-scripts/ifcfg-ethN file (ifcfg-eth0 for the first Ethernet interface config file, ifcfg-eth1 - for the second, etc.):

    MACADDR=12:34:56:78:90:ab



then for SME for making it permanent to reconfiguration, you will have to make it in a template



Code: [Select]
mkdir -p /etc/e-smith/templates-custom/etc/sysconfig/network-scripts/ifcfg-ethX/
vim /etc/e-smith/templates-custom/etc/sysconfig/network-scripts/ifcfg-ethX/10HWADDR

and add something like this
Code: [Select]
{
    $OUT = "";
    return if ($InternalInterface{Name} eq "bond0");
    return unless $THIS_DEVICE =~ /^eth[01]$/;
my
    my $MACaddr = $is_internal ?
        '':         $ExternalInterface{MACaddr};
return if $MACaddr  eq '';
    $OUT .= "MACADDR=$MACaddr " ;
}


then  do

Code: [Select]
config setprop ExternalInterface MACaddr 12:34:56:78:90:ab

test the template with

Code: [Select]
expand-template /etc/sysconfig/network-scripts/ifcfg-eth0
again assuming your actual external network is eth0 ( adapt to eth1 or anything else if it is different)

Warning NOT TESTED, there might be some typos
« Last Edit: June 20, 2016, 09:57:25 AM by Jean-Philippe Pialasse »

Offline cattledog

  • ***
  • 70
  • +0/-0
Re: Change mac address permanent
« Reply #8 on: June 20, 2016, 09:59:54 AM »
Yes...thank you.

I was thinking that it was going to help.

By the way I sent an email and it was intended for you Jean-Philippe Pialasse about the way you did this:

Does anybody has already to configure such connection directly in SME with the modem bridged ?? ( no login, no password, fixed IP, unknown gateway IP)

How did you handle it ?

It was something you did back in 2013...I was after instruction that you followed.

https://forums.contribs.org/index.php/topic,49927.msg250224.html#msg250224

cheers

Offline Stefano

  • *
  • 10,894
  • +3/-0
Re: Change mac address permanent
« Reply #9 on: June 20, 2016, 10:02:25 AM »
AFAICS in templates/etc/sysconfig/network-scripts/ifcfg-ethX/10HWADDR fragment, a

Code: [Select]
config setprop ExternalInterface HWAddress 12:34:56:78:90:ab

followed by proper action/event should be enough (and it is so at least since SME8)


NOTE: edited the key name
« Last Edit: June 20, 2016, 10:06:58 AM by Stefano »

Offline Stefano

  • *
  • 10,894
  • +3/-0
Re: Change mac address permanent
« Reply #10 on: June 20, 2016, 10:07:51 AM »
Yes...thank you.

I was thinking that it was going to help.

By the way I sent an email and it was intended for you Jean-Philippe Pialasse about the way you did this:

Does anybody has already to configure such connection directly in SME with the modem bridged ?? ( no login, no password, fixed IP, unknown gateway IP)

How did you handle it ?

It was something you did back in 2013...I was after instruction that you followed.

https://forums.contribs.org/index.php/topic,49927.msg250224.html#msg250224

cheers


this is OT in this topic and you already posted the same question elsewhere..

Offline Jean-Philippe Pialasse

  • *
  • 2,912
  • +11/-0
  • aka Unnilennium
    • http://smeserver.pialasse.com
Re: Change mac address permanent
« Reply #11 on: June 20, 2016, 10:13:59 AM »
AFAICS in templates/etc/sysconfig/network-scripts/ifcfg-ethX/10HWADDR fragment, a

Code: [Select]
config setprop ExternalInterface HWAddress 12:34:56:78:90:ab

followed by proper action/event should be enough (and it is so at least since SME8)


NOTE: edited the key name
WRONG !!!!!!

HWAddress  is a totally different purpose : choosing the right network card based on their original MAC Address
MACADDR is to fake the MAC Adress !!!!

Offline Stefano

  • *
  • 10,894
  • +3/-0
Re: Change mac address permanent
« Reply #12 on: June 20, 2016, 10:20:38 AM »
ops.. I misunderstood.. I apologize

Offline Jean-Philippe Pialasse

  • *
  • 2,912
  • +11/-0
  • aka Unnilennium
    • http://smeserver.pialasse.com
Re: Change mac address permanent
« Reply #13 on: June 20, 2016, 10:23:41 AM »
ops.. I misunderstood.. I apologize

no problem, It took me also a time to see the difference ;)
plus if you see the syntax of debian it does not help :D to see the difference