Topic review - Linux How to change hardware MAC address of an interface
Author
Message
Zettie49
Post subject: Re: Linux How to change hardware MAC address of an interface | Posted: Tue Dec 06, 2011 6:26 am
I am wondering how to change the MAC address of my ethernet adaptor(eth0) under Linux. Since the LAN's IP address need register in my college, and I want to use my laptop in Lab. I think the way to do it is to change my MAC to the Lab computer's.
Waiting for your help
I am wondering how to change the MAC address of my ethernet adaptor(eth0) under Linux. Since the LAN's IP address need register in my college, and I want to use my laptop in Lab. I think the way to do it is to change my MAC to the Lab computer's.
Waiting for your help
debuser
Post subject: Linux How to change hardware MAC address of an interface | Posted: Sat Dec 03, 2011 9:18 pm
The mac address is also referred to as physical address and it is used in Ethernet network via ARP and DHCP to map a layer 3 IPv4 address.
Change interface mac address in Linux
To change the mac address of an interface in Linux, the interface needs to be brought down first, otherwise a "device or resource busy" error will occur. This can be done if logged in via ssh to an interface not serving the ssh traffic (otherwise reachability will be lost) or if connected through a console port.
Code:
root@server:~# ip a l eth0 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 00:16:3e:3a:0a:1a brd ff:ff:ff:ff:ff:ff inet6 fe80::216:3eff:fe3a:a1a/64 scope link valid_lft forever preferred_lft forever
root@server:~# ifconfig eth0 hw ether '00:16:3e:3a:0a:1b' SIOCSIFHWADDR: Device or resource busy - you may need to down the interface root@server:~# ifconfig eth0 down root@server:~# ifconfig eth0 hw ether '00:16:3e:3a:0a:1b' root@server:~# ifconfig eth0 up root@server:~# ip a l eth0 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 00:16:3e:3a:0a:1b brd ff:ff:ff:ff:ff:ff inet6 fe80::216:3eff:fe3a:a1b/64 scope link valid_lft forever preferred_lft forever
The mac address is also referred to as physical address and it is used in Ethernet network via ARP and DHCP to map a layer 3 IPv4 address.
[h2]Change interface mac address in Linux[/h2] To change the mac address of an interface in Linux, the interface needs to be brought down first, otherwise a "device or resource busy" error will occur. This can be done if logged in via ssh to an interface not serving the ssh traffic (otherwise reachability will be lost) or if connected through a console port.
[code] root@server:~# ip a l eth0 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 00:16:3e:3a:0a:1a brd ff:ff:ff:ff:ff:ff inet6 fe80::216:3eff:fe3a:a1a/64 scope link valid_lft forever preferred_lft forever
root@server:~# ifconfig eth0 hw ether '00:16:3e:3a:0a:1b' SIOCSIFHWADDR: Device or resource busy - you may need to down the interface root@server:~# ifconfig eth0 down root@server:~# ifconfig eth0 hw ether '00:16:3e:3a:0a:1b' root@server:~# ifconfig eth0 up root@server:~# ip a l eth0 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 00:16:3e:3a:0a:1b brd ff:ff:ff:ff:ff:ff inet6 fe80::216:3eff:fe3a:a1b/64 scope link valid_lft forever preferred_lft forever [/code]