Open In App

Switch Concepts and Configuration

A switch is a discrete piece of hardware that connects various computers to a single local area network (LAN). In the OSI model, network switches function at layer 2 (Data link layer).

Switching

Messages are sent over the network of transmission media when a person uses the internet or another computer network from a location other than their immediate area. Switching is the term used to describe this method of moving data between computer networks.



Ethernet

Devices connected to the same Ethernet segment typically use this sort of communication on LAN networks to listen to the network media to determine whether they can transmit or whether they need to wait. Switches allow several devices to access the media simultaneously while hubs only allow one device to broadcast at once. There are three different methods of message transmission in Ethernet communication: Unicast, Multicast, and Broadcast.

Addressing

Physical addresses, which are frequently MAC addresses, are the type of addressing utilized in Ethernet. The address used to transmit frames is this one. Frames are created when packets are received from the network layer. This entails including details like the source and destination MAC addresses.



MAC Address

Operation modes in Ethernet

There are two modes of operation for Ethernet networks; the duplex decides whether the communication is unidirectional or bidirectional. There are two duplex modes: Half Duplex and Full Duplex.

MAC Address Table

The routing decisions routers make are based on the data in the routing table. Similarly, the switches include an address database. The MAC-Address table is a database that serves as the foundation for how to switch forward frames. This database is used by the switch to identify the source and destination of frames when communicating. Following are the actions that are conducted when a switch wants to forward a frame.

  1. The switch receives the frame from a port.
  2. If the source port from which it received the frame is present, the switch verifies this. It adds the source MAC address to its MAC address table if it doesn’t.
  3. The switch then determines whether its MAC address database contains the target port for the frame. If it does not, it broadcasts the frame to all ports except the one it received the frame on.
  4. The switch adds the MAC address to the MAC-address database when the target node responds, and any further communication with this node will be unicast rather than broadcast.

Configuring the Switch

The many configuration modes included the interface configuration, the global configuration mode, the privileged executive mode, the user executive mode, and several more specific configuration modes. Here, we will set up some of a switch’s fundamental settings, such as:

The configuration topology that we’ll be employing is displayed below.

 

We have 1 switch and 2 hosts in this topology. We’ll use the console wire to set up the switch. Follow the procedures below to create this topology in a packet tracer or a physical lab:

Hostnames, Console & Vty lines, Banners, and Passwords

Contrary to older switches like the catalyst switches, the CISCO IOS is utilized on more contemporary switches like the CISCO 2960 switch, which is the one we are utilizing. In order to specify the majority of the parameters on the SWITCH 1 command line interface, we must switch to global configuration mode. Enter the following commands to access this.

Switch>enable
Switch#configure
terminal

Explanation:

While the second command, “configure terminal,” will provide us access to the global configuration mode, the first command grants access to the privileged access mode.

We must first update the switch’s hostname from “switch” to “SWITCH_1” in the global configuration mode. Entering the command hostname <SWITCH_HOSTNAME> accomplishes this.

The command in our scenario is displayed below.

Switch(config)#hostnameSWITCH_1

The prompt will change from “switch(config)#” to “SWITCH_1(config)#” when this command is run.

The five telnet line settings, including the password, executive timeouts, and logging synchronous, must then be configured. The passwords on both lines are set to “cisco” using the commands below, and the timeouts are set to 15 minutes.

SWITCH_1(config)#line console 0
SWITCH_1(config-line)#password cisco
SWITCH_1(config-line)#login
SWITCH_1(config-line)#logging synchronous
SWITCH_1(config-line)#exec-timeout 15 0
SWITCH_1(config-line)#exit
SWITCH_1(config)#line vty 0 4
SWITCH_1(config-line)#password cisco
SWITCH_1(config-line)#login
SWITCH_1(config-line)#logging synchronous
SWITCH_1(config-line)#exec-timeout 15 0
SWITCH_1(config-line)#exit

Explanation:

The command logging synchronously will stop extraneous messages from popping up on the screen as you type and interfering with the command.

When someone tries to access the switch, a banner with a notice is displayed. We talked about a few of the factors that could influence an administrator’s decision to utilize a banner. In this instance, we’ll use a banner MOTD that has been set up with the command:

Banner motd#<MESSAGE>#

The beginning and conclusion of the message are denoted by the pound sign. In this instance, the message “WARNING. AUTHORIZED ACCESS ONLY!!!” will be used, and it is configured on SWITCH_1 using the command indicated below.

SWITCH_1(config)#Banner 
motd# WARNING. 
AUTHORIZED ACCESS ONLY!!!#

When setting routers, we discovered that an IP address was required to contact the router remotely using vty lines. Similar to a PC, switches require the configuration of an IP address, subnet mask, and default gateway. The IP address is used to control the switch.

We carry out the procedures listed below to configure the management interface.

NOTE: An SVI (Switched Virtual Interface) is configured using the “interface VLAN command”.

Step 1: Construct VLAN 99 as the management VLAN interface. We’ll use the following command:

SWITCH_1(config)#interface vlan 99

Step 2: Use the no shutdown command to activate and make the interface active after giving it an IP address and subnet mask.

SWITCH_1(config-if)#ip address 192.168.99.1 255.255.255.0
SWITCH_1(config-if)#no shutdown
SWITCH_1(config-if)#exit

Step 3: We must attach one of the switch interfaces to the VLAN 99 management VLAN, as demonstrated below. 

SWITCH_1(config)#interface fa0/5
SWITCH_1(config-if)#switchport mode access
SWITCH_1(config-if)#switchport access vlan 99
SWITCH_1(config-if)#end
SWITCH_1#copy runing-config startup-config

The command “IP default-gateway IP address>” is used to set up the IP default gateway so that traffic headed for distant networks can be redirected. This command is executed as illustrated below using the IP address 192.168.1.1 as the default gateway in this situation.

SWITCH_1(config)#ip default-gateway 192.168.1.1

Following this arrangement, all networked devices ought to be able to communicate with one another without further configuration.

Duplex Settings

The duplex mode controls whether communication will be unidirectional or bidirectional. On CISCO switches, the duplex is typically set to auto by default. Accordingly, if one side is using a half-duplex, the port will also be using a half-duplex.

The switch’s ports can be hard-coded to exclusively use a full duplex because that is the recommended option. The required commands are implemented on a switch in the interface configuration mode as shown below.

Switch(config)#interface fastEthernet 0/1
Switch(config-if)#duplex<full>

Port Security

Switches are susceptible to a variety of attacks, including:

One method for defending the switch against such attacks is by using port security. Before the switch is implemented, all ports or interfaces should be secured. The number of valid MAC addresses that can use a port is constrained by port security.

One method of protecting a Cisco switch is port security. The following methods that configuration choices employing port security can secure the switch.

  1. Utilizing statically configured MAC addresses requires hardcoding a specific user node’s MAC address onto each port on a switch to designate that port to a certain user node. This indicates that only equipment with MAC addresses that match those configured can interact. This is a fantastic technique to establish security, however, given the size of the network, configuring the MAC addresses of the clients to the switch may be an administrative nightmare.
  2. A good technique to assure security on a switch is to use dynamic secure MAC addresses. The MAC addresses of the user nodes are specified to be learned and stored by the switch ports.
  3. Sticky MAC addresses can be used to make sure that only MAC addresses that have been dynamically learned can use the switch. Since these addresses are saved to the switch’s running configuration file, they are lost when rebooted.
  4. The maximum number of MAC addresses that can use a specific port can also be specified. This is a reliable method of preventing MAC address spoofing.

Article Tags :