keepcalculator

06 Numbers and Powers

Restrict Cisco Switch Management Access IP

Card No. 06·70082 · Updated · Standard formula, shown below

To restrict Cisco switch management access by IP, you apply an access control list (ACL) to the Virtual Terminal (VTY) lines and, optionally, to the management interface (like VLAN 1 or a dedicated management VLAN). This limits which source IP addresses can establish Telnet, SSH, or HTTP sessions to the switch, blocking all others at the switch’s own input. The core configuration involves creating a standard or extended ACL that permits only specific management hosts, then referencing it under the line vty configuration with the access-class command.

Why Restrict Management Access by IP

An unmanaged switch accepts connection attempts on its management protocols from any device that can reach it at Layer 3. On a flat network, that means any user on the same VLAN can try to Telnet or SSH into the switch and attempt to guess credentials. Even with strong passwords, exposing the management plane to the entire network increases the attack surface and complicates auditing. Restricting by source IP narrows that surface to known administrative workstations or jump hosts. It is a fundamental part of the principle of least privilege: only the devices that must manage the switch should be allowed to initiate a management session. This also reduces log noise from random scans and brute-force attempts, making real security events easier to spot.

How It Works: VTY Lines and the access-class Command

Cisco IOS switches have a fixed number of VTY lines (typically 5, numbered 0 through 4, or 16 on some models). These lines are the virtual terminal ports that accept incoming Telnet and SSH connections. By default, all VTY lines allow connections from any source. The access-class command, applied in line configuration mode, filters incoming connections based on the source IP address of the packet that initiates the session. The switch evaluates the ACL when a TCP connection request arrives on a VTY line. If the source address matches a permit statement, the connection proceeds; if it matches a deny or no statement, the connection is refused. This filtering happens before any login prompt is presented, so unauthorized hosts are dropped immediately.

Step-by-Step Configuration

The configuration process is consistent across IOS and IOS-XE switches. The following steps assume you are already connected via console or an existing management session.

  1. Create a standard ACL that permits only the management hosts. For a single host, use a host statement. For a subnet, use a wildcard mask. Example: access-list 10 permit host 192.168.1.100 or access-list 10 permit 192.168.1.0 0.0.0.255.
  2. Enter line configuration mode for all VTY lines: line vty 0 4 (or line vty 0 15 on larger switches).
  3. Apply the ACL to the lines with the command access-class 10 in. The in keyword filters incoming connections.
  4. Optionally apply the same ACL to the auxiliary port if it exists and is used: line aux 0 then access-class 10 in.
  5. Consider applying the ACL to the management interface (e.g., interface vlan 1 or a dedicated management VLAN) using ip access-group 10 in. This filters all traffic destined to the switch’s IP, including ping and SNMP, not just VTY sessions. Be careful: if you filter the interface, you must ensure your management host is in the permitted list or you will lose remote access.

After applying, test from a permitted host and from a non-permitted host to confirm the behavior. The non-permitted host should receive a connection timeout or a “connection refused” message, depending on the IOS version and whether the ACL is applied to the interface or just the VTY lines.

Using Extended ACLs for Tighter Control

A standard ACL only filters on source IP. If you need to restrict by both source and destination (e.g., only allow SSH to the switch’s management IP, not to other IPs the switch might route), use an extended ACL. Extended ACLs can also filter by protocol, so you could permit only TCP port 22 (SSH) from the management subnet, while blocking Telnet even from that subnet. The configuration is similar, but the ACL syntax is more verbose:

access-list 100 permit tcp host 192.168.1.100 host 192.168.1.1 eq 22
access-list 100 deny ip any any log

Then apply it with access-class 100 in under the VTY lines. The log keyword on the final deny helps you see blocked attempts. Note that extended ACLs are evaluated more slowly than standard ones, but for a management plane with low traffic volume, the difference is negligible.

Common Mistakes and Pitfalls

The most common mistake is forgetting that the switch’s management IP is not necessarily the VLAN 1 interface. If you apply an ACL to the interface but your management host is on a different VLAN, the ACL may block the very traffic you want to permit. Always verify which VLAN the management IP resides in. Another frequent error is applying the ACL to the VTY lines but not to the interface, leaving SNMP or HTTP management open. A related issue is using the wrong wildcard mask: 0.0.0.255 is correct for a /24, but many people mistakenly use 255.255.255.0, which will not match anything. Also, remember that the ACL is evaluated in order; a deny any at the end is implied, so you do not need to add one, but if you add an explicit deny, it must come after all permits. Finally, if you are managing the switch over the network and you apply an interface ACL that does not include your current source IP, you will lose connectivity immediately. Always have console access as a fallback.

Alternatives and Additional Security Measures

Restricting by IP is one layer, but it is not sufficient on its own. IP addresses can be spoofed, and a compromised host on the allowed subnet becomes a gateway for attackers. Consider these complementary controls:

  • Use SSH instead of Telnet for all management traffic. Telnet sends credentials and data in clear text. Disable Telnet entirely with transport input ssh under the VTY lines.
  • Implement AAA (Authentication, Authorization, and Accounting) with a RADIUS or TACACS+ server to centralize user management and log every command.
  • Set a login banner to warn unauthorized users that access is restricted.
  • Use a dedicated management VLAN that is not routed to user networks, and restrict that VLAN’s access at the distribution layer.
  • Enable the switch’s built-in CPU protection features like Control Plane Policing (CoPP) to rate-limit management traffic, preventing DoS attacks on the CPU.

Verifying and Troubleshooting Your Configuration

After applying the ACL, verify it with show access-lists to see the match counters. If you see matches on the deny statement, someone is being blocked. Use show line vty to see which lines are in use. If you lose remote access, connect via console and check the configuration. A common troubleshooting step is to temporarily remove the access-class or ip access-group command to confirm it is the cause. Also, verify that your management host’s IP address is indeed the source IP of the packets (check for NAT or VPN tunnels that might change the source). If you are using a VPN, the source IP might be the VPN gateway’s IP, not your workstation’s IP, so you must permit that gateway address.

Frequently Asked Questions

Q: Can I restrict management access to only one IP address?
Yes. Use a standard ACL with a single host statement: access-list 10 permit host 192.168.1.100. Apply it to the VTY lines and optionally to the management interface. No other source IP will be able to establish a management session.

Q: What is the difference between access-class and ip access-group?
access-class is used under line configuration (VTY, AUX, console) to filter incoming and outgoing connections on those lines. ip access-group is used under an interface to filter all IP traffic entering or leaving that interface, regardless of the application. For VTY filtering, you must use access-class.

Q: Does the ACL also block SNMP or ping to the switch?
Only if you apply the ACL to the management interface with ip access-group. If you only apply it to the VTY lines, it only affects Telnet, SSH, and other line-based protocols. SNMP and ICMP are handled by the interface, so they remain open unless separately filtered.

Q: What happens if I deny my own management IP?
You will lose remote management access immediately. The switch will refuse your connection attempts, and you will need console access to fix the configuration. Always test ACL changes from a session that is not the one you are configuring, or keep a console session open.

Q: Can I use a named ACL instead of a numbered one?
Yes. Cisco IOS supports named standard and extended ACLs. For example: ip access-list standard MGMT then permit host 192.168.1.100. Apply it with access-class MGMT in. Named ACLs are often clearer for documentation.

Q: Does this work on all Cisco switch models?
The access-class command is available on virtually all IOS and IOS-XE switches, from Catalyst 2960 to 9500. On Catalyst 9000 series running IOS-XE, the syntax is identical. On older CatOS-based switches, the configuration is different, but those are legacy platforms.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →