www.howtonetwork.org

CCNA & CCNP Certifcation Training

  • About
  • Contact
  • FAQ
  • Join
  • Home
  • CCNA
    • ICND1
    • ICND2
    • 101 CCNA LABS
  • CCNP
    • ROUTE
    • SWITCH
    • TSHOOT
    • 101 CCNP LABS
  • CompTIA
    • Security+
    • Network+
  • Design
    • CCDA
    • CCDP
You are here: Home / ICND1 / Day 4 – Router and Switch Security / Day 4 Tasks / Securing the Switch

Securing the Switch

Prevent Telnet Access

Telnet traffic sends the password in clear text, which means that it could easily be read on the configuration or by a network sniffer, if one was attached to your network.

Telnet is actually disabled by default (i.e., you need to set a password and, optionally, a username to get it working). However, if you still want to have remote access to the management ports, you can enable SSH traffic to the switch with the transport input ssh command, which was discussed earlier.

Farai says – “The command transport input all is enabled by default for all VTY lines, while transport input none is enabled by default for other lines.”

Enable SSH

When possible, you should always use SSH instead of Telnet and SNMP to access your switches. SSH stands for secure shell and allows a secure exchange of information between two devices on a network. SSH uses public-key cryptography to authenticate the connecting device. Telnet and SNMP versions 1 and 2 are unencrypted and susceptible to packet sniffing (SNMP version 3 offers confidentiality – encryption of packets to prevent snooping by an unauthorised source). SSH, on the other hand, is encrypted.

To enable SSH you must have a version of IOS that supports encryption. A quick way to find this out is the show version command. Look for K9 in the file name and/or the security statement of Cisco Systems.

Switch#sh version
Cisco IOS Software, C3560 Software (C3560-ADVIPSERVICES K9-M), Version
12.2(35)SE1, RELEASE SOFTWARE (fc1)
Copyright (c) 1986-2006 by Cisco Systems, Inc.
Compiled Tue 19-Dec-06 10:54 by antonio
Image text-base: 0x00003000, data-base: 0x01362CA0
ROM: Bootstrap program is C3560 boot loader
BOOTLDR: C3560 Boot Loader (C3560-HBOOT-M) Version 12.2(25r)SEC, RELEASE
SOFTWARE (fc4)
Switch uptime is 1 hour, 8 minutes
System returned to ROM by power-on
System image file is “flash:/c3560-advipservicesk9-mz.122-35.SE1.bin”
This product contains cryptographic features and is subject to United States and local country laws governing import, export, transfer and use. Delivery of Cisco cryptographic products does not imply third-party authority to import, export, distribute or use encryption. Importers, exporters, distributors and users are responsible for compliance with U.S. and local country laws. By using this product you agree to comply with applicable laws and regulations. If you are unable to comply with U.S. and local laws, return this product immediately. A summary of U.S. laws governing Cisco cryptographic products may be found at:
http://www.cisco.com/wwl/export/crypto/tool/stqrg.html
If you require further assistance please contact us by sending email to export@cisco.com.
–More-

NOTE: If you do not have a security version of IOS, you must purchase a license for it.

For an encrypted connection , you will need to create a private/public key on the switch (see below). When you connect, use the public key to encrypt the data and the switch will use its private key to decrypt the data. For authentication, use your chosen username/password combination. Next, set the switch hostname and domain name because the private/public keys will be created using the hostname.domainname nomenclature. Obviously, it makes sense for the key to be named something representing the system.

Firstly, make sure that you have a hostname other than the default one, which is Switch. Next, add your domain name (this typically matches your FQDN in Windows Active Directory). Then, create the crypto key that will be used for encryption. The modulus will be the length of the keys you want to use, in the range from 360 to 2048, with the latter being the most secure; 1024 and above is considered secure. At this point, SSH is enabled on the switch. There are a few maintenance commands you should enter as well. The ip ssh time-out 60 will time out any SSH connection that has been idle for 60 seconds. The ip ssh authentication-retries 2 will reset the initial SSH connection if authentication fails two times. This will not prevent the user from establishing a new connection and retrying authentication. This process is illustrated in the output below:

Switch(config)#hostname SwitchOne
SwitchOne(config)#ip domain-name mydomain.com
SwitchOne(config)#crypto key generate rsa
Enter modulus: 1024
SwitchOne(config)#ip ssh time-out 60
SwitchOne(config)#ip ssh authentication-retries 2

You can optionally enable SSH version 2 with the ip ssh version 2 command. Let’s take a look at one of the keys. In this example, the key was generated for HTTPS. Because the key was automatically generated when enabling HTTPS, the name will also be auto-generated.

firewall#show crypto key mypubkey rsa
Key name: HTTPS_SS_CERT_KEYPAIR.server
Temporary key
Usage: Encryption Key
Key is not exportable.
Key Data:
306C300D 06092A86 4886F70D 01010105 00035B00 30580251 00C41B63 8EF294A1
DC0F7378 7EF410F6 6254750F 475DAD71 4E1CD15E 1D9086A8 BD175433 1302F403
2FD22F82 C311769F 9C75B7D2 1E50D315 EFA0E940 DF44AD5A F717BF17 A3CEDBE1
A6A2D601 45F313B6 6B020301 0001

To verify that SSH is enabled on the switch, enter the following command:

Switch#show ip ssh
SSH Enabled – version 1.99
Authentication timeout: 120 secs; Authentication retries: 2
Switch#

If you have SSH enabled, you should probably disable Telnet and HTTP. When you enter the transport input command, any protocol entered after it is allowed. Any protocol not entered is not allowed. In the output below, you can see that only SSH is allowed:

line vty 0 15
transport input ssh

The following output shows that both SSH and Telnet are allowed:

line vty 0 15
transport input ssh telnet

You can disable HTTP access with one simple command:

Switch(config)#no ip http server

To view the status of the HTTP server on the switch:

Switch#show ip http server status
HTTP server status: Disabled
HTTP server port: 80
HTTP server authentication method: enable
HTTP server access class: 0
HTTP server base path: flash:html
Maximum number of concurrent server connections allowed: 16
Server idle time-out: 180 seconds
Server life time-out: 180 seconds
Maximum number of requests allowed on a connection: 25
HTTP server active session modules: ALL
HTTP secure server capability: Present
HTTP secure server status: Enabled
HTTP secure server port: 443
HTTP secure server ciphersuite: 3des-ede-cbc-sha des-cbc-sha rc4-128-md5 rc4-12
HTTP secure server client authentication: Disabled
HTTP secure server trustpoint:
HTTP secure server active session modules: ALL

You could also apply an access control list to the vty lines and permit only SSH. We will cover access control lists on Day 9.

Set an Enable Secret Password

Global Configuration mode will permit a user to configure the switch or router and erase configurations, as well as reset passwords. You must protect this mode by setting a password or a secret password (which actually prevents the user from getting past User mode). The secret password will be displayed on the routers running the configuration file, whereas the enable secret password will be encrypted.

I’ve already mentioned that you can actually have both a password and an enable secret password on your router and switch, but this can cause confusion. Just set the enable secret password. The configuration file below illustrates how to issue a command without dropping back to Privileged mode by typing do before the command:

Switch1(config)#enable password cisco
Switch1(config)#do show run
Building configuration…
Current configuration: 1144 bytes
hostname Switch1
enable password cisco

Farai says – “You can encrypt the enable secret password with the service password-encryption command.”

You can erase most lines of configuration by issuing it again with the word no before the command. It is also worth noting that, as Farai says, you can issue a service password-encryption command, but this only offers weak (level 7) encryption, whereas below, the secret password has strong (MD5) encryption :

Switch1(config)#no enable password
Switch1(config)#enable secret cisco
Switch1(config)#do show run
Building configuration…
Current configuration: 1169 bytes
hostname Switch1
enable secret 5 $1$mERr$hx5rVt7rPNoS4wqbXKX7m0 [strong level 5 password]

Services

You should always disable the services you are not going to use. Cisco has done a good job by not enabling insecure or rarely used services/protocols; however, you might want to disable them just to make sure. There are some services that are helpful as well. The majority of services are found under the command service in Global Configuration mode.

Switch(config)# service ?
compress-config Compress the configuration file
config TFTP load config files
counters Control aging of interface counters
dhcp Enable DHCP server and relay agent
disable-ip-fast-frag Disable IP particle-based fast fragmentation
exec-callback Enable exec callback
exec-wait Delay EXEC startup on noisy lines
finger Allow responses to finger requests
hide-telnet-addresses Hide destination addresses in telnet command
linenumber enable line number banner for each exec
nagle Enable Nagle’s congestion control algorithm
old-slip-prompts Allow old scripts to operate with slip/ppp
pad Enable PAD commands
password-encryption Encrypt system passwords
password-recovery Disable password recovery
prompt Enable mode specific prompt
pt-vty-logging Log significant VTY-Async events
sequence-numbers Stamp logger messages with a sequence number
slave-log Enable log capability of slave IPs
tcp-keepalives-in Generate keepalives on idle incoming network
connections
tcp-keepalives-out Generate keepalives on idle outgoing network
connections
tcp-small-servers Enable small TCP servers (e.g., ECHO)
telnet-zeroidle Set TCP window 0 when connection is idle
timestamps Timestamp debug/log messages
udp-small-servers Enable small UDP servers (e.g., ECHO)

Generally speaking, the most common services to enable/disable are listed below. The description of the service is in brackets [ ].

  • no service pad [packet assembler/disassembler, used in asynchronous networking; rarely used]
  • no service config [prevents the switch from getting its config file from the network]
  • no service finger [disables the finger server; rarely used]
  • no ip icmp redirect [prevents ICMP redirects, which can be used for router poisoning]
  • no ip finger [another way to disable the finger service]
  • no ip gratuitous-arps [disable to prevent man-in-the-middle attacks]
  • no ip source-route [disables user-provided hop-by-hop routing to destination]
  • service sequence-numbers [in each log entry, gives it a number and increases sequentially]
  • service tcp-keepalives-in [prevents the router from keeping hung management sessions open]
  • service tcp-keepalives-out [same as service tcp-keepalives-in]
  • no service udp-small-servers [disables echo, chargen, discard, daytime; rarely used]
  • no service tcp-small-servers [disables echo, chargen, discard; rarely used]
  • service timestamps debug datetime localtime show-timezone [timestamps each logged packet (in debug mode) with the date and time, using local time, and shows the timezone]
  • service timestamps log datetime localtime show-timezone [timestamps each logged packet (not in debug mode) with the date and time, using local time, and shows the timezone – very useful for observing the log file (especially if the clock is set up correctly) ]

 

Change the Native VLAN

The native VLAN is used by the switch to carry specific protocol traffic, such as Cisco Discovery Protocol (CDP), VLAN Trunking Protocol (VTP), Port Aggregation Protocol (PAgP), and Dynamic Trunking Protocol (DTP) information. The default native VLAN is always VLAN 1; however, the native VLAN can be manually changed to any valid VLAN number (except for 0 and 4096, because these are in the reserved range of VLANs).

You can verify the native VLAN with the commands (issued per interface) illustrated in the output below:

Switch#show interfaces FastEthernet0/1 switchport
Name: Fa0/1
Switchport: Enabled
Administrative Mode: trunk
Operational Mode: trunk
Administrative Trunking Encapsulation: dot1q
Operational Trunking Encapsulation: dot1q
Negotiation of Trunking: On
Access Mode VLAN: 1 (default)
Trunking Native Mode VLAN: 1 (default)
Voice VLAN: none

Having ports in VLAN 1 is considered a security vulnerability which allows hackers to gain access to network resources. To mitigate this problem, it is advisable to avoid putting any hosts into VLAN 1. You can also change the native VLAN on all trunk ports to an unused VLAN:

Switch(config-if)#switchport trunk native vlan 888

NOTE: This is one of the key objectives in the CCNA syllabus, so bear it in mind.

You can also prevent native VLAN data from passing on the trunk with the command below:

 

Switch(config-if)#switchport trunk allowed vlan remove 888

Change the Management VLAN

You can also add an IP address to the switch to allow you to Telnet to it for management purposes. This is referred to as a Switch Virtual Interface (SVI). It is a wise precaution to have this management access in a VLAN other than VLAN 1, as shown in the output below:

 

Switch(config)#vlan 3

Switch(config-vlan)#interface vlan3

 

%LINK-5-CHANGED: Interface Vlan3, changed state to up

Switch(config-if)#ip address 192.168.1.1 255.255.255.0

Turn Off CDP

Cisco Discovery Protocol (CDP) will be covered later, but for now, you just need to know that it is turned on by default on most routers and switches universally and per interface, and its function is to discover attached Cisco devices. You may not want other Cisco devices to see information about your network devices, so you can turn this off, at least on the devices at the edge of your network which connect to other companies or your ISP.

Farai says – “CDP is not enabled by default on all platforms, such as ASR routers, for example.”

In the output below, you can see how a router connected to my switch is able to see basic information when I issue the show cdp neighbor detail command:

Router#show cdp neighbor detail

Device ID: Switch1
Entry address(es):
Platform: Cisco 2960, Capabilities: Switch
Interface: FastEthernet0/0, Port ID (outgoing port): FastEthernet0/2
Holdtime: 176
Version :

Cisco Internetwork Operating System Software
IOS ™ C2960 Software (C2960-I6Q4L2-M), Version 12.1(22)EA4, RELEASE SOFTWARE(fc1)
Copyright (c) 1986-2005 by Cisco Systems, Inc.
Compiled Wed 18-May-05 22:31 by jharirba
advertisement version: 2
Duplex: full

Router#

The command below will turn off CDP for the entire device:

Switch1(config)#no cdp run

To turn off CDP for a particular interface, issue the following command:

Switch1(config)#int FastEthernet0/2

Switch1(config-if)#no cdp enable

Add a Banner Message

A banner message will show when a user logs in to your router or switch. It won’t offer any actual security but it will display a warning message of your choice. In the configuration below, I chose the letter Y as my delimiting character, which tells the router that I’ve finished typing my message:

Switch1(config)#banner motd Y
Enter TEXT message.  End with the character ‘Y’.

KEEP OUT OR YOU WILL REGRET IT Y

Switch1(config)#

When I Telnet to the switch from my router, I can see the banner message. The mistake was choosing Y as the delimiting character because it cuts off my message:

Router#telnet 192.168.1.3

Trying 192.168.1.3 …Open

KEEP OUT OR

Banner messages can be:

  • Shown before the user sees the login prompt – MOTD (message of the day)
  • Shown before the user sees the login prompt – Login
  • Shown to the user after the login prompt – Exec (used when you want to hide information from unauthorised users)

Banner inputs as part of the labs in this book. I suggest that you learn to configure all three types and test them by logging in to the router. You will have different choices depending upon your platform and IOS:

Router(config)#banner ?

LINE            c banner-text c, where ‘c’ is a delimiting character

exec            Set EXEC process creation banner

incoming        Set incoming terminal line banner

login           Set login banner

motd            Set Message of the Day banner

prompt-timeout  Set Message for login authentication timeout

slip-ppp        Set Message for SLIP/PPP

Set a VTP Password

VTP ensures that accurate VLAN information is passed between the switches on your network. In order to protect these updates, you should add a VTP password on your switch (it should match on all switches in the VTP domain), as illustrated in the output below:

Switch1(config)#vtp domain 60days
Changing VTP domain name from NULL to 60days
Switch1(config)#vtp password cisco
Setting device VLAN database password to cisco
Switch1(config)#

Restrict VLAN Information

By default, switches permit all VLANs across the trunk links. You can change this by specifying which VLANs can pass, as illustrated in the following output:

Switch1(config)#int FastEthernet0/4
Switch1(config-if)#switchport mode trunk
Switch1(config-if)#switchport trunk allowed vlan ?
WORD    VLAN IDs of the allowed VLANs when this port is in trunking mode
add     add VLANs to the current list
all     all VLANs
except  all VLANs except the following
none    no VLANs
remove  remove VLANs from the current list

Switch1(config-if)#switchport trunk allowed vlan 7-12

Switch1#show interface trunk
Port        Mode         Encapsulation  Status        Native vlan
Fa0/4       on           802.1q         trunking      1

Port        Vlans allowed on trunk
Fa0/4       7-12

Error Disable Recovery

A series of events can cause Cisco switches to put their ports into a special disabled mode called err-disabled. This basically means that a particular port has been disabled (shut down) due to an error. This error can have multiple causes, one of the most common being a violation of a port security policy. This is a normal behaviour when an unauthorised user tries to connect to a switch port and it prevents rogue devices from accessing the network.

An err-disabled port might look something like this:

Switch# show interface f0/1

FastEthernet0/1 is down, line protocol is down [err-disabled]

…..

In order to re-activate an err-disabled interface, manual intervention is necessary via issuing the shutdown and no shutdown commands on the interface (referred to a bouncing the port by network engineers). However, some situations might require automatic recovery of the original port state instead of waiting for an administrator to manually enable the port. The err-disable recovery mode functions by configuring the switch to automatically re-enable an err-disabled port after a certain period, based on the event that generated the failure. This provides granularity in deciding which events can be monitored by the err-disable recovery function.

The command to do this is the errdisable recovery cause, entered under Global Router Configuration mode:

Switch(config)#errdisable recovery cause ?

  all        Enable timer to recover from all causes

  bpduguard  Enable timer to recover from bpdu-guard error disable state

  dtp-flap   Enable timer to recover from dtp-flap error disable state

  link-flap  Enable timer to recover from link-flap error disable state

  pagp-flap  Enable timer to recover from pagp-flap error disable state

  rootguard  Enable timer to recover from root-guard error disable state

  udld       Enable timer to recover from udld error disable state

……

The errdisable recovery cause command can vary based on the device model, but the most common parameters are:

  • all
  • arp-inspection
  • bpduguard
  • dhcp-rate-limit
  • link-flap
  • psecure-violation
  • security-violation
  • storm-control
  • udld

The time after which the port is automatically restored is 300 seconds by default on most platforms, but this can be manually configured with the errdisable recovery interval global configuration command:

Switch(config)#errdisable recovery interval ?

<30-86400>  timer-interval(sec)

The show errdisable recovery command will provide information about the active features monitored by the err-disable recovery function and about the interfaces being monitored, including the time left until the interface is enabled.

Switch#show errdisable recovery

ErrDisable Reason            Timer Status

—————–            ————–

arp-inspection               Disabled

bpduguard                    Disabled

channel-misconfig            Disabled

dhcp-rate-limit              Disabled

dtp-flap                     Disabled

gbic-invalid                 Disabled

inline-power                 Disabled

l2ptguard                    Disabled

link-flap                    Disabled

mac-limit                    Disabled

link-monitor-failure         Disabled

loopback                     Disabled

oam-remote-failure           Disabled

pagp-flap                    Disabled

port-mode-failure            Disabled

psecure-violation            Enabled

security-violation           Disabled

sfp-config-mismatch          Disabled

storm-control                Disabled

udld                         Disabled

unicast-flood                Disabled

vmps                         Disabled

 

Timer interval: 300 seconds

 

Interfaces that will be enabled at the next timeout:

 

Interface       Errdisable reason       Time left(sec)

———       —————–       ————–

Fa0/0           psecure-violation       193

 

External Authentication Methods

Rather than store usernames and passwords locally, you can use a server which typically runs either AAA or TACACS+. The advantage to this method is not having to manually enter usernames and passwords on each individual router and switch. Instead, they are stored on the server database.

TACACS+ stands for Terminal Access Controller Access Control System Plus. It is a Cisco proprietary protocol that uses TCP port 49. TACACS+ provides access control for network devices, including routers, and network access servers via one or more centralised servers.

RADIUS stands for Remote Authentication Dial-In User Service. It is a system of distributed network security that secures remote access to the network and a client/server protocol that uses UDP.  RADIUS is open standard.

If you have TACACS+ or RADIUS, you may wish to enable Authentication, Authorization, and Accounting (AAA). AAA is installed on a server and monitors a database of user accounts for the network. Users’ access, protocols, connections, and disconnect reasons, as well as many other features, can be monitored.

Routers and switches can be configured to query the server when a user attempts to log in. The server then validates the user. You should not be expected to configure these protocols for the CCNA exam.

Router Clock and NTP

The time on a switch is often overlooked; however, it is very important. When you encounter security violations, SNMP traps, or logging of events, it uses a timestamp. If the time on your switch is incorrect, it will be difficult figuring out when the event happened. For example, let’s take a look at the switch below and check the time:

Switch#show clock
*23:09:45.773 UTC Tue Mar 2 1993

The time is not accurate, so let’s change it. But first, let’s set some attributes:

clock timezone CST -6
clock summer-time CDT recurring
clock summer-time CST recurring 2 Sun Mar 2:00 1 Sun Nov 2:00

First, let’s set the time zone. I’m in the Central time zone and I’m 6 hours off of GMT. Next, tell the switch that summertime (the time change) is recurring. Finally, set what the summertime time really is. Now, let’s set the time and date:

Switch#clock set 14:55:05 June 19 2007
Switch#
1d23h: %SYS-6-CLOCKUPDATE: System clock has been updated from 17:26:01 CST
Tue Mar 2 1993 to 14:55:05 CST Tue Jun 19 2007, configured from console by console.
Switch#show clock
14:55:13.858 CST Tue Jun 19 2007

Notice that the clock was set in Enable mode, not Configuration mode. Alternatively, you can use NTP. NTP stands for Network Time Protocol and it allows you to synchronise your switch’s clock to an atomic clock, ensuring very accurate time.

Switch(config)#ntp server 134.84.84.84 prefer
Switch(config)#ntp server 209.184.112.199

You can see whether your clock has synchronised with your NTP sources with the following two commands:

Switch#show ntp associations
Switch#show ntp status

We will cover NTP in more detail on Day 40.

Prev

Next

About Us

This is a free bonus site for members of www.howtonetwork.com

Copyright

The content on this copyright Reality Press Ltd.
Copyright Reality Press Ltd.