Securing the network: ports, lists and the traps between them
Hardening the device itself, AAA and why TACACS+ and RADIUS differ, the first-hop protections that stop a laptop impersonating a server, how to write an access list that does what you meant, and the VPN types worth naming.
On this page
Network security is not one product. It is a sequence of small assumptions removed: that anyone with a cable belongs here, that a device claiming to be the DHCP server is one, that a frame's source address is honest, that traffic between two subnets should flow just because a route exists. Each of the features in this article removes one of those assumptions, and each is a few lines of configuration on equipment you already own.
The map
Read this first when short on time. Every branch is a section below.
Where the attacks actually are
It is tempting to think of security as a firewall at the edge. That model assumes everything inside is trustworthy, and almost every serious incident begins with something inside that is not — a compromised laptop, a contractor's device, a camera with a default password.
Threats map onto layers, and so do the defences:
| Layer | Attack | Control |
|---|---|---|
| Physical | Plugging into a socket in a lobby | Shut unused ports, 802.1X, locked cabinets |
| Layer 2 | MAC flooding, DHCP spoofing, ARP poisoning, VLAN hopping | Port security, DHCP snooping, dynamic ARP inspection, explicit port modes |
| Layer 3 | Spoofed sources, reconnaissance, reaching things you should not | Access lists, segmentation, anti-spoofing filters |
| Layer 4 and above | Interception, credential theft, exploitation | Encryption, stateful firewalls, patching |
| Management | Weak passwords, shared accounts, plaintext protocols | SSH, AAA, per-user accounts, command accounting |
The pattern worth internalising: the weakest layer decides the outcome. A perfectly configured firewall protects nothing if an attacker is already inside the broadcast domain poisoning ARP, and the strongest layer 2 protections do not help if the management password is cisco.
Hardening the device itself
Before protecting traffic, protect the thing doing the protecting. Most of this appeared in the IOS article; here it is as a checklist with the reasoning attached.
! strong, hashed privileged-mode secret
Router(config)# enable secret 9 $9$longHashedValue
! individual accounts, not a shared line password
Router(config)# username sujith privilege 15 secret Str0ng-Pass
! SSH only, and only from the management network
Router(config)# ip domain-name example.local
Router(config)# crypto key generate rsa modulus 2048
Router(config)# ip ssh version 2
Router(config)# access-list 10 permit 10.99.0.0 0.0.0.255
Router(config)# line vty 0 15
Router(config-line)# login local
Router(config-line)# transport input ssh
Router(config-line)# access-class 10 in
Router(config-line)# exec-timeout 10 0
Router(config-line)# exit
! a legal banner, worded as a warning rather than a greeting
Router(config)# banner login # Authorised access only. Activity is monitored. #access-class 10 in on the vty lines is the one people skip, and it is among the most valuable. It means SSH is only accepted from the management subnet, so an attacker who reaches the device from a user VLAN cannot even attempt a password.
The banner wording matters for a non-technical reason: in several jurisdictions a system that says "Welcome" has been argued to have invited access. Banners are worded as warnings for that reason, not out of unfriendliness.
Unused switch ports deserve the same discipline. A live port in the default VLAN is an open invitation:
Switch(config)# interface range GigabitEthernet1/0/21 - 24
Switch(config-if-range)# switchport mode access
Switch(config-if-range)# switchport access vlan 999
Switch(config-if-range)# shutdownShut, and in an unused VLAN, so that enabling one by accident still leads nowhere.
AAA: authentication, authorisation, accounting
Local accounts on each device do not scale. Ten devices and five staff is fifty accounts to keep synchronised, and removing someone who leaves means logging into all ten. AAA centralises it.
- Authentication — who are you? Verifying a credential.
- Authorisation — what may you do? Which commands, which privilege level.
- Accounting — what did you do? A record of commands and sessions.
| RADIUS | TACACS+ | |
|---|---|---|
| Transport | UDP 1812/1813 | TCP 49 |
| Encryption | Password only | The entire payload |
| The three As | Authentication and authorisation combined | Separated |
| Standard | IETF, multi-vendor | Cisco, though widely implemented |
| Command authorisation | No | Yes, per command |
| Typical use | Authenticating users and devices onto the network (802.1X, wireless, VPN) | Authenticating administrators onto network devices |
The separation in TACACS+ is what makes per-command authorisation possible: the device can ask the server about each command as it is typed, so a junior engineer can be permitted show commands and clear counters and nothing else. RADIUS, which decides everything at login, cannot do that.
The practical split in most organisations is therefore both: RADIUS for users and devices joining the network, TACACS+ for administrators managing the equipment.
Router(config)# aaa new-model
Router(config)# tacacs server TAC1
Router(config-server-tacacs)# address ipv4 10.99.0.30
Router(config-server-tacacs)# key SharedTacacsSecret
Router(config-server-tacacs)# exit
Router(config)# aaa group server tacacs+ TACGROUP
Router(config-sg-tacacs+)# server name TAC1
Router(config-sg-tacacs+)# exit
Router(config)# aaa authentication login default group TACGROUP local
Router(config)# aaa authorization exec default group TACGROUP local
Router(config)# aaa accounting commands 15 default start-stop group TACGROUPThe local at the end of each authentication line is a fallback, and it is not optional. Without it, a device that loses contact with the AAA server refuses every login including yours — and the moment you most need to log in is usually the moment the network is broken. Always keep a local account and always list it as the last method.
802.1X applies the same idea to the network edge: a switch port stays closed until the device on it authenticates to a RADIUS server, and the server can return the VLAN the device should be placed in. It is the strongest available answer to "somebody plugged into the socket in reception", and the reason it is not universal is that printers, cameras and other devices without a supplicant need exceptions.
Protecting the first hop
Four switch features work together, and each depends on the one before it. Together they take an access port from "trusts everything" to "trusts nothing it has not verified".
Port security: cap the MAC addresses
Limits how many MAC addresses a port may learn, and what to do when the limit is exceeded. It stops MAC flooding attacks — filling the table so the switch floods everything — and it stops somebody quietly plugging a small switch into a desk port.
Switch(config-if)# switchport mode access
Switch(config-if)# switchport port-security
Switch(config-if)# switchport port-security maximum 2
Switch(config-if)# switchport port-security mac-address sticky
Switch(config-if)# switchport port-security violation restrict
Switch(config-if)# switchport port-security aging time 60| Violation action | Port | Traffic | Log and counter |
|---|---|---|---|
protect | Stays up | Offending frames dropped | Neither — silent |
restrict | Stays up | Offending frames dropped | Both |
shutdown (default) | err-disabled | Everything stops | Both |
protect is almost never right: it fails silently, so nobody learns anything happened. restrict is the usual choice on user ports, and shutdown where a violation should genuinely stop the world. Note that a maximum of 2 is normal on a port with an IP phone, since the phone and the PC behind it each have an address.
Sticky learning writes the learned addresses into the running configuration, so they survive a reload once saved. It is convenient and it is also how a port ends up permanently bound to a laptop that was replaced two years ago, so an ageing time is worth setting.
DHCP snooping: only the real server may answer
A rogue DHCP server — malicious, or just somebody's home router plugged in the wrong way round — hands out addresses with itself as the default gateway, and all traffic flows through it. DHCP snooping stops it by dividing ports into trusted and untrusted.
Switch(config)# ip dhcp snooping
Switch(config)# ip dhcp snooping vlan 10,20
Switch(config)# no ip dhcp snooping information option
Switch(config)# interface GigabitEthernet1/0/24
Switch(config-if)# ip dhcp snooping trust
Switch(config-if)# exit
Switch(config)# interface range GigabitEthernet1/0/1 - 20
Switch(config-if-range)# ip dhcp snooping limit rate 10Only trusted ports — the uplink towards the real server — may send DHCP offers and acknowledgements. An untrusted port sending one has its frames dropped. The rate limit stops a client exhausting the pool by requesting thousands of addresses.
The second thing snooping does is quietly more important: it builds a binding table recording which IP address was issued to which MAC address on which port in which VLAN. That table is the foundation of the next two features.
Dynamic ARP inspection: check the ARP replies
ARP has no authentication whatsoever. Any host can announce that it owns any address, and every listener believes it. ARP poisoning exploits this to become a man in the middle: tell the victim you are the gateway, tell the gateway you are the victim, and read everything in between.
DAI intercepts ARP packets on untrusted ports and checks them against the DHCP snooping binding table. An ARP reply claiming an address that the table says belongs to a different port is dropped and logged.
Switch(config)# ip arp inspection vlan 10,20
Switch(config)# interface GigabitEthernet1/0/24
Switch(config-if)# ip arp inspection trustBecause it depends on the binding table, DAI without DHCP snooping drops all ARP on untrusted ports — statically addressed hosts need an ARP access list to be permitted explicitly.
IP source guard: check the source address
The last of the four. It filters ordinary IP traffic against the same binding table, so a host cannot send packets claiming a source address it was not given. This defeats source-address spoofing from inside the network, which is otherwise trivial.
flowchart TD A["DHCP snooping<br/>only trusted ports answer DHCP"] --> B["Binding table<br/>IP, MAC, port, VLAN"] B --> C["Dynamic ARP inspection<br/>drops forged ARP replies"] B --> D["IP source guard<br/>drops spoofed source addresses"] E["Port security<br/>caps MAC addresses per port"] --> F["An access port that<br/>cannot be impersonated"] C --> F D --> F
Access lists
An ACL is an ordered list of permit and deny statements evaluated against each packet. They are used for filtering, and — as NAT and OSPF showed — reused as a general matching language throughout IOS.
| Standard | Extended | |
|---|---|---|
| Numbers | 1–99, 1300–1999 | 100–199, 2000–2699 |
| Matches | Source address only | Source, destination, protocol, ports, flags |
| Place it | Close to the destination | Close to the source |
The placement rule follows from what each can see. A standard ACL knows only the source, so placing it near the source would block that source's traffic to everything, not just the destination you meant. An extended ACL knows both ends, so it can be placed early and drop unwanted traffic before it consumes bandwidth.
Three rules that decide behaviour
- Top to bottom, first match wins. Once a packet matches a line, no later line is considered. A
permit anynear the top makes everything below it decoration. - There is an implicit
deny anyat the end. It is invisible in the configuration and it is always there. An ACL that permits one thing denies everything else — which is the most common cause of an ACL working in a way its author did not intend. - Order from specific to general. Deny the one host, then permit the subnet, not the reverse.
! named extended ACL: let the guest VLAN reach the internet and nothing internal
Switch(config)# ip access-list extended GUEST-OUT
Switch(config-ext-nacl)# remark block access to all internal networks
Switch(config-ext-nacl)# deny ip 10.20.0.0 0.0.255.255 10.0.0.0 0.255.255.255
Switch(config-ext-nacl)# permit udp 10.20.0.0 0.0.255.255 host 10.99.0.10 eq 53
Switch(config-ext-nacl)# permit tcp 10.20.0.0 0.0.255.255 any eq 443
Switch(config-ext-nacl)# permit tcp 10.20.0.0 0.0.255.255 any eq 80
Switch(config-ext-nacl)# exit
Switch(config)# interface vlan 20
Switch(config-if)# ip access-group GUEST-OUT inNamed ACLs are worth using over numbered ones: the name says what it is for, and individual lines can be edited by sequence number instead of deleting and retyping the whole list.
Note the wildcard masks. 0.0.255.255 matches a /16; 0.0.0.0 matches one host and can be written host 10.99.0.10; 255.255.255.255 matches everything and is written any. Writing a subnet mask where a wildcard belongs is the most common ACL error there is, and it usually fails in a way that is not obvious until traffic tests it.
Applying an ACL in the wrong direction on the interface you are connected through will disconnect you. in means traffic entering the interface from the network; out means traffic leaving the router towards it. Before applying one to a remote device, set reload in 10 so a mistake fixes itself.
Switch# show access-lists ! includes a match counter per line
Switch# show ip interface vlan 20 ! which ACL is applied, in which directionThe per-line match counters in show access-lists are the fastest debugging tool available: if the line you expected to match has a count of zero, the traffic is not reaching it and something earlier caught it first.
VPNs, in one page
A VPN carries private traffic across a network you do not trust — usually the internet — by encrypting it. Two shapes cover almost everything.
Site to site. Two routers build a permanent tunnel, and hosts at either end are unaware of it. Traffic between the two offices is encrypted in transit and neither host does anything special. Built with IPsec, which provides four things:
- Confidentiality — encryption, so the payload cannot be read.
- Integrity — hashing, so it cannot be altered undetected.
- Authentication — each end proves who it is, with a pre-shared key or a certificate.
- Anti-replay — a captured packet cannot be resent later to repeat its effect.
Plain IPsec carries only unicast IP, which means no routing protocols and no multicast across the tunnel. GRE over IPsec is the usual answer: GRE builds a tunnel interface that behaves like an ordinary link and can carry anything, and IPsec encrypts it. That is why routers can run OSPF across a site-to-site VPN.
Remote access. An individual connects from a laptop. Either IPsec with a client, or — far more commonly now — a TLS VPN, which uses the same protocol as HTTPS and therefore passes through hotel and airport networks that block everything else. It also needs no special client for basic access, which removes an entire category of support work.
| Site-to-site IPsec | Remote-access TLS | |
|---|---|---|
| Endpoints | Two routers or firewalls | A client device and a gateway |
| Lifetime | Permanent | Per session |
| Hosts must | Do nothing | Run a client or use a browser |
| Through restrictive networks | Often blocked | Usually passes, being port 443 |
| Carries routing protocols | Only with GRE | No |
- DMVPN and SD-WAN automate the site-to-site case, building tunnels between branches on demand rather than requiring an explicit configuration for every pair — which is what makes a hundred-site network manageable.
- WireGuard has taken a large share of the remote-access market by being small enough to audit and fast enough to run on a phone without draining it.
- Zero trust designs are steadily replacing the VPN model entirely: instead of putting a remote user "inside" the network, each application is published individually and every request is authenticated, which removes the assumption that being inside means anything.
- AAA
- Authentication, authorisation and accounting — who you are, what you may do, and a record of what you did.
- Binding table
- The DHCP snooping record of IP address, MAC address, port and VLAN, used by dynamic ARP inspection and IP source guard.
- Implicit deny
- The invisible
deny anyat the end of every access list. - Wildcard mask
- An inverted subnet mask used for matching: 0 means the bit must match, 1 means ignore it.
- IPsec
- The protocol suite providing confidentiality, integrity, authentication and anti-replay for IP traffic.
Recap
- Security is layered, and the weakest layer decides the outcome — a firewall does not help against ARP poisoning inside the broadcast domain.
- Harden the device first: SSH only, individual accounts, hashed secrets, a warning banner, and an access class on the vty lines.
- Unused ports should be shut and assigned to an unused VLAN.
- AAA separates authentication, authorisation and accounting; always configure a local fallback method.
- RADIUS encrypts only the password and combines authentication with authorisation; TACACS+ encrypts everything and separates them, enabling per-command authorisation.
- RADIUS for users joining the network, TACACS+ for administrators managing the devices.
- Port security caps MAC addresses per port;
restrictis usually the right violation action becauseprotectfails silently. - DHCP snooping lets only trusted ports answer DHCP and builds the binding table everything else depends on.
- Dynamic ARP inspection checks ARP replies against that table; IP source guard checks ordinary traffic against it.
- Access lists are read top to bottom, first match wins, with an invisible
deny anyat the end. - Standard ACLs match source only and go near the destination; extended ACLs match both ends and go near the source.
- IPsec gives confidentiality, integrity, authentication and anti-replay; GRE over IPsec is what lets routing protocols cross a tunnel.
Questions
Say the answer out loud before opening it.
What is the difference between RADIUS and TACACS+?
RADIUS uses UDP and encrypts only the password, combining authentication and authorisation; TACACS+ uses TCP, encrypts the whole payload, and separates the three As.
- The separation is what allows per-command authorisation, which RADIUS cannot do.
- RADIUS is an IETF standard and is used for 802.1X, wireless and VPN authentication.
- TACACS+ is Cisco's and is used for administrative access to devices.
Most organisations run both, because each is better at a different job and the two populations of users are entirely separate.
Why must an AAA configuration include a local fallback?
Because without it, a device that cannot reach the AAA server refuses every login — including yours, at exactly the moment the network is broken.
aaa authentication login default group TACGROUP localtries the server first and falls back.- The fallback only applies when the server is unreachable, not when it rejects a password.
- A local account must exist for the fallback to be useful.
The same reasoning applies to the console line, which is often given a separate method list so physical access always works even when everything else does not.
What does port security do, and which violation action should you choose?
It limits how many MAC addresses a port may learn; restrict is usually right because it drops offending traffic while logging and counting it.
protectdrops silently, so nobody learns anything happened.shutdownis the default and puts the port into err-disabled.- A maximum of 2 is normal on a port with an IP phone and a PC behind it.
Sticky learning writes learned addresses into the configuration, which is convenient but can permanently bind a port to a device that was replaced long ago unless an ageing time is set.
What attack does DHCP snooping prevent, and what else does it provide?
It stops a rogue DHCP server handing out addresses, and it builds the binding table that ARP inspection and IP source guard depend on.
- Only trusted ports may send offers and acknowledgements; untrusted ones are dropped.
- The rogue server's real damage is setting itself as the default gateway, which routes all traffic through it.
- The binding table records IP, MAC, port and VLAN for every lease it observed.
Because the other two features have nothing to check against without it, DHCP snooping is the one to enable first — the others are meaningless on their own.
How does ARP poisoning work and how is it stopped?
ARP has no authentication, so an attacker announces that it owns the gateway's address to the victim and the victim's address to the gateway, placing itself in the middle. Dynamic ARP inspection stops it.
- DAI intercepts ARP on untrusted ports and checks it against the DHCP snooping binding table.
- A reply claiming an address bound to a different port is dropped and logged.
- Statically addressed hosts need an ARP access list, since they have no binding entry.
The attack works at layer 2 inside a broadcast domain, which is why no amount of firewalling at the network edge affects it.
What is the implicit deny, and why does it catch people out?
Every access list ends with an invisible deny any, so anything not explicitly permitted is dropped — and it does not appear in the configuration.
- An ACL written to block one thing blocks everything, because the author forgot to permit the rest.
- Adding an explicit
deny ip any anyat the end changes nothing functionally but gives a match counter. - An empty ACL applied to an interface denies everything.
The match counters in show access-lists are the fastest way to diagnose this: traffic hitting the implicit deny shows as zero matches on every line you wrote.
Where should a standard ACL be placed, and why not near the source?
Close to the destination, because it can match only the source address and would otherwise block that source's traffic to every destination.
- An extended ACL matches both ends, so it can safely go near the source and save bandwidth.
- The trade-off for standard ACLs is that unwanted traffic crosses the network before being dropped.
- In practice extended named ACLs are used for almost everything.
The placement rule is really a statement about information: put the filter where it has enough information to be precise, and no earlier.
What is a wildcard mask and how do you write one for a /26?
An inverted subnet mask where 0 means the bit must match and 1 means ignore it; a /26 is 0.0.0.63.
- Subtract each subnet mask octet from 255: 255.255.255.192 becomes 0.0.0.63.
host 10.1.1.5is shorthand for a wildcard of 0.0.0.0.anyis shorthand for 0.0.0.0 with a wildcard of 255.255.255.255.
Wildcards can be non-contiguous, which allows tricks like matching only odd subnets, though the confusion this causes usually outweighs the lines saved.
What does "access-class 10 in" on the vty lines do?
It restricts which source addresses may open an SSH session to the device.
- Only addresses permitted by access list 10 can connect at all.
- An attacker reaching the device from a user VLAN cannot even attempt a password.
- It applies to all vty lines it is configured on, so all sixteen must be covered.
It is one of the highest-value single lines in a device configuration, and it is frequently omitted because the device appears secure without it.
Why are login banners worded as warnings?
Because in several jurisdictions a system greeting a user has been argued to have invited access, which weakens later legal action.
- The banner should state that access is restricted to authorised users and that activity is monitored.
- It should not name the organisation, the device model or the software version.
banner loginappears before authentication;banner motdappears on connection.
It is one of the few security controls that does nothing technically and is still worth configuring on every device.
What does IPsec provide?
Confidentiality through encryption, integrity through hashing, authentication of both endpoints, and anti-replay protection.
- Endpoint authentication uses a pre-shared key or a certificate.
- Anti-replay stops a captured packet being resent to repeat its effect.
- It carries only unicast IP, so routing protocols and multicast need GRE.
NAT is a problem for IPsec in transport mode because the authentication covers the IP header, which is why NAT traversal wraps the whole thing in UDP.
Why use GRE over IPsec rather than IPsec alone?
Because GRE creates a tunnel interface that behaves like an ordinary link and can carry anything, including routing protocols and multicast, which plain IPsec cannot.
- OSPF or EIGRP can then form adjacencies across the tunnel.
- GRE itself provides no encryption, so IPsec is still required for confidentiality.
- The combination costs extra header overhead and therefore a smaller usable MTU.
That MTU reduction is a common source of mysterious failures — small packets pass and large ones vanish — which is why MSS clamping is usually configured on tunnel interfaces.
Why have TLS VPNs largely replaced IPsec for remote access?
Because they use port 443, which passes through hotel, airport and corporate guest networks that block almost everything else, and they need no special client for basic access.
- IPsec uses protocols and ports that restrictive networks frequently block.
- A browser-based portal removes a whole category of client installation and support.
- Full-tunnel clients still exist for TLS VPNs where complete network access is needed.
Both are now being displaced by zero-trust models, which publish individual applications and authenticate every request rather than placing a remote user inside the network.
How would you secure unused switch ports?
Shut them down and assign them to an unused VLAN, so that enabling one by mistake still leads nowhere.
shutdownalone is the minimum.- Setting
switchport mode accessalso prevents DTP negotiating a trunk if the port is later enabled. - An unused VLAN with no routing means an enabled port has no path anywhere.
802.1X is the stronger control, since it leaves ports usable while requiring authentication — but it needs exceptions for printers, cameras and anything without a supplicant.
You applied an ACL and lost your SSH session. What went wrong and how do you avoid it?
The ACL denied your own management traffic, most likely because it was applied in the wrong direction or omitted a permit for the management subnet.
infilters traffic entering the interface from the network;outfilters traffic leaving towards it.- The implicit deny catches management traffic that was never explicitly permitted.
reload in 10before applying the ACL rolls the device back automatically if you lose access.
Testing an ACL by applying it and watching the per-line match counters — before relying on it — is the habit that turns this from a recurring incident into a non-event.