Koozali.org: home of the SME Server

How to set Macaddress to eth1

Offline bbialy

  • ****
  • 105
  • +0/-0
How to set Macaddress to eth1
« on: July 09, 2008, 07:04:46 PM »
Hello,
i've got problem howto change mac address.
i tried to write custom template
/etc/e-smith/templates-custom/etc/sysconfig/network-scripts/ifcfg-ethX/90otherparams



2 questions
how to expand this template?   :?
      becouse it the name there is ifcfg-ethX

Why it doesnt'work??  :?
      i tried post-upgrade, reconfigure in admin panel and many many more.

My configuration is:
eth1 static IP
eth0 192.168.10.x/24 no DHCP to network eth0


Code: [Select]
{
    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" .
        "IPADDR=$ExternalIP\n" .
        "NETMASK=$ExternalNetmask\n" .
        "NETWORK=$network\n" .
        "BROADCAST=$broadcast"\n;
        "MACADDR=01:01:01:A0:A0:A0";
    }
    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";
}


regards
Maciej

     
Reading with understanding is the hardest thing IN THE WORLD

Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
Re: How to set Macaddress to eth1
« Reply #1 on: July 09, 2008, 08:33:59 PM »
Hello,
i've got problem howto change mac address.

Why do you want to change the MAC address (on a NIC with static configuration)?

Quote

i tried to write custom template
/etc/e-smith/templates-custom/etc/sysconfig/network-scripts/ifcfg-ethX/90otherparams



2 questions
how to expand this template?   :?
      becouse it the name there is ifcfg-ethX

expand-template /etc/sysconfig/network-scripts/ifcfg-eth1

Confirm that you have what you want by doing:

cat /etc/sysconfig/network-scripts/ifcfg-eth1

Offline bbialy

  • ****
  • 105
  • +0/-0
Re: How to set Macaddress to eth1
« Reply #2 on: July 09, 2008, 09:06:28 PM »
Ad 1. becouse mu ISP wants to have sepcyfic MAC and i had to change my NIC.

I found two mistakes in code and trhat was the reason why it doesn't work

it was
        "BROADCAST=$broadcast"\n;
        "MACADDR=01:01:01:A0:A0:A0";

it should be
        "BROADCAST=$broadcast\n" .
        "MACADDR=01:01:01:A0:A0:A0";

founded


Thank you very much
you were very helpful and i should start lerning in subject reading with understanding  :grin:


that was error messages

Code: [Select]

WARNING in /etc/e-smith/templates-custom//etc/sysconfig/network-scripts/ifcfg-ethX/90otherparams: Useless use of a constant in void context at /etc/e-smith/templates-custom//etc/sysconfig/network-scripts/ifcfg-ethX/90otherparams line 24.
WARNING: Template processing succeeded for //etc/sysconfig/network-scripts/ifcfg-eth1: 1 fragment generated warnings
 at /sbin/e-smith/expand-template line 45
[root@xxxx ifcfg-ethX]#
[root@xxxx ifcfg-ethX]# expand-template /etc/sysconfig/network-scripts/ifcfg-eth1
ERROR in /etc/e-smith/templates-custom//etc/sysconfig/network-scripts/ifcfg-ethX/90otherparams: Program fragment delivered error <<syntax error at /etc/e-smith/templates-custom//etc/sysconfig/network-scripts/ifcfg-ethX/90otherparams line 23, near "; .">> at template line 1
ERROR: Template processing failed for //etc/sysconfig/network-scripts/ifcfg-eth1: 1 fragment generated errors
 at /sbin/e-smith/expand-template line 45
[root@xxxx ifcfg-ethX]# expand-template /etc/sysconfig/network-scripts/ifcfg-eth1
[root@xxxx ifcfg-ethX]# cat /etc/sysconfig/network-scripts/ifcfg-eth1

Reading with understanding is the hardest thing IN THE WORLD