Port security controls network access by restricting which devices can connect to a switch port based on MAC addresses, offering a simple but limited layer of physical network protection.
Port Security
One of the most basic ways that we can control access to a network is through port security. It is also very simple to set up, which might be why we would want to implement port security. It's not a perfect solution, but it's an easy solution to implement.
Let's say I was an adversary and I wanted to hack into a network. One of the ways I could do that is somehow figure out physical access to get into the network and plug a device into the switch. Largely our networks are open, so once we plug into the switch now we have access to a lot of resources and there's nothing that's controlling my access to that. So I could either plug it in on a machine, or better yet I can just plug in a little box that's hidden from everybody else, hidden out of sight. Now I have free access, and that is going to maybe do some data exfiltration where I'm going to have control within that network through this device. So this is where something like port security can really shine and stop somebody from just coming in and plugging in a random device.
Port security uses MAC addresses to limit the access into a network. Local area networks, or Ethernet, in this case right here it's Ethernet that is communicating back and forth. This Ethernet network uses a MAC address for one machine to be able to talk to another machine on this local area network, so it has to have a MAC address.
These MAC addresses are burned into a network interface card. So if your machine has a network interface card, there's a good chance it has two actually. It probably has a wireless one, and it probably has one built into the motherboard. So if there are two of them on there, then it would have two MAC addresses, one per network interface card. And whoever the manufacturer is for that network interface card is the one that has burned in that MAC address into that network interface card. So that's what exists on the computer, some sort of MAC addresses associated with each one of its network interface cards. Now if it connects in, then it will use that MAC address to communicate on that network.
Port security just means that we're limiting who can plug into a port based off of their MAC address. So if this is the MAC address of this machine and it's assigned to this port right here, then what happens is that no one else can plug into that port. And also, if it's not allowed, then this machine can't plug into a different port. So we control which port this machine has access to based off of its MAC address.
There are static or dynamic port security. What I mean by that is that this port right here can either statically be set up for this MAC address, so no other machine can connect to it unless it has that MAC address, or it could dynamically learn it. So when we plug in this machine, it will learn of this MAC address and now no other machine can plug into that port, because it now is associated with this MAC address. This just makes it easier to manage if it's more dynamic, versus a static where I have to manually go in there and enter those MAC addresses initially. Static would be more secure, versus dynamic would be less secure, because now anybody can plug in and it will learn that MAC address.
If it does learn about it dynamically, then maybe we don't want it to permanently associate with that port. We can have it so it permanently associates with that port, and now only this machine can plug into that port until we reset that port. Or what we could do is we could say, well, after a certain period of time it can do away with that MAC address and another machine can plug into it, which lessens the security but allows it to be more dynamic, where another machine can plug into it.
Usually what we do, if we're just learning about these MAC addresses temporarily, is we're just limiting how many MAC addresses can use that port. What this does is it allows it so somebody doesn't plug in a switch with many devices that are hanging off of this, because a lot of times we want to be very specific about which network devices we have, how many switches we have, and we don't want stray switches that cause problems on our network. And the sign of a stray switch, or something else that's plugged into this network, is multiple MAC addresses. So what we might do is we might limit it to only two MAC addresses, or only one MAC address, that can be on this port at any given time, which limits it to just a single MAC address, and now only one computer can be plugged into there.
When I worked at a university, this is the way we set it up. We didn't want to control what devices plugged into our switches, but we did want to limit how many devices. We didn't want people to be plugging in their own switches, which could cause problems and interrupt all the rest of the students if they plugged that in wrong. So we controlled how many MAC addresses could be on each of those ports.
This is a common method also with wireless, to limit who can access a wireless network based off of the MAC address. So we can do wireless MAC address filtering as well.
This is not a great solution though. The problem here is this is readily accessible information, this MAC address here. Anybody on this network, on this local area network, can really see what that MAC address is. If you're communicating wirelessly you can see what that MAC address is. So it's very public information and it's very easy to spoof. It's very easy that I could claim that this is my MAC address and plug into the port.
So it does add a level of security and complexity to the network, so that way I can control who accesses the network. But by no means is this a great solution, because anybody can mimic these MAC addresses and it's very simple to do.
TechKnowSurge builds IT and cybersecurity professionals through hands-on, concept-first training built around real understanding — not memorization. Free interactive tools, structured programs, and 25+ years of real-world experience, all in one place.
Explore free tools and programs →