Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Hardware
User Name
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?


  Search this Thread
Old 12-12-2006, 12:46 PM   #1
LQ Newbie
Registered: Dec 2006
Posts: 4

Rep: Reputation: 0
Hw to change mac address permanently?

Changing MAC address for current session is possible through 'ipconfig eth0 hw ether NEW_MAC'.But this does nt exixt after reboot.
Is there any way of changing MAC address permanently in RHEL4?

Thnking in advance,
Old 12-12-2006, 01:38 PM   #2
LQ 5k Club
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,398
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
The MAC address is usually a permanent part of the ethernet hardware. Most often, it is simply in a small ROM which the driver reads, and subsequently writes to one or more appropriate registers on the ethernet chip(set). Because of this idiom, it is possible to write any valid MAC address to the ethernet hardware registers, as you have noted. However, unless the driver permits specifiying it, the address embedded in the hardware will be used when the driver starts up.

You may be able to solve your problem by not starting the ethernet interface at boot time, and then using the method you have already described to start it with the conditions you require.

For your distribution, try adding to /etc/sysconfig/network-scripts/ifcfg-eth0
Of course, use the MAC that you want, and change eth0 to whatever is appropriate, if necessary.

--- rod.

Last edited by theNbomr; 12-12-2006 at 01:44 PM.
Old 05-24-2007, 01:23 AM   #3
LQ Newbie
Registered: Jan 2007
Posts: 11

Rep: Reputation: 0

So, I have the same problem like in the #1 post. My internet provider binds me an ip by the mac address. I have bought a laptop, so it has different mac addresses than my old pc, so no internet unless, i change mac addresses. When i had xp, i had no problems changing macadr. It worked perfectly. Now i have these problems, because when i change mac addr through "ifconfig eth0 hw ether xx:Xx:xx:xx:xx" I get new mac, but my ip bind only then when i restart my pc. And then i restart my pc, i get old mac. I tried what you said, but it didint work for me, so thats probably of distribution. I have a slackware, and my configuration files are differently located. I even created those folders "network-scripts" but nothing new. Do you have any idea how to change my mac on slackware? I mean, that it would stay, after restarting my computer..

Thanks in advance
Old 05-24-2007, 07:44 AM   #4
Wim Sturkenboom
Senior Member
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
I haven't analyzed that part, but I think that a good starting point is /etc/rc.d/rc.inet1 Make a backup and modify it.

# Function to bring up an Ethernet interface.  If the interface is
# already up or does not yet exist (perhaps because the kernel driver
# is not loaded yet), do nothing.
eth_up() {
  # If the interface isn't in the kernel yet (but there's an alias for it in
  # modules.conf), then it should be loaded first:
  if ! grep eth${1}: /proc/net/dev 1> /dev/null ; then # no interface yet
    if /sbin/modprobe -c | grep -w "alias eth${1}" | grep -vw "alias eth${1} off" > /dev/null ; then
      echo "/etc/rc.d/rc.inet1:  /sbin/modprobe eth${1}" | $LOGGER
      /sbin/modprobe eth${1}
  if grep eth${1}: /proc/net/dev 1> /dev/null ; then # interface exists
    if ! /sbin/ifconfig | grep -w "eth${1}" 1>/dev/null || \
      ! /sbin/ifconfig eth${1} | grep "inet addr" 1> /dev/null ; then # interface not up or not configured
      if [ -x /etc/rc.d/rc.wireless ]; then
        . /etc/rc.d/rc.wireless eth${1} # Initialize any wireless parameters
# I would add something here for DHCP
      if [ "${USE_DHCP[$1]}" = "yes" ]; then # use DHCP to bring interface up
        if [ ! "${DHCP_HOSTNAME[$1]}" = "" ]; then
          echo "/etc/rc.d/rc.inet1:  /sbin/dhcpcd -d -t 10 -h ${DHCP_HOSTNAME[$1]} eth${1}" | $LOGGER
          /sbin/dhcpcd -d -t 10 -h ${DHCP_HOSTNAME[$1]} eth${1}
          echo "/etc/rc.d/rc.inet1:  /sbin/dhcpcd -d -t 10 eth${1}" | $LOGGER
          /sbin/dhcpcd -d -t 10 eth${1}
      else # bring up interface using a static IP address
        if [ ! "${IPADDR[$1]}" = "" ]; then # skip unconfigured interfaces
          # Determine broadcast address from the IP address and netmask:
          BROADCAST=`/bin/ipmask ${NETMASK[$1]} ${IPADDR[$1]} | cut -f 1 -d ' '`
          # Set up the ethernet card:
          echo "/etc/rc.d/rc.inet1:  /sbin/ifconfig eth${1} ${IPADDR[$1]} broadcast ${BROADCAST} netmask ${NETMASK[$1]}" | $LOGGER
# I would add something here for static IP
          /sbin/ifconfig eth${1} ${IPADDR[$1]} broadcast ${BROADCAST} netmask ${NETMASK[$1]}
          if [ "$DEBUG_ETH_UP" = "yes" ]; then
            echo "/etc/rc.d/rc.inet1:  eth${1} interface is not configured in /etc/rc.d/rc.inet1.conf" | $LOGGER
      if [ "$DEBUG_ETH_UP" = "yes" ]; then
        echo "/etc/rc.d/rc.inet1:  eth${1} is already up, skipping" | $LOGGER
    if [ "$DEBUG_ETH_UP" = "yes" ]; then
      echo "/etc/rc.d/rc.inet1:  eth${1} interface does not exist (yet)" | $LOGGER
I might, however, be completely wrong

PS The above comes from my Slack 10.1 box


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to change MAC address cain_eve Linux - Software 11 02-05-2009 01:52 PM
to change outgoing mac and ip address korenje Linux - Networking 3 12-31-2005 12:41 AM
change mac address possible? kahn Linux - Networking 4 04-22-2005 04:43 AM
Change MAC address (hwaddr) permanently clandestine Ubuntu 1 04-18-2005 01:17 PM
MAC address change? w9q Linux - Networking 3 09-10-2004 02:42 AM > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 07:13 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration