Router Basics
Router mode configuration
1. User EXEC Mode:
- Purpose: This is the default mode when you connect to the router. It provides limited access to view system status.
- Access: Enter the router's CLI by using a console cable or connecting via SSH/Telnet. You'll see a prompt ending with
>. - Command to Enter:
enable
shellRouter> enable
Password: [Enter password if required]
Router#
2. Privileged EXEC Mode:
- Purpose: In this mode, you have access to all router commands and can view or change the configuration.
- Access: You enter privileged EXEC mode by typing
enablein user EXEC mode. You'll see a prompt ending with#. - Command to Enter:
configure terminalor simplyconf t
arduinoRouter# configure terminal
Router(config)#
3. Global Configuration Mode:
- Purpose: This mode allows you to configure global settings for the router.
- Access: From privileged EXEC mode, use the
configure terminalorconf tcommand. - Example:
scssRouter(config)# hostname MyRouter
MyRouter(config)#
4. Interface Configuration Mode:
- Purpose: You can configure individual router interfaces (e.g., Ethernet, serial) in this mode.
- Access: From global configuration mode, use the
interfacecommand followed by the interface type and number (e.g.,interface GigabitEthernet0/0). - Example:
scssMyRouter(config)# interface GigabitEthernet0/0
MyRouter(config-if)#
5. Subinterface Configuration Mode (for VLANs):
- Purpose: When configuring VLANs or subinterfaces, you enter this mode.
- Access: From global configuration mode, use the
interfacecommand followed by the subinterface type and number (e.g.,interface GigabitEthernet0/0.10for subinterface VLAN 10). - Example:
scssMyRouter(config)# interface GigabitEthernet0/0.10
MyRouter(config-subif)#
6. Line Configuration Mode:
- Purpose: You use this mode to configure specific lines (e.g., console, Telnet, SSH) for user access.
- Access: From global configuration mode, use the
linecommand followed by the line type and number (e.g.,line console 0). - Example:
arduinoMyRouter(config)# line console 0
MyRouter(config-line)#
7. Router Configuration Mode (for routing protocols):
- Purpose: When configuring routing protocols like OSPF or EIGRP, you enter this mode.
- Access: From global configuration mode, use the appropriate routing protocol command (e.g.,
router ospf 1). - Example:
scssMyRouter(config)# router ospf 1
MyRouter(config-router)#
8. Access Control List (ACL) Configuration Mode:
- Purpose: This mode allows you to create and configure ACLs for traffic filtering.
- Access: From global configuration mode, use the
access-listcommand followed by the ACL number. - Example:
Configuring a router involves entering different configuration modes to set up various aspects of the router's operation. The configuration process typically involves moving through different modes, from the user EXEC mode to the privileged EXEC mode and then to specific configuration modes. Below is an overview of the common configuration modes in a Cisco router and how to access and navigate them:
1. User EXEC Mode:
- Purpose: This is the default mode when you connect to the router. It provides limited access to view system status.
- Access: Enter the router's CLI by using a console cable or connecting via SSH/Telnet. You'll see a prompt ending with
>. - Command to Enter:
enable
shellRouter> enable
Password: [Enter password if required]
Router#
2. Privileged EXEC Mode:
- Purpose: In this mode, you have access to all router commands and can view or change the configuration.
- Access: You enter privileged EXEC mode by typing
enablein user EXEC mode. You'll see a prompt ending with#. - Command to Enter:
configure terminalor simplyconf t
arduinoRouter# configure terminal
Router(config)#
3. Global Configuration Mode:
- Purpose: This mode allows you to configure global settings for the router.
- Access: From privileged EXEC mode, use the
configure terminalorconf tcommand. - Example:
scssRouter(config)# hostname MyRouter
MyRouter(config)#
4. Interface Configuration Mode:
- Purpose: You can configure individual router interfaces (e.g., Ethernet, serial) in this mode.
- Access: From global configuration mode, use the
interfacecommand followed by the interface type and number (e.g.,interface GigabitEthernet0/0). - Example:
scssMyRouter(config)# interface GigabitEthernet0/0
MyRouter(config-if)#
5. Subinterface Configuration Mode (for VLANs):
- Purpose: When configuring VLANs or subinterfaces, you enter this mode.
- Access: From global configuration mode, use the
interfacecommand followed by the subinterface type and number (e.g.,interface GigabitEthernet0/0.10for subinterface VLAN 10). - Example:
scssMyRouter(config)# interface GigabitEthernet0/0.10
MyRouter(config-subif)#
6. Line Configuration Mode:
- Purpose: You use this mode to configure specific lines (e.g., console, Telnet, SSH) for user access.
- Access: From global configuration mode, use the
linecommand followed by the line type and number (e.g.,line console 0). - Example:
arduinoMyRouter(config)# line console 0
MyRouter(config-line)#
7. Router Configuration Mode (for routing protocols):
- Purpose: When configuring routing protocols like OSPF or EIGRP, you enter this mode.
- Access: From global configuration mode, use the appropriate routing protocol command (e.g.,
router ospf 1). - Example:
scssMyRouter(config)# router ospf 1
MyRouter(config-router)#
8. Access Control List (ACL) Configuration Mode:
- Purpose: This mode allows you to create and configure ACLs for traffic filtering.
- Access: From global configuration mode, use the
access-listcommand followed by the ACL number. - Example:
arduinoMyRouter(config)# access-list 101 permit tcp any host 192.168.1.2 eq 80
MyRouter(config)# interface GigabitEthernet0/0
MyRouter(config-if)# ip access-group 101 inAccess Privileged EXEC Mode: If you are not already in privileged EXEC mode, start by accessing it. You should see a router prompt ending with
#. You can enter this mode by typingenableand providing the required password if necessary.shellRouter> enable Password: [Enter password if required] Router#Change the Hostname: In privileged EXEC mode, use the
configure terminalorconf tcommand to enter global configuration mode. Then, use thehostnamecommand followed by the new hostname you want to set.arduinoRouter# configure terminal Router(config)# hostname NewHostnameReplace
NewHostnamewith the desired hostname for your router.Exit Configuration Mode: After changing the hostname, you can exit the configuration mode and return to privileged EXEC mode by typing
exitor pressingCtrl-Z.shellRouter(config)# exit Router#Save the Configuration: To ensure that the new hostname persists across reboots, save the configuration to the router's startup-config. Use the
write memorycommand or thecopy running-config startup-configcommand.arduinoRouter# write memory
Access Privileged EXEC Mode: If you are not already in privileged EXEC mode, start by accessing it. You should see a router prompt ending with
#. You can enter this mode by typingenableand providing the required password if necessary.shellRouter> enable Password: [Enter password if required] Router#Change the Hostname: In privileged EXEC mode, use the
configure terminalorconf tcommand to enter global configuration mode. Then, use thehostnamecommand followed by the new hostname you want to set.arduinoRouter# configure terminal Router(config)# hostname NewHostnameReplace
NewHostnamewith the desired hostname for your router.Exit Configuration Mode: After changing the hostname, you can exit the configuration mode and return to privileged EXEC mode by typing
exitor pressingCtrl-Z.shellRouter(config)# exit Router#Save the Configuration: To ensure that the new hostname persists across reboots, save the configuration to the router's startup-config. Use the
write memorycommand or thecopy running-config startup-configcommand.arduinoRouter# write memory
Access Privileged EXEC Mode: If you are not already in privileged EXEC mode, start by accessing it. You should see a router prompt ending with
#. You can enter this mode by typingenableand providing the required password if necessary.shellRouter> enable Password: [Enter password if required] Router#Change the Hostname: In privileged EXEC mode, use the
configure terminalorconf tcommand to enter global configuration mode. Then, use thehostnamecommand followed by the new hostname you want to set.arduinoRouter# configure terminal Router(config)# hostname NewHostnameReplace
NewHostnamewith the desired hostname for your router.Exit Configuration Mode: After changing the hostname, you can exit the configuration mode and return to privileged EXEC mode by typing
exitor pressingCtrl-Z.shellRouter(config)# exit Router#Save the Configuration: To ensure that the new hostname persists across reboots, save the configuration to the router's startup-config. Use the
write memorycommand or thecopy running-config startup-configcommand.arduinoRouter# write memoryRouter Change Password
1. Access Privileged EXEC Mode:
- If you are not already in privileged EXEC mode, access it by typing
enablein user EXEC mode and providing the current enable password if required.
bashRouter> enable Password: [Enter current enable password if required] Router#2. Enter Global Configuration Mode:
- In privileged EXEC mode, use the
configure terminalorconf tcommand to enter global configuration mode.
arduinoRouter# configure terminal Router(config)#3. Change the Enable Password:
- Use the
enable secretcommand followed by the new password to change the enable password. This command sets an encrypted password.
arduinoRouter(config)# enable secret NewPasswordReplace
NewPasswordwith your desired new password.4. Optionally, Change the Enable Password (Legacy Method):
- If you prefer to use the older method to set the enable password, you can use the
enable passwordcommand. Note that this method stores the password in clear text, which is less secure.
arduinoRouter(config)# enable password NewPasswordReplace
NewPasswordwith your desired new password.5. Exit Configuration Mode:
- After changing the password, exit the configuration mode and return to privileged EXEC mode.
shellRouter(config)# exit Router#6. Save the Configuration:
- To save the configuration with the new password, use the
write memorycommand or thecopy running-config startup-configcommand.
arduinoRouter# write memory==========================================
- If you are not already in privileged EXEC mode, access it by typing
Router Password Encrpytion
In Cisco routers, two main types of password encryption are used:
Type 7 Password Encryption:
Cisco routers use a weak encryption algorithm known as "Type 7" to encrypt passwords. This type of encryption is considered weak because it can be relatively easily reversed by attackers who have access to the encrypted password. Therefore, it is not recommended for securing critical passwords.
To configure a Type 7 encrypted password, you can use a command like this:
arduinoRouter(config)# enable secret 7 <encrypted-password>The
<encrypted-password>is the result of running the original password through the Type 7 encryption algorithm. For example, if you wanted to set the enable secret password to "mypassword," you would need to first obtain its Type 7 encrypted form:arduinoRouter(config)# enable secret 7 070C285F4D4A1A1ANote that to view the Type 7 encrypted password, you can use the
show running-configcommand or theshow enable secretcommand. However, it's important to understand that Type 7 encryption is not secure for critical passwords.
Type 5 Password Encryption (MD5):
To enhance security, it is recommended to use Type 5 password encryption, which employs the MD5 (Message Digest 5) hashing algorithm. MD5 is significantly more secure than Type 7 encryption.
To configure a Type 5 encrypted password, you can use a command like this:
arduinoRouter(config)# enable secret <plaintext-password>The
<plaintext-password>is the actual password in plain text, and the router will automatically hash it using MD5 for storage. For example:arduinoRouter(config)# enable secret mysecurepasswordThe password will be stored securely in its hashed format in the router's configuration.
==========================================================
Router Simple Interface Configuration
1. Access the Router's CLI:
- Connect to the router using a console cable or via SSH/Telnet. Access the router's command-line interface (CLI). You should start in user EXEC mode, which is indicated by a prompt ending with
>. You can enter privileged EXEC mode using theenablecommand and providing the required password if prompted.
shellRouter> enable Password: [Enter password if required] Router#2. Enter Global Configuration Mode:
- In privileged EXEC mode, use the
configure terminalorconf tcommand to enter global configuration mode. This mode allows you to configure various router settings, including interfaces.
arduinoRouter# configure terminal Router(config)#3. Select the Interface:
- Use the
interfacecommand followed by the interface type and number to select the specific interface you want to configure. For example, to configure GigabitEthernet interface 0/0:
scssRouter(config)# interface GigabitEthernet0/0 Router(config-if)#4. Configure IP Address and Subnet Mask:
- Assign an IP address and subnet mask to the interface using the
ip addresscommand. For example:
arduinoRouter(config-if)# ip address 192.168.1.1 255.255.255.0- Replace
192.168.1.1with the desired IP address for the interface and255.255.255.0with the appropriate subnet mask.
5. Enable the Interface:
- Use the
no shutdowncommand to enable the interface.
arduinoRouter(config-if)# no shutdown6. Exit Configuration Mode:
- After configuring the interface, exit the configuration mode to return to privileged EXEC mode.
scssRouter(config-if)# exit Router(config)#7. Save the Configuration:
- To ensure that your configuration persists across reboots, save the configuration to the router's startup-config file using the
write memorycommand.
arduinoRouter(config)# end Router# write memoryYour router's Ethernet interface (in this example, GigabitEthernet0/0) is now configured with the specified IP address and subnet mask.
- Connect to the router using a console cable or via SSH/Telnet. Access the router's command-line interface (CLI). You should start in user EXEC mode, which is indicated by a prompt ending with
=====================================================
Router Banner Configuration
Here's how to configure a few common banners on a Cisco router using Cisco IOS commands:
1. MOTD (Message of the Day) Banner:
The MOTD banner is typically displayed to users when they log in to the router. It's often used to provide a welcome message or legal disclaimer.
bashRouter(config)# banner motd # Enter TEXT message. End with the character '#'. This is the MOTD banner. Unauthorized access is prohibited. #In the above example, the
#character is used as a delimiter to start and end the banner message. You can use any character that is not part of your banner message.2. Login Banner:
The login banner is displayed before the username and password prompts when a user logs in to the router. It's often used to warn unauthorized users about access restrictions.
bashRouter(config)# banner login # Enter TEXT message. End with the character '#'. Unauthorized access is strictly prohibited. #3. Exec Banner (Exec-Timeout Banner):
The exec banner is displayed to users after a period of inactivity (exec-timeout) when they are logged in to the router. It can be used to remind users to log out after use.
bashRouter(config)# line console 0 Router(config-line)# exec-timeout 15 0 Router(config-line)# login Router(config-line)# exit Router(config)# banner exec # Enter TEXT message. End with the character '#'. Session will be terminated due to inactivity. #In the above example, we set an exec-timeout of 15 minutes with no seconds, which means the session will not automatically time out due to inactivity. However, when the user reaches 15 minutes of inactivity and tries to execute a command, they will see the exec banner.
4. Configuring a Message-of-the-Day Banner for SSH:
If you want to display a banner to users connecting via SSH, you can configure an SSH banner as follows:
bashRouter(config)# banner login # Enter TEXT message. End with the character '#'. Welcome to the secure SSH access. Unauthorized access is prohibited. # Router(config)# line vty 0 15 Router(config-line)# login local Router(config-line)# transport input ssh Router(config-line)# exitIn this example, we've configured a login banner and ensured that SSH access is enabled on the VTY lines (0 to 15).
===================================
Router Clock Configuration
1. Access the Router's CLI:
- Connect to the router using a console cable, SSH, or Telnet, and access the router's command-line interface (CLI). You should start in user EXEC mode, which is indicated by a prompt ending with
>. You can enter privileged EXEC mode using theenablecommand and providing the required password if prompted.
bashRouter> enable Password: [Enter password if required] Router#2. Configure the Time Zone:
- Before setting the clock, you should configure the router's time zone. The time zone is specified in hours and minutes ahead or behind Coordinated Universal Time (UTC). You can use the
clock timezonecommand to set the time zone.
bashRouter(config)# clock timezone GMT 0In the above example, we set the time zone to GMT (UTC) with an offset of 0 hours. Adjust the offset according to your time zone.
3. Set the Clock Manually:
- You can manually set the router's clock using the
clock setcommand. Specify the current time and date in the formathh:mm:ss month day year. For example:
bashRouter(config)# clock set 15:30:00 Sep 15 2023This sets the router's clock to 3:30 PM on September 15, 2023.
4. Save the Configuration:
- To ensure that the configured time persists across router reboots, save the configuration to the router's startup-config file using the
write memorycommand.
bashRouter(config)# end Router# write memory5. Verify the Clock Configuration:
- You can verify the clock configuration by checking the router's current time and date using the
show clockcommand.
bashRouter# show clockThe router should display the configured time and date.
6. Optional: Configure NTP (Network Time Protocol):
- For more accurate and automatic time synchronization, consider configuring the router to use NTP to synchronize its clock with an NTP server. NTP is especially useful in larger networks.
Here's a basic example of how to configure NTP:
bashRouter(config)# ntp server <ntp-server-ip-address>Replace
<ntp-server-ip-address>with the IP address of an NTP server. You can find publicly available NTP servers on the internet or use your organization's internal NTP server if available.- Connect to the router using a console cable, SSH, or Telnet, and access the router's command-line interface (CLI). You should start in user EXEC mode, which is indicated by a prompt ending with
==========================================================
Router Mapping a Local Hostname to Remote IP Address
1. Access the Router's CLI:
- Connect to the router using a console cable, SSH, or Telnet, and access the router's command-line interface (CLI) in privileged EXEC mode.
2. Configure DNS Resolution (Option 1 - Using a DNS Server):
- If you have a DNS server in your network, you can configure the router to use it for DNS resolution. This is the most common method for mapping hostnames to IP addresses.
bashRouter(config)# ip name-server <DNS-server-IP>Replace
<DNS-server-IP>with the IP address of your DNS server. You can specify multiple DNS servers if needed.3. Configure DNS Resolution (Option 2 - Using Embedded DNS Server):
- Some Cisco routers have an embedded DNS server that can be configured to resolve hostnames. You can enable it and add static mappings.
bashRouter(config)# ip dns server Router(config)# ip host <hostname> <IP-address>Replace
<hostname>with the desired hostname and<IP-address>with the remote IP address to which you want to map the hostname.4. Verify DNS Configuration:
- To verify your DNS configuration, you can use the
show ip name-servercommand to see the configured DNS servers, or useshow hoststo see the configured hostname-to-IP mappings.
bashRouter# show ip name-server Router# show hosts5. Test DNS Resolution:
- You can now test the DNS resolution by trying to resolve the hostname to an IP address. For example:
bashRouter# ping <hostname>If DNS resolution is configured correctly, you should see the IP address associated with the hostname.
6. Save the Configuration:
- To ensure that your DNS configuration persists across router reboots, save the configuration to the router's startup-config file using the
write memorycommand.
bashRouter# write memoryThis configuration allows you to map a local hostname to remote IP addresses using DNS resolution. Users in your network can then use the hostname to access remote devices without needing to remember the IP addresses.
=========================
Saving and Erasing Router Configuration
Saving the Configuration:
Access the Router's CLI:
- Connect to the router using a console cable, SSH, or Telnet, and access the router's command-line interface (CLI). You should start in user EXEC mode, which is indicated by a prompt ending with
>. You can enter privileged EXEC mode using theenablecommand and providing the required password if prompted.
bashRouter> enable Password: [Enter password if required] Router#- Connect to the router using a console cable, SSH, or Telnet, and access the router's command-line interface (CLI). You should start in user EXEC mode, which is indicated by a prompt ending with
Save the Configuration:
- To save the running configuration to the router's startup configuration file, use the
write memoryorcopy running-config startup-configcommand.
bashRouter# write memoryor
bashRouter# copy running-config startup-configBoth commands accomplish the same task: they save the current running configuration to the NVRAM (Non-Volatile RAM), which is where the startup configuration is stored. The router will now boot up with the saved configuration the next time it is restarted.
- To save the running configuration to the router's startup configuration file, use the
Erasing the Configuration:
Erasing the configuration should be done with caution, as it resets the router to its factory default settings. If you need to erase the configuration, follow these steps:
Access the Router's CLI:
- Connect to the router's CLI as explained in the previous section.
Enter Global Configuration Mode:
- Use the
configure terminalorconf tcommand to enter global configuration mode.
bashRouter# configure terminal Router(config)#- Use the
Erase the Configuration:
- To erase the entire configuration, including all settings and passwords, use the
erase startup-configorwrite erasecommand. You will be prompted to confirm this action.
bashRouter(config)# erase startup-configor
bashRouter(config)# write erase- To erase the entire configuration, including all settings and passwords, use the
Reload the Router:
- After erasing the configuration, you should reload (reboot) the router for the changes to take effect.
bashRouter(config)# exit Router# reloadThe router will now boot up with its factory default settings. You'll need to reconfigure it from scratch.
===============================
Router show Commands
Here are some commonly used show commands on a router, along with their descriptions:
show running-config:- Description: This command displays the router's current running configuration, which includes all the settings and configurations currently in use. It shows how the router is currently configured.
show startup-config:- Description: This command displays the contents of the router's startup configuration, which is the configuration that will be used upon the next reboot. It can be used to compare the current running configuration with the saved startup configuration.
show interfaces:- Description: This command provides detailed information about all the router's interfaces, including their status (up or down), IP addresses, MAC addresses, and statistics like input and output errors.
show ip route:- Description: This command displays the router's IP routing table. It shows the routes the router knows about, including directly connected networks and routes learned from routing protocols.
show version:- Description: This command provides information about the router's hardware, software version, uptime, and configuration register settings. It's useful for identifying the router model and software version.
show arp:- Description: This command displays the router's ARP (Address Resolution Protocol) table. It shows the mappings between IP addresses and MAC addresses of devices in the local network.
show access-lists:- Description: This command displays the router's configured access control lists (ACLs). It shows the rules for filtering traffic based on source and destination addresses, ports, and protocols.
show cdp neighbors:- Description: If CDP (Cisco Discovery Protocol) is enabled, this command shows information about neighboring Cisco devices connected to the router's interfaces. It includes details like the device's hostname and interface.
show ip interface brief:- Description: This command provides a brief overview of the router's IP interfaces, including their IP addresses, status, and protocol (e.g., up/up, down/down).
show logging:- Description: This command displays the router's system log messages. It can be used to check for any system events, errors, or warnings that have been logged.
show running-config | section <keyword>:- Description: This command allows you to filter the running configuration and display only the sections that contain the specified keyword. It's helpful for quickly finding relevant configuration sections.
show clock:- Description: This command displays the router's current date and time, as configured on the router. It's useful for verifying the router's time settings.
- ==========================================================Router Exec Timeout
1. Access the Router's CLI:
- Connect to the router using a console cable, SSH, or Telnet, and access the router's command-line interface (CLI). You should start in user EXEC mode, which is indicated by a prompt ending with
>. You can enter privileged EXEC mode using theenablecommand and providing the required password if prompted.
bashRouter> enable Password: [Enter password if required] Router#2. Enter Line Configuration Mode:
- To configure the execution timeout for a specific line (e.g., console, VTY), enter line configuration mode. For example, to configure the console line:
bashRouter# configure terminal Router(config)# Router(config)# line console 0 Router(config-line)#3. Configure the Execution Timeout:
- Use the
exec-timeoutcommand followed by the timeout values to set the execution timeout. The command has two timeout values: the first specifies the timeout for user EXEC mode, and the second specifies the timeout for privileged EXEC mode.
bashRouter(config-line)# exec-timeout <minutes> <seconds>Replace
<minutes>with the desired number of minutes and<seconds>with the desired number of seconds. For example, to set an execution timeout of 15 minutes and 0 seconds:bashRouter(config-line)# exec-timeout 15 0This configuration means that if a user's session remains idle for 15 minutes, the session will be automatically disconnected.
4. Exit Configuration Mode:
- After configuring the execution timeout, exit the line configuration mode and return to global configuration mode.
bashRouter(config-line)# exit Router(config)#5. Save the Configuration:
- To ensure that your configuration persists across router reboots, save the configuration to the router's startup-config file using the
write memorycommand.
bashRouter(config)# end Router# write memoryWith the execution timeout configured, users who are inactive for the specified duration will be automatically logged out of their CLI session
- Connect to the router using a console cable, SSH, or Telnet, and access the router's command-line interface (CLI). You should start in user EXEC mode, which is indicated by a prompt ending with
============================================
Prashant Shrivastava
Comments
Post a Comment