Monday, 16 September 2013

change mac address for ubuntu and gentoo

first one has to check the situation of network:
# ifconfig
this gives:
mybox Desktop # ifconfig
enp6s0: flags=4163  mtu 1500
        inet 10.33.21.70  netmask 255.255.252.0  broadcast 10.33.23.255
        inet6 fe80::222:19ff:fe2e:603f  prefixlen 64  scopeid 0x20
        ether 00:22:19:2e:60:3f  txqueuelen 1000  (Ethernet)
        RX packets 13223  bytes 6462275 (6.1 MiB)
        RX errors 0  dropped 18  overruns 0  frame 0
        TX packets 6147  bytes 1062544 (1.0 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 1  collisions 0

lo: flags=73  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10
        loop  txqueuelen 0  (Local Loopback)
        RX packets 600  bytes 48840 (47.6 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 600  bytes 48840 (47.6 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlp2s0: flags=4099  mtu 1500
        inet6 fe80::e2ca:94ff:fedb:57ac  prefixlen 64  scopeid 0x20
        ether e0:ca:94:db:57:ac  txqueuelen 1000  (Ethernet)
        RX packets 457  bytes 532967 (520.4 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 257  bytes 42551 (41.5 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
note that here enp6s0 is wired card and wlp2s0 is wireless, which is different from eth0 and wlan0 in some distributions (e.g., slackware ubuntu debian lubuntu, scientific linux) also note that the name of the mac is called ether rather than HWaddr
therefore, one can do:
ifconfig enp6s0 down
ifconfig enp6s0 hw ether  00:22:19:2E:60:3F
ifconfig enp6s0 up

now you have the new mac address working on your enternet. for other distributions, one may need to change enp6s0 into eth0, and ether into HWaddr. enjoy!

2 comments:

  1. With the above method it is fun changing the mac address of your network adapter.

    Thanks
    Silvester Norman

    Changing MAC Address

    ReplyDelete
    Replies
    1. hah, Thanks for the reply. Actually it is a temporary way to gain internet access for some encrypted LAN. Some of the router only provide ip for registered MAC, if you want to allow some unregistered device to aquire IP temporarily, you can change the mac. but be careful it is not good to connect the LAN with two device having the same MAC!

      Delete