Configuring Static IP Routing

Finding Feature Information

Your software release may not support all the features documented in this module. For the latest caveats and feature information, see Bug Search Tool and the release notes for your platform and software release. To find information about the features documented in this module, and to see a list of the releases in which each feature is supported, see the feature information table at the end of this module.

Use Cisco Feature Navigator to find information about platform support and Cisco software image support. To access Cisco Feature Navigator, go to http://www.cisco.com/go/cfn. An account on Cisco.com is not required.

Information About Configuring IP Unicast Routing

This module describes how to configure IP Version 4 (IPv4) unicast routing on the switch. Static routing is supported only on switched virtual interfaces (SVIs) and not on physical interfaces. The switch does not support routing protocols.

Unless otherwise noted, the term switch refers to a standalone switch and a switch stack. A switch stack operates and appears as a single switch to the routers in the network.

For complete syntax and usage information for the commands used in this chapter, see the Cisco IOS IP Command Reference, Volume 1 of 3: Addressing and Services, Release 12.2


Note

When configuring routing parameters on the switch and to allocate system resources to maximize the number of unicast routes allowed, use the sdm prefer lanbase-routing global configuration command to set the Switch Database Management (SDM) feature to the routing template. For more information on the SDM templates, see chapter Configuring SDM Templates or see the sdm prefer command in the command reference for this release.


Information About IP Routing

In some network environments, VLANs are associated with individual networks or subnetworks. In an IP network, each subnetwork is mapped to an individual VLAN. Configuring VLANs helps control the size of the broadcast domain and keeps local traffic local. However, network devices in different VLANs cannot communicate with one another without a Layer 3 device (router) to route traffic between the VLAN, referred to as inter-VLAN routing. You configure one or more routers to route traffic to the appropriate destination VLAN.

Figure 1. Routing Topology Example. This figure shows a basic routing topology. Switch A is in VLAN 10, and Switch B is in VLAN 20. The router has an interface in each VLAN.

When Host A in VLAN 10 needs to communicate with Host B in VLAN 10, it sends a packet addressed to that host. Switch A forwards the packet directly to Host B, without sending it to the router.

When Host A sends a packet to Host C in VLAN 20, Switch A forwards the packet to the router, which receives the traffic on the VLAN 10 interface. The router checks the routing table, finds the correct outgoing interface, and forwards the packet on the VLAN 20 interface to Switch B. Switch B receives the packet and forwards it to Host C.

When static routing is enabled on Switch A and B, the router device is no longer needed to route packets.

Types of Routing

Routers and Layer 3 switch can route packets in these ways:

  • Using default routing to send traffic with a destination unknown to the router to a default outlet or destination

  • Using static routes to forward packets from predetermined ports through a single path into and out of a network

  • Dynamically calculating routes by using a routing protocol

The switch supports static routes and default routes, It does not support routing protocols.

IP Routing and Switch Stacks


Note

Stacking is supported only on Catalyst 2960-S switch.


A switch stack appears to the network as a single switch, regardless of which switch in the stack is connected to a peer.

stack's active switch functions:

  • The MAC address of the stack's active switch is used as the router MAC address for the whole stack, and all outside devices use this address to send IP packets to the stack.

  • All IP packets that require software forwarding or processing go through the CPU of the stack's active switch.

Stack members functions:

  • Act as routing standby switch, taking over if elected as the new stack's active switch when the stack's active switch fails.

  • Program the routes into hardware.

If a stack's active switch fails, the stack detects that the stack's active switch is down and elects a stack member to be the new stack's active switch. Except for a momentary interruption, the hardware continues to forward packets.

New stack's active switch functions after election:

  • Builds routing table and distributes it to stack members.

  • Uses its MAC address as the router MAC address. To notify its network peers of the new MAC address, it periodically (every few seconds for 5 minutes) sends a gratuitous ARP reply with the new router MAC address.


    Note

    If you configure the persistent MAC address feature on the stack and the stack's active switch changes, the stack MAC address does not change during the configured time period. If the previous stack's active switch rejoins the stack as a member switch during that time period, the stack MAC address remains the MAC address of the previous stack's active switch.


Configuring IP Unicast Routing

By default, IP routing is disabled on the switch. .

In these procedures, the specified interface must be a switch virtual interface (SVI)-a VLAN interface created by using the interface vlan vlan_id global configuration command and by default a Layer 3 interface. All Layer 3 interfaces on which routing will occur must have IP addresses assigned to them. See the Assigning IP Addresses to SVIs section.


Note

The switch supports 16 static routes (including user-configured routes and the default route) and any directly connected routes and default routes for the management interface. You can use the "lanbase-default" SDM template to configure the static routes. The switch can have an IP address assigned to each SVI. Before enabling routing, enter the sdm prefer lanbase-routing global configuration command and reload the switch.

Procedures for configuring routing:

  • To support VLAN interfaces, create and configure VLANs on the switch or switch stack, and assign VLAN membership to Layer 2 interfaces. For more information, see chapter: Configuring VLANs.

  • Configure Layer 3 interfaces (SVIs).

  • Enable IP routing on the switch.

  • Assign IP addresses to the Layer 3 interfaces.

  • Configure static routes.

Enabling IP Unicast Routing

By default, the switch is in Layer 2 switching mode and IP routing is disabled. To use the Layer 3 capabilities of the switch, you must enable IP routing.

Follow these steps to enable IP routing:

SUMMARY STEPS

  1. enable
  2. configure terminal
  3. ip routing
  4. end
  5. show running-config
  6. copy running-config startup-config

DETAILED STEPS

  Command or Action Purpose
Step 1

enable

Example:


Switch> enable

Enables privileged EXEC mode.

  • Enter your password if prompted.

Step 2

configure terminal

Example:


Switch# configure terminal

Enters global configuration mode.

Step 3

ip routing

Example:


Switch(config)# ip routing

Enables IP routing.

Step 4

end

Example:


Switch(config)# end

Returns to privileged EXEC mode.

Step 5

show running-config

Example:


Switch# show running-config 

Verifies your entries.

Step 6

copy running-config startup-config

Example:


Switch# copy running-config startup-config 

(Optional) Saves your entries in the configuration file.

What to do next

Use the no ip routing global configuration command to disable routing.

Example of Enabling IP Routing

This example shows how to enable IP routing :


Switch# configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)# ip routing

Switch(config-router)# end

Assigning IP Addresses to SVIs

To configure IP routing, you need to assign IP addresses to Layer 3 network interfaces. This enables communication with the hosts of those interfaces that use IP. IP routing is disabled by default, and no IP addresses are assigned to SVIs.

An IP address identifies a location to which IP packets can be sent. Some IP addresses are reserved for special uses and cannot be used for host, subnet, or network addresses. RFC 1166, “Internet Numbers,” contains the official description of IP addresses.

An interface can have one primary IP address. A mask identifies the bits that denote the network number in an IP address. When you use the mask to subnet a network, the mask is referred to as a subnet mask. To receive an assigned network number, contact your Internet service provider.

Follow these steps to assign an IP address and a network mask to an SVI:

Procedure

  Command or Action Purpose
Step 1

enable

Example:


Switch> enable

Enables privileged EXEC mode.

  • Enter your password if prompted.

Step 2

configure terminal

Example:


Switch# configure terminal

Enters global configuration mode.

Step 3

interface vlan vlan-id

Enters interface configuration mode, and specifies the Layer 3 VLAN to configure.

Note 

If the interface is still in Layer 2 mode (the default), you must enter a no switchport interface configuration command before entering the ip address interface configuration command.

Step 4

ip address ip-address subnet-mask

Example:


Switch(config-if)# ip address 10.1.5.1 255.255.255.0

Configures the IP address and IP subnet mask.

Step 5

end

Example:


Switch(config)# end

Returns to privileged EXEC mode.

Step 6

show interfaces [interface-id]

Example:


Switch# show interfaces gigabitethernet 1/0/1

Verifies your entries.

Step 7

show running-config

Example:


Switch# show running-config 

Verifies your entries.

Step 8

copy running-config startup-config

Example:


Switch# copy running-config startup-config 

(Optional) Saves your entries in the configuration file.

Configuring Static Unicast Routes

Static unicast routes are user-defined routes that cause packets moving between a source and a destination to take a specified path. Static routes can be important if the router cannot build a route to a particular destination and are useful for specifying a gateway of last resort to which all unroutable packets are sent.

Follow these steps to configure a static route:

Procedure

  Command or Action Purpose
Step 1

enable

Example:


Device> enable

Enables privileged EXEC mode.

  • Enter your password if prompted.

Step 2

configure terminal

Example:


Device# configure terminal

Enters global configuration mode.

Step 3

ip route prefix mask {address | interface} [distance]

Example:


Device(config)# ip route prefix mask gigabitethernet 1/0/4

Establish a static route.

Step 4

end

Example:


Switch(config)# end

Returns to privileged EXEC mode.

Step 5

show ip route

Example:


Switch# show ip route

Displays the current state of the routing table to verify the configuration.

Step 6

copy running-config startup-config

Example:


Device# copy running-config startup-config 

(Optional) Saves your entries in the configuration file.

What to do next

Use the no ip route prefix mask {address| interface} global configuration command to remove a static route. The switch retains static routes until you remove them.

When an interface goes down, all static routes through that interface are removed from the IP routing table. When the software can no longer find a valid next hop for the address specified as the forwarding router's address in a static route, the static route is also removed from the IP routing table.

Monitoring and Maintaining the IP Network

You can remove all contents of a particular cache, table, or database. You can also display specific statistics.

Table 1. Commands to Clear IP Routes or Display Route Status
Command Purpose

show ip route [address [mask] [longer-prefixes]]

Displays the current state of the routing table.

show ip route summary

Displays the current state of the routing table in summary form.

show platform ip unicast

Displays platform-dependent IP unicast information.

Additional References for Configuring IP Unicast Routing

Related Documents

Related Topic Document Title

Command reference

Command Reference, Cisco IOS Release 15.2(2)E (Catalyst 2960, 2960-S, 2960-SF and 2960-Plus Switches)

Error Message Decoder

Description Link

To help you research and resolve system error messages in this release, use the Error Message Decoder tool.

https://www.cisco.com/cgi-bin/Support/Errordecoder/index.cgi

Standards and RFCs

Standard/RFC Title
None

MIBs

MIB MIBs Link

All the supported MIBs for this release.

To locate and download MIBs for selected platforms, Cisco IOS releases, and feature sets, use Cisco MIB Locator found at the following URL:

http://www.cisco.com/go/mibs

Technical Assistance

Description Link

The Cisco Support website provides extensive online resources, including documentation and tools for troubleshooting and resolving technical issues with Cisco products and technologies.

To receive security and technical information about your products, you can subscribe to various services, such as the Product Alert Tool (accessed from Field Notices), the Cisco Technical Services Newsletter, and Really Simple Syndication (RSS) Feeds.

Access to most tools on the Cisco Support website requires a Cisco.com user ID and password.

http://www.cisco.com/support