How to change the MAC address?

Asked by Aman on 2008-05-06

Can anyone please tell me how can i change my MAC address of my ethernet card?

I used macchanger in the terminal to change the MAC address as well as the GTL interface of the macchanger and it changed my mac in both cases but problem is that when i changed my MAC the internet stopped working. And it cannot ping even its gateway after changing my MAC.

Is there any other software package available for that?
or any solution for that.

Urgently needed!!

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Solved by:
Selene ToyKeeper
Solved:
2008-07-18
Last query:
2008-07-18
Last reply:
2008-05-13
Tim Bosse (timbosse) said : #1

Before you can bring up an IP interface, you need to specify your MAC address. If you change your MAC address while you have an IP interface up and a route specified, you will run into networking issues.

My guess, without knowing any more information, is that you should try changing your IP address, then restart networking services. Depending on your setup, you can do so from network-manager or from /etc/init.d/networking.

If you are still having problems, or if you need assistance with any of the above, please provide more information. A good guide on what we may be looking for can be found here: https://help.ubuntu.com/community/InternetHowto

Tim Bosse (timbosse) said : #2

Before you can bring up an IP interface, you need to specify your MAC address. If you change your MAC address while you have an IP interface up and a route specified, you will run into networking issues.

My guess, without knowing any more information, is that you should try changing your MAC address, then restart networking services. Depending on your setup, you can do so from network-manager or from /etc/init.d/networking.

If you are still having problems, or if you need assistance with any of the above, please provide more information. A good guide on what we may be looking for can be found here: https://help.ubuntu.com/community/InternetHowto

Aman (indian-munnda) said : #3

yes Tim, i did the same as you said.
I first changed the MAC address and then restarted my networking servics using the command "sudo /etc/init.d/networking restart".

But it stopped the internet completely and i can't ping even my gateway after that.

Selene ToyKeeper (toykeeper) said : #4

This may be a long shot, but it's possible that your modem has a MAC filter. I've run into this occasionally, where a technician from the ISP configures the modem at install time to talk to only one or two computers.

The manual way to change your MAC is with "ifconfig eth0 hw ether 00:11:22:33:44:55".

You can try some experiments by running "ifdown eth0" and then changing the macaddr... then run "dhclient eth0" to see if you can get an address. Then, killall dhclient, change the macaddr, and try dhclient again. If you can get an address with one MAC and not the other, it's probably a filter on the modem or router. BTW, you'll need sudo for all those commands.

Let us know if this reveals anything, and if you need further assistance.

Aman (indian-munnda) said : #5

Scott i did whatever you said above, but it didn't worked.

I am having a static IP address.
And in windows when i changed my MAC its working fine but in ubuntu my internet get stopped after changing MAC.
And when i asked it in #ubuntu channel one of them said that may be my ubuntu is using old arp caches and i don't know what is that.

So please tell me any solution if possible.

Selene ToyKeeper (toykeeper) said : #6

Okay this makes sense. MAC changing doesn't work very well with static IPs, because of the arp cache.

What that means is ... if you understand how DNS converts a name to an IP address (look up ubuntu.com with "host ubuntu.com", and the result is 91.189.94.158), there's something similar going on at a lower level. To actually send data on a local network, the system looks up that IP address in order to get a MAC address. But this is a little slow, so it caches the answers. To do the lookup, it broadcasts a message saying "who has 192.168.1.13?" and waits until someone answers. Then all the machines on the network cache the result for a while.

You can see your machine's current arp cache by running "arp -n". If it's not in your path, try "/usr/sbin/arp -n".

Your router has its own arp cache, as does every other machine on the local network. As soon as you change your MAC, the other machines end up with stale arp cache entries, and those entries need to be cleared.

Usually, changing MAC address without changing IP is only done when one "high availability" machine fails over to another. The "heartbeat" package provides some utilities for doing this, but it's not very straightforward how to do it manually. After installing heartbeat, the command to force an arp reset is something like...

  sudo /usr/lib/heartbeat/send_arp eth0 192.168.1.13 auto 192.168.1.255 255.255.255.0

This reads as "tell everyone on the 192.168.1.0/24 network that 192.168.1.13 belongs to me".

There is probably an easier way to do this, but I've only used this approach. Changing the MAC isn't something most people do, so perhaps only low-level tools are available for it.

BTW, why do you need to change your MAC? Does send_arp help after you've made a MAC change?

Aman (indian-munnda) said : #7

Scott,
I tried what u said but it dint work. It gave me some error. It maybe because I don't have a router and its a direct cable internet connection. So do u have any idea about that?

Selene ToyKeeper (toykeeper) said : #8

I need more information about your network before I can give any useful answers.

When you say "direct cable internet connection", does that mean you have a cable modem? Or is it just an ethernet port (as you mentioned in question 12262)? Could you describe your uplink?

Why do you need to change the MAC address?

In Windows, what is the output of "ipconfig /all" ?

In Linux, what are the output of "ifconfig" and "route -n" (both while it is working, and while it is not)?

Aman (indian-munnda) said : #9

Scott,

Actully with the "Direct Cable Internet Connection", I mean that i am just having a cable coming from outside from the hub located at the pole near my house direct into my computer's lancard. And there is no router in between the hub and my computer.

And i have been given a static IP address with username and password using which i login to my ISP gateway server to start internet. And the connection is working fine in windows and even when i am changing MAC in windows, its working fine.
But when it comes to ubuntu, as i change my MAC address it stops working.

Actually i am having a computer and a laptop(recently bought 1 month ago). So sometimes i need to use internet on laptop and sometimes on my PC. So when i try to use internet on my laptop it doesn't work. Because my static have been binded with the MAC. That' is why i wanna change my MAC address to use internet on both on my PC as well as laptop.

And in question number 12262 i was asking to setup the internet connection, but now i am asking for changing the MAC.

while connection is working, 'ifconfig' is:
aman@aman-desktop:~$ ifconfig
eth0 Link encap:Ethernet HWaddr 00:11:09:11:C4:9B
          inet addr:192.168.1.25 Bcast:192.168.1.255 Mask:255.255.255.0
          UP BROADCAST MULTICAST MTU:1500 Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
          Interrupt:20 Base address:0x8000

eth1 Link encap:Ethernet HWaddr 00:E0:20:AC:18:FA
          inet addr:61.16.226.56 Bcast:61.16.226.127 Mask:255.255.255.128
          inet6 addr: fe80::2e0:20ff:feac:18fa/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
          RX packets:34829 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8786 errors:0 dropped:0 overruns:0 carrier:0
          collisions:513 txqueuelen:1000
          RX bytes:13383461 (12.7 MB) TX bytes:1798930 (1.7 MB)
          Interrupt:21 Memory:ec020000-ec0200ff

lo Link encap:Local Loopback
          inet addr:127.0.0.1 Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING MTU:16436 Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)

aman@aman-desktop:~$

and 'route -n' when connection is working:
aman@aman-desktop:~$ route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
61.16.226.0 0.0.0.0 255.255.255.128 U 0 0 0 eth1
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 1000 0 0 eth0
0.0.0.0 61.16.226.1 0.0.0.0 UG 100 0 0 eth1
aman@aman-desktop:~$

and 'ping' also when connection is working:
aman@aman-desktop:~$ ping 61.16.226.1
PING 61.16.226.1 (61.16.226.1) 56(84) bytes of data.
64 bytes from 61.16.226.1: icmp_seq=1 ttl=64 time=0.812 ms
64 bytes from 61.16.226.1: icmp_seq=2 ttl=64 time=0.803 ms
64 bytes from 61.16.226.1: icmp_seq=3 ttl=64 time=1.30 ms
64 bytes from 61.16.226.1: icmp_seq=4 ttl=64 time=0.777 ms
64 bytes from 61.16.226.1: icmp_seq=5 ttl=64 time=2.92 ms
64 bytes from 61.16.226.1: icmp_seq=6 ttl=64 time=0.775 ms
64 bytes from 61.16.226.1: icmp_seq=7 ttl=64 time=0.779 ms
64 bytes from 61.16.226.1: icmp_seq=8 ttl=64 time=1.91 ms
64 bytes from 61.16.226.1: icmp_seq=9 ttl=64 time=0.859 ms
64 bytes from 61.16.226.1: icmp_seq=10 ttl=64 time=0.748 ms
64 bytes from 61.16.226.1: icmp_seq=11 ttl=64 time=1.29 ms
64 bytes from 61.16.226.1: icmp_seq=12 ttl=64 time=0.755 ms
64 bytes from 61.16.226.1: icmp_seq=13 ttl=64 time=0.752 ms

[1]+ Stopped ping 61.16.226.1
aman@aman-desktop:~$

changing MAC:
aman@aman-desktop:~$ sudo ifdown eth1
[sudo] password for aman:
aman@aman-desktop:~$ sudo ifconfig eth1 hw ether 00:14:78:ca:0e:61
aman@aman-desktop:~$ sudo ifup eth1
aman@aman-desktop:~$

When connection is not working after changing MAC:
'ifconfig' is:
aman@aman-desktop:~$ ifconfig
eth0 Link encap:Ethernet HWaddr 00:11:09:11:C4:9B
          inet addr:192.168.1.25 Bcast:192.168.1.255 Mask:255.255.255.0
          UP BROADCAST MULTICAST MTU:1500 Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
          Interrupt:20 Base address:0x8000

eth1 Link encap:Ethernet HWaddr 00:14:78:CA:0E:61
          inet addr:61.16.226.56 Bcast:61.16.226.127 Mask:255.255.255.128
          inet6 addr: fe80::214:78ff:feca:e61/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
          RX packets:39419 errors:0 dropped:0 overruns:0 frame:0
          TX packets:9236 errors:0 dropped:0 overruns:0 carrier:0
          collisions:532 txqueuelen:1000
          RX bytes:14515022 (13.8 MB) TX bytes:1909501 (1.8 MB)
          Interrupt:21 Memory:ec020000-ec0200ff

lo Link encap:Local Loopback
          inet addr:127.0.0.1 Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING MTU:16436 Metric:1
          RX packets:13 errors:0 dropped:0 overruns:0 frame:0
          TX packets:13 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:1144 (1.1 KB) TX bytes:1144 (1.1 KB)

aman@aman-desktop:~$

and 'route -n' after changing MAC:
aman@aman-desktop:~$ route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
61.16.226.0 0.0.0.0 255.255.255.128 U 0 0 0 eth1
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 1000 0 0 eth0
0.0.0.0 61.16.226.1 0.0.0.0 UG 100 0 0 eth1
aman@aman-desktop:~$

and 'ping' to my gateway after changing MAC:
aman@aman-desktop:~$ ping 61.16.226.1
PING 61.16.226.1 (61.16.226.1) 56(84) bytes of data.
From 61.16.226.56 icmp_seq=1 Destination Host Unreachable
From 61.16.226.56 icmp_seq=2 Destination Host Unreachable
From 61.16.226.56 icmp_seq=3 Destination Host Unreachable
From 61.16.226.56 icmp_seq=4 Destination Host Unreachable
From 61.16.226.56 icmp_seq=5 Destination Host Unreachable
From 61.16.226.56 icmp_seq=6 Destination Host Unreachable

[1]+ Stopped ping 61.16.226.1
aman@aman-desktop:~$

In windows ipconfig /all is:

F:\Documents and Settings\root>ipconfig /all

Windows IP Configuration

        Host Name . . . . . . . . . . . . : winutuxu

        Primary Dns Suffix . . . . . . . :

        Node Type . . . . . . . . . . . . : Unknown

        IP Routing Enabled. . . . . . . . : No

        WINS Proxy Enabled. . . . . . . . : No

Ethernet adapter Local Area Connection 2:

        Connection-specific DNS Suffix . :

        Description . . . . . . . . . . . : Silan SC92031 PCI Fast Ethernet Adapter

        Physical Address. . . . . . . . . : 00-E0-20-AC-18-FA

        Dhcp Enabled. . . . . . . . . . . : No

        IP Address. . . . . . . . . . . . : 61.16.226.56

        Subnet Mask . . . . . . . . . . . : 255.255.255.128

        Default Gateway . . . . . . . . . : 61.16.226.1

        DNS Servers . . . . . . . . . . . : 61.16.226.1

                                            203.196.173.4

                                            203.196.173.5

and ping is:

F:\Documents and Settings\root>ping 61.16.226.1

Pinging 61.16.226.1 with 32 bytes of data:

Reply from 61.16.226.1: bytes=32 time<1ms TTL=64

Reply from 61.16.226.1: bytes=32 time<1ms TTL=64

Reply from 61.16.226.1: bytes=32 time<1ms TTL=64

Reply from 61.16.226.1: bytes=32 time<1ms TTL=64

Ping statistics for 61.16.226.1:

    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),

Approximate round trip times in milli-seconds:

    Minimum = 0ms, Maximum = 0ms, Average = 0ms

F:\Documents and Settings\root>

After changing MAC ipconfig /all is:

F:\Documents and Settings\root>ipconfig /all

Windows IP Configuration

        Host Name . . . . . . . . . . . . : winutuxu

        Primary Dns Suffix . . . . . . . :

        Node Type . . . . . . . . . . . . : Unknown

        IP Routing Enabled. . . . . . . . : No

        WINS Proxy Enabled. . . . . . . . : No

Ethernet adapter Local Area Connection 2:

        Connection-specific DNS Suffix . :

        Description . . . . . . . . . . . : Silan SC92031 PCI Fast Ethernet Adapter

        Physical Address. . . . . . . . . : 00-40-2A-7F-3A-4E

        Dhcp Enabled. . . . . . . . . . . : No

        IP Address. . . . . . . . . . . . : 61.16.226.56

        Subnet Mask . . . . . . . . . . . : 255.255.255.128

        Default Gateway . . . . . . . . . : 61.16.226.1

        DNS Servers . . . . . . . . . . . : 61.16.226.1

                                            203.196.173.4

                                            203.196.173.5

and ping is:

F:\Documents and Settings\root>ping 61.16.226.1

Pinging 61.16.226.1 with 32 bytes of data:

Reply from 61.16.226.1: bytes=32 time<1ms TTL=64

Reply from 61.16.226.1: bytes=32 time<1ms TTL=64

Reply from 61.16.226.1: bytes=32 time<1ms TTL=64

Reply from 61.16.226.1: bytes=32 time<1ms TTL=64

Ping statistics for 61.16.226.1:

    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),

Approximate round trip times in milli-seconds:

    Minimum = 0ms, Maximum = 0ms, Average = 0ms

F:\Documents and Settings\root>

Best Selene ToyKeeper (toykeeper) said : #10

Thanks. That explains a lot about your situation.

In your data above, I see three different MAC addresses in use, and you said 2/3 of them work:

linux (before): 00:E0:20:AC:18:FA (works)
linux (after): 00:14:78:CA:0E:61 (fails)
windows (before): 00-E0-20-AC-18-FA (works)
windows (after): 00-40-2A-7F-3A-4E (works)

What if you change your MAC in linux to 00:40:2A:7F:3A:4E instead of 00:14:78:CA:0E:61 ? Does that make any difference? Perhaps two of the addresses are on your ISP's whitelist, and the other is not.

If using the same MAC as Windows doesn't work, then maybe a special arp packet would fix it...

  sudo ifdown eth1
  sudo ifconfig eth1 hw ether 00:40:2A:7F:3A:4E
  sudo ifup eth1
  sudo /usr/lib/heartbeat/send_arp eth1 61.16.226.56 auto 61.16.226.127 255.255.255.128
  ping 61.16.226.1

If this works, you can make it automatic by editing /etc/network/interfaces. It would look something like...

  auto eth1
  iface eth1 inet static
    address 61.16.226.56
    gateway 61.16.226.1
    broadcast 61.16.226.127
    netmask 255.255.255.128
    hwaddress ether 00:40:2A:7F:3A:4E
    post-up /usr/lib/heartbeat/send_arp eth1 61.16.226.56 auto 61.16.226.127 255.255.255.128

Of course, if it works without the arp command, just leave out the post-up line.

There is another possibility you might want to consider. Could you keep a system connected all the time, and route everything else through it? I see your desktop has two NICs; could you connect your notebook to one of them, and route traffic through the desktop PC?

Or, a simpler solution (but not free)... Many wireless routers have ethernet hubs built in, and can use whatever MAC / IP addresses you like. Something like that, if you can get one, would likely simplify your network. Plug it in, give it your static IP and MAC address, and then use DHCP on all your other machines. This is easy and effective.

Aman (indian-munnda) said : #11

Thanks Scott Scriven, that solved my question.