To start up a new Cisco LAN switch, all you have to do is plug in the Ethernet cables and power on the switch. However, you need to perform some basic Cisco router configuration before the basic router will start routing packets. In particular, the router needs to be told what interfaces (and which IP address on each of those interfaces) to use.
Installing Internet Access Routers
Routers play a key role in enterprise networks because they connect the organization’s devices to the internet. Routers support a relatively large number of IOS commands; my quick check found around 5,000 Command Line Interface (CLI) commands. But these commands are not unique to routers; many Cisco routers and switches use the exact same commands. For example, show, vty and enable password all work the same on both routers and switches. Here some other actions that are the same across devices:
- Enable privileged exec mode
- Enter or exit configuration mode using the configure terminal, end and exit commands, and the Ctrl+Z key sequence
- CLI help, command editing, and command recall features
- Setup mode, which guides the user through a set of questions to create a simple initial configuration
- Configuring the console and Telnet and enabling secret passwords
- Configuring the hostname and interface description
- Configuring the SSH encryption keys and login credentials
- Configuring an interface to be administratively disabled (shutdown) or enabled (no shutdown)
- Navigating through different configuration mode contexts using commands like line console 0 and interface
- Configuring Ethernet interfaces using the speed and duplex commands
- Using the debug command to create log messages about certain events, so that any user can monitor those messages using the terminal monitor command
- The startup config (in NVRAM), running config (in RAM), and external servers (like TFTP), along with using the copy command to copy the configuration files and Cisco IOS images
However, a couple of things do work differently with routers than switches, such as the configuration of IP addresses and the CLI, because switches and routers do different things. For example, Cisco Layer 2 switches support the show mac address-table command but not the show ip route command, because that command lists IP routes at Level 3. Cisco routers are Level 3 devices and can do IP routing but not Layer 2 switching, so they support the show ip route command but not the show mac address-table command.
Another difference between Cisco switches and routers is that routers support a much wider variety of interfaces. LAN switches support Ethernet LAN interfaces, while routers support a variety of other types of interfaces, including serial, cable TV and DSL interfaces.
Most Cisco routers have at least one Ethernet interface of some type. Many of those interfaces support multiple speeds. For example, a 10-Mbps Ethernet interface can be configured with the interface Ethernet number command, a 10/100 interface can be configured using the interface fastethernet number command, and a 10/100/1000 interface can be configured with the interface gigabitethernet number command.
Routers refer to interfaces in many commands, first by the type of interface (Ethernet, Fast Ethernet, Serial and so on) and then with a unique number of the router. On routers, the interface numbers might be a single number, two numbers separated by a slash or three numbers separated by slashes. For example:
interface ethernet 0
interface fastEthernet 0/1
interface gigabitethernet 1/0
interface serial 1/1/1
Two commands are commonly used to display the interfaces and their statuses. The show ip interface brief command displays a list with one line per interface, with some basic information, including the interface static IP address and interface status. The show interfaces command lists the interfaces with a large amount of information per interface.
Commands that refer to router interfaces can be significantly shortened. For example, show interfaces fastethernet 0/0 can be entered as sh int fa0/0.
Router Interface IP Addresses
To make a router ready to route IPv4 packets on an interface, the first thing we need to do is enable the interface and assign it an IPv4 address. Note the following:
- Most Cisco router interfaces are disabled by default (are in shutdown state) and should be enabled with the no shutdown
- Cisco routers start to route IP packets only after IP address and mask have been configured.
- Cisco routers route IP packets for any interfaces that are in an up/up state and that have an IP address/mask assigned. (Routers enable IPv4 routing by default due to the default ip routing global configuration mode)
To configure the address and mask, simply use the ip address address mask interface command. Serial interfaces (WAN interfaces) need the same settings as Ethernet interfaces, but they require some additional configuration because they run a different network layer protocol. They still need an IP address and mask and they still need to be enabled, but they also require you to:
- Select an encapsulation type.
- Specify the end to perform the clocking.
After you have configured these items, there are certainly some additional things that can be configured, but the encapsulation type and clocking specifications are required to get the interface operational.
Routers route IPv4 packets. For routers to route packets, routers follow a routing process. That routing process relies on information called IP routes. Each IP route lists a destination — an IP network, an IP subnet or some other group of IP addresses. Each route also lists instructions that tell the router where to forward packets sent to addresses in that IP network or subnet. Routers need to have a detailed accurate list of IP routes.
There are three methods for adding IPv4 routes:
- Connected routes — Routers can learn routes for subnets attached to a router interface.
- Static routes — Routes can be created through a configuration command (ip route) that tells the router what route to put in the IPv4 routing table. See the section below for more information on configuring static routes.
- Routing protocol — Routers can learn and build routes to all networks and subnets by telling each other about their known routes.
If either of the following applies, a Cisco router will automatically add a route to its routing table for the subnet connected to each interface:
- The interface is in an up state (the show interfaces command lists both line and protocol statuses as up).
- The interface has an IP address assigned.
Additionally, note that both the Cisco routers and switch need to manually configure trunking. Here is how to configure trunking on a router:
- Create a unique interface for each VLAN that needs to be routed (interface type subint).
- Enable 802.1Q and associate one specific VLAN with the interface in interface
config mode (encapsulation dot1q vlan_id).
- Configure IP settings (address subnet and mask) in router config interface mode (ip address address mask).
Configuring Static Routes
Most networks use dynamic routing protocols to cause each router to learn the rest of the routes in a local network. But sometimes static routes are also needed. IOS allows you to assign static routes using the ip route global configuration command.
Every ip route command defines a destination with a subnet ID and mask. The command also lists the forwarding instructions. To list the current static routes, use the show ip route static command.
Configuring a Router as a DHCP Server
A Cisco router can be either a DHCP client or a DHCP server. If your router connects to your internet service provider (ISP), your ISP will issue the router an IP address to one of the interfaces; this interface needs to be set as a DHCP client. This can be done with the ip address dhcp command.
However, it is more likely that the router interface will be functioning as a DHCP server. To configure the router as a DHCP server, do the following:
- Enable the DHCP server.
- Configure a DHCP address pool.
- Configure the pool options.
You enable the DHCP server on each interface by configuring an address pool that includes the subnet in which the interface resides. To enable the service, execute the service dhcp command. Then create a dhcp pool by running the ip dhcp pool poolname command. After that, you can create the addresses and the subnet mask for the pool; you must consider the IP address of the interface on which DHCP will operate. To configure the pool, use network address mask command.
At this point, DHCP will be functional and will start to lease IP addresses to clients. But these IP addresses will need default gateway and DNS server addresses (pool options). To configure them, use the following commands in dhcp configuration mode:
- default-router address — To configure the default gateway
- dns-server address — To configure the DNS server