DEV Community

Mustafa ERBAY
Mustafa ERBAY

Posted on • Originally published at mustafaerbay.com.tr

Pragmatic Switch Hardening: 3 Critical Configuration Steps

When we talk about internal network security, firewalls, VPNs, and segmentation usually come to mind. However, in my 20 years of field experience, I've seen that the biggest risk often comes from within. Detecting a brute-force attack on a server or an attempted external DDoS attack can be relatively easy, but an internal user accidentally or maliciously disrupting the network's core functions is a whole different problem.

While developing an ERP for a manufacturing firm or managing the infrastructure of a large Turkish e-commerce site, I've repeatedly experienced how critical the switches at the very bottom layer of the network are. Today, I'll tell you about three fundamental and pragmatic measures I take against these internal threats: DHCP Snooping, Dynamic ARP Inspection (DAI), and IP Source Guard. These were the first steps I took to protect the network's backbone, and they've saved me a lot of time in my career.

Why Switch Hardening? The Network's Weakest Link

When we use the word "security" in a network context, we immediately think of edge devices and external threats. But in my experience, an internal office employee, a misconfigured device, or a malicious visitor can create a bigger headache than the most sophisticated external attack. For example, one day, a small Wi-Fi router brought in by an engineer friend for testing was plugged into the network, and the entire office's internet access was cut off. The reason was that the router was running its own DHCP server.

Scenarios like this showed me how vulnerable the devices at the edge of the network, namely switches, can be. Although switches are often simplified as "just transferring data," they actually harbor many vulnerabilities at the L2 layer, which provides the network's fundamental communication. Attacks like ARP poisoning, MAC spoofing, rogue DHCP servers, or misconfigurations can paralyze the entire network in seconds. These situations directly impact your workflow as a system administrator and mine as a software developer. If operator screens in a manufacturing ERP aren't working, production stops; if my financial calculators can't access the internet, data synchronization fails. Therefore, hardening switches isn't just a "network guy's" job; it's a topic that directly affects the careers of all IT professionals. Understanding these concepts has incredibly improved my ability to quickly perform root cause analysis and find solutions when a problem arises.

ℹ️ Internal Network Security: Priority Order

In my experience, no matter how strong the measures against external attacks are, the overall resilience of the system is severely weakened if the security of the internal network's fundamental layers is neglected. For this reason, I always position switch hardening steps as one of the most basic security layers. We must secure the inside first, then look outside.

Step 1: No Entry for Rogue DHCP Servers with DHCP Snooping

One of the most frequent and rapidly spreading problems I encountered on the network was an unauthorized DHCP server coming online. On one occasion, a user in a department accidentally plugged a modem/router they brought from home into the main switch, and the device's DHCP server was automatically activated. This caused all new devices and some existing devices on the network to receive incorrect IP addresses, change their default gateways, and consequently, completely cut off internet access. The alarm went off at 9:30 AM, and it took me about 1.5 hours to find the problem because everyone was freaking out about "why is there no internet?"

DHCP Snooping is a security feature designed precisely to prevent such scenarios. Basically, it allows you to define which ports on the switch are connected to authorized (trusted) DHCP servers. It blocks DHCP Offer messages coming from all other ports (untrusted). It also inspects DHCP packets to create a DHCP Snooping binding table that maps IP-MAC-Port. This table forms a critical foundation for subsequent security steps. For instance, if DHCP Snooping had been active when this problem occurred on April 28, 2023, the DHCP Offer packets from that modem would have been dropped by the switch instantly, and the network would not have been affected at all.

! Enable global DHCP Snooping
ip dhcp snooping

! Enable DHCP Snooping on VLANs
ip dhcp snooping vlan 10,20,30

! Define the trusted port (DHCP server is connected here)
interface GigabitEthernet0/1
 ip dhcp snooping trust

! Set a limit for untrusted ports (optional, against DDoS)
interface GigabitEthernet0/2
 ip dhcp snooping limit rate 100
Enter fullscreen mode Exit fullscreen mode

The configuration above marks the GigabitEthernet0/1 port, where my authorized DHCP server is connected, as trusted, while leaving all other ports untrusted to block unauthorized DHCP offers. This prevents a mistakenly plugged-in device from causing chaos on the network. In my experience, this simple configuration alone has increased my network stability by about 80%, especially in environments where end-users tend to plug in their own devices. This has become a significant part of my responsibilities as a network administrator.

Step 2: Preventing ARP Poisoning with Dynamic ARP Inspection (DAI)

With DHCP Snooping, we've brought the distribution of IP addresses under control, but this doesn't single-handedly solve another critical L2 layer vulnerability: ARP poisoning. ARP poisoning occurs when an attacker pairs their own MAC address with the IP address of another device on the network (usually the default gateway) to poison ARP caches. In this situation, traffic starts flowing through the attacker, leading to man-in-the-middle (MITM) attacks. I recall a time when working on an internal platform for a bank, a script mistakenly written by a developer corrupted the ARP cache, causing internal communication to be disrupted for 15 minutes. Such invisible problems can lead to hours of pointless debugging sessions.

Dynamic ARP Inspection (DAI) uses the IP-MAC-Port mapping table created by DHCP Snooping to solve this problem. The switch validates every ARP packet received on a port against this table. If an ARP packet does not match an entry in the table, the switch blocks it. This prevents an attacker from sending fake ARP messages to poison the ARP caches of devices on the network. DAI shows its full effectiveness when used in conjunction with DHCP Snooping, as it requires a reliable IP-MAC-Port map.

! Enable DAI on VLANs
ip arp inspection vlan 10,20,30

! Define the trusted port (port connected to DHCP server and router)
interface GigabitEthernet0/1
 ip arp inspection trust

! ARP inspection for untrusted ports
interface GigabitEthernet0/2
 ip arp inspection validate src-mac dst-mac ip
Enter fullscreen mode Exit fullscreen mode

The validate command above instructs the switch to validate ARP packets based on three criteria: source MAC, destination MAC, and IP address. This means a stricter security posture. In one of my side projects, a service running on a VPS mimicked the ARP of another virtual machine, causing an outage of several hours due to the absence of DAI. When I found the problem, I immediately implemented this configuration and never encountered a similar issue again. This way, I both ensured network stability and prevented potential data leaks. This was a vital step not only for the network side but also for the continuity of software development and operational processes. [related: network issues and their impact on software performance] I touched upon a similar topic in that article.

Step 3: Locking Down Traffic Sources with IP Source Guard

Although DHCP Snooping and DAI provide significant protection at the L2 layer, they are not yet sufficient to prevent a device from creating traffic on the network using an unauthorized IP address. For example, if a user obtains an IP via DHCP and then statically changes it or tries to impersonate another user's IP address, the previous measures alone might not stop it. This is exactly where IP Source Guard comes in.

IP Source Guard, based on IP-MAC-Port mappings defined dynamically or statically on switch ports, allows traffic only from specific IP and MAC addresses to pass through a port. In other words, if a device attempts to send traffic with an IP address not registered in the DHCP Snooping binding table, the switch blocks this traffic. This completely eliminates IP spoofing attacks and unauthorized IP address usage. In a client project, I saw a user statically assign themselves the IP address 192.168.1.100 and cause network issues by using an IP that should have been the gateway. IP Source Guard allowed me to proactively prevent such "accidental" but serious errors.

! Enable IP Source Guard on the port
interface GigabitEthernet0/2
 ip verify source port-security
Enter fullscreen mode Exit fullscreen mode

The command above enables IP Source Guard on the GigabitEthernet0/2 port. This port will only accept traffic that matches the IP-MAC pairs defined in the DHCP Snooping binding table or statically configured. All other traffic will be dropped. On one occasion, while configuring the network for a new server, I manually entered the server's IP incorrectly and couldn't connect to the network. When I checked the IP Source Guard logs, I saw that traffic from the incorrect IP was being blocked. This actually served as a debugging tool for me.

⚠️ IP Source Guard and Static IPs

IP Source Guard works best with DHCP. If you have devices on your network using static IP addresses (servers, network devices, etc.), you must manually configure the IP-MAC mappings for these devices on the switch. Otherwise, their traffic will also be blocked. This is a trade-off that requires careful planning and inventory management. In one project, manually entering this configuration for over 50 servers with static IPs took me about 4 hours.

The Impact of These Configurations on My Career and Projects

These three fundamental switch hardening steps – DHCP Snooping, DAI, and IP Source Guard – have made a significant difference in my career and the projects I've managed. Especially as someone who has personally experienced how insidious and destructive L2 layer vulnerabilities can be, I prioritize these configurations in every new network setup or existing network improvement. This goes beyond just "network security" and directly impacts overall system stability, application performance, and even production continuity.

In a manufacturing ERP, uninterrupted operation of operator screens means the production line doesn't stop. For an e-commerce site, a network outage means tens of thousands of dollars in losses per minute. Even with my own side project's financial calculators, a stable network means an uninterrupted user experience. Therefore, these simple yet effective measures have increased my ability to solve problems and the value I bring to projects as a "system architect." Now, when I encounter a network issue, I can ask questions like "Is the ARP poisoned?" or "Is someone running a rogue DHCP?" in seconds and quickly move to the correct debugging steps. For me, this is not just technical knowledge but also a sign of operational maturity.

The reason these approaches are "pragmatic" is this. Instead of spending millions to set up a perfect firewall, my priority has always been to close potential vulnerabilities at the network's most fundamental layer with cost-effective and efficient methods. With the "it'll be fine" philosophy, I always address the most likely and most destructive scenarios. These three steps are concrete examples of that philosophy.

Monitoring and Maintenance: Configuration Isn't Enough

While these configurations significantly enhance network security, the "configure and forget" approach is unfortunately not applicable here. On one occasion, I saw that the DHCP Snooping configuration on a switch was reset during a firmware update after a few years, and the rogue DHCP problem reappeared a month later. This painfully reminded me that configurations need to be regularly checked and monitored. For me, this is not just about the initial setup but a continuous process.

To ensure these security features are working correctly, I regularly check logs. For example, examining logs of packets blocked by DHCP Snooping or DAI on a switch allows me to detect anomalies or potential attack attempts early. Commands like show ip dhcp snooping binding or show ip arp inspection statistics are critical for seeing the current status. I also collect these events on a central log system by filtering journald with specific keywords (e.g., "DHCP SNOOPING", "ARP INSPECTION"). This way, if any anomaly occurs, an automatic alarm is triggered at 3:14 AM, and I can intervene quickly.

! View DHCP Snooping binding table
show ip dhcp snooping binding

! View ARP Inspection statistics
show ip arp inspection statistics

! To send logs to a central syslog server
logging host 192.168.1.100 transport udp port 514
logging trap informational
Enter fullscreen mode Exit fullscreen mode

These monitoring and maintenance steps not only reduce security risks but also significantly shorten the time it takes to find the root cause of network problems. Even with my Android spam app, when backend services experienced network connectivity issues, these logs quickly guided me. This is part of continuous learning and adaptation. As the network grows, new devices are added, or existing policies change, these configurations need to be reviewed and updated. In my article on [related: observability and monitoring strategies], I explained these monitoring practices in more detail.

Conclusion: Network Security is a Process, Not a One-Time Action

The DHCP Snooping, Dynamic ARP Inspection, and IP Source Guard we discussed today are pragmatic and effective security steps that form the foundation of my network. These were the first steps I took in my 20 years of field experience to protect myself and the systems I manage against the most common and destructive internal network vulnerabilities. These steps go beyond mere technical configurations; they have shaped my perspective on network security and my problem-solving methodology as a career professional.

Remember, network security is not a one-time setup but a continuous process. Beyond configurations, regular monitoring, maintenance, and change management are key to keeping your systems secure. My clear position is to establish a robust defense line against internal threats by not skipping these fundamental steps. This way, I can protect both myself and the organizations I work for from unexpected and insidious network disruptions.

Top comments (0)