-: When it comes to networking,
you've probably heard of the term MAC address a lot.
So in this lecture,
I'm gonna cover what do we mean by MAC address,
what it's used for, and how to change it.
(dramatic music)
(loud banging)
MAC address stands for Media Access Control,
it's a permanent, physical, and unique address
assigned to network interfaces
by the device manufacturer.
So whether you have a wireless card,
or a wired, or Ethernet card,
each one of these network cards
come with a specific address that is unique to this card.
So there is no two devices in the world
that would have the same MAC address.
And this address will always be the same
to this specific device,
even if you unplug it from your computer,
connect it to another computer,
then this network device will always have the same address.
So you might already know that the IP address
is used in the internet to identify computers,
and communicate between devices on the internet.
The MAC address is used within the network
to identify devices and transfer data between devices.
So each piece of data or packet
that is sent within the network
contains a source MAC and a destination MAC.
Therefore, this packet would flow
from the source MAC to the destination MAC.
So because this is a physical unique address
to each interface, to each network device,
and because it is used to identify devices,
then changing it will make you anonymous on the network.
Not only that, but the MAC address is often used
by filters to prevent or allow devices
to connect to networks,
and do specific tasks on the network.
So being able to change your MAC address
to another device's MAC address
will allow you to impersonate this device
and allow you to do things
that you might not be able to do.
So you'd be able to bypass filters,
or connect to networks that only specific devices
with specific MAC addresses can connect to,
and you will also be able to hide your identity.
Now changing the MAC address is very, very simple,
so let me show you how to do that.
First of all, I'm going to use the ifconfig command
to list all the network interfaces
available on my Kali machine.
What I mean by network interface is any device
that allow us to connect to a network.
So an example is a Wi-Fi card,
or an Ethernet card, and so on.
So you can see first of all we have eth0,
and this is a virtual interface created by virtual box
when we set Kali to use iNet network.
So you can see the interface name is eth0,
you can see it has an IP address because like I said,
it's connected to a network.
So if we go here, we can see it saying Wired Connected.
So this is the interface that represents the wired network
that Kali is connected to,
which is actually a virtual NAT network.
You can also see the netmask, the broadcast,
and a really important piece of information,
which is the ether.
This is the MAC address of this virtual interface.
Now, you can see similar information
for my other two interfaces, the lo and the lan0.
The only thing is you can see for both of these interfaces,
we do not have an IP address.
And the main reason for that
is because none of these interfaces
is connected to a network.
Now lo is the default interface created by Linux,
and lan0 is my real wireless adapter,
so I can use it to connect to Wi-Fi networks.
But if I go on the network in here,
you'll see Wi-Fi is not connected,
because I actually didn't connect to any network,
and that's why it does not have an IP address.
Now, this doesn't matter because what we want to do
is to just change the MAC address,
which again, is shown here under the ether part,
so similar to what you're seeing here for eth0.
Now, in order to change any of the values
that you see in here,
you have to first disable the interface.
So in this example, we want to change the MAC address,
so that is represented by the ether
and the value is right here.
So in order to disable an interface,
we're gonna do ifconfig followed by the interface name,
which is lan0 in my example, followed by down to disable it.
Now, if I hit Enter, you'll see
the command runs with no errors,
so it means that it got executed properly.
And the next thing that we need to do,
is to change the option that we want to change.
And in this example, we want to change the ether,
which is the MAC address.
So first, we're gonna type ifconfig,
we're gonna type the interface that we want to change,
one of its options, then we're gonna type
the option that we want to change.
And what we want to change is the hardware address,
so we're gonna do hw ether.
Then we're gonna give it the address
that we want to change the MAC address to.
So for example, I'm gonna use 00:11:22:33:44:55.
Very, very simple command,
we're doing ifconfig lan0 to select the interface
that we want to change its option,
we wanna set the hardware address,
and we wanna set this address to this specific address.
So you can use any address that you want,
following the same format shown here.
Just make sure your address starts with 00.
So I'm gonna hit Enter and again,
we don't see any error messages,
so it means the command got executed properly.
And finally, we just need to enable the interface
because we disabled it, by doing, ifconfig lan0 down,
so we just need to do, ifconfig lan0 up, to enable it.
Now the interface is enabled,
and if we do ifconfig again,
and look at the ether part in here,
you can see that it is changed
to the MAC address that we specified.
Now, this is done, and your MAC address has changed.
Now, you can go ahead and start using the interface
and it'll appear to have this MAC address
instead of its original MAC address.
And like I said, this can be useful in so many scenarios.
Now, keep in mind, the MAC address will revert back
to the original one once you restart the computer,
because we're only changing the MAC address in memory,
we're not really changing the physical MAC address.
But if your MAC address is resetting
to the original one without restarting,
then something is going wrong.
And it's probably happening because your network manager
is resetting the MAC address.
Not everybody will face this issue,
so I'm not gonna cover it in this lecture,
but if you face this issue,
if your MAC address goes back to the original one
without restarting the computer,
then check out the YouTube video
in the resources of this lecture,
it'll show you how to fix this issue.