Get better performance with Cisco Express Forwarding (CEF)

Cisco Express Forwarding (CEF) can result in faster switching and enable advanced features in the Cisco IOS. David Davis introduces you to CEF and its benefits in this article.

There are times while working in the Cisco IOS that, to configure a certain feature, you must enable Cisco Express Forwarding (CEF). What is this CEF and how does it help?

Introduction to Cisco Express Forwarding (CEF)

Routers must make decisions about where to forward your packets. This decision-making process is called "switching." This shouldn't be confused with an Ethernet switch. Switching is what a router does when it makes the following decisions:

  • Whether or not to forward the packet after checking that the destination for the packet is reachable?
  • If the destination is reachable, what is the next hop of the next router, and what interface will the router use to get to that destination?
  • Whether or not to modify the Ethernet MAC on the packet?

CEF is one of the available switching options for Cisco routers. Based on the routing table, CEF creates it own table, called the Forwarding Information Base (FIB). The FIB is organized differently than the routing table, and CEF uses the FIB to decide which interface to send traffic from. CEF offers the following benefits:

  • Better performance than fast-switching (the default) and takes less CPU to perform the same task
  • When enabled, allows for advanced features like NBAR
  • Overall, CEF can switch traffic faster than route-caching using fast-switching

Enabling and disabling CEF

CEF is disabled by default on all routers except the 7xxx series routers. Enabling and Disabling CEF is easy. To enable CEF, you go into global configuration mode and enter the ip cef command, like this:

Router# config t
Router(config)# ip cef

Disabling CEF works the same way, but in reverse. To disable CEF, just type no ip cef.

Showing CEF status

You can check on the status of CEF with a few different commands:

Show ip cef shows the entries in CEF's FIB. The FIB could be compared to a routing table. For detailed information on this command, see the command reference. Here is an example of the command output:

Router# show ip cef
Prefix              Next Hop             Interface           FastEthernet0/0          receive         Serial0/2/0         Serial0/2/0         Serial0/2/0         Serial0/2/0         Serial0/2/0

Show ip cef detail shows detailed information on every entry in the FIB.

Show ip cef summary shows a summary of entries in the FIB, like this:

Router# show ip cef summary
IP CEF with switching (Table Version 1267), flags=0x0
  239 routes, 0 reresolve, 0 unresolved (0 old, 0 new), peak 3
  3 instant recursive resolutions, 0 used background process
  239 leaves, 153 nodes, 195448 bytes, 776 inserts, 537 invalidations
  0 load sharing elements, 0 bytes, 0 references
  universal per-destination load sharing algorithm, id 9C1B7D1D
  3(0) CEF resets, 483 revisions of existing leaves
  Resolution Timer: Exponential (currently 1s, peak 1s)
  485 in-place/0 aborted modifications
  refcounts:  40214 leaf, 39424 node

  Table epoch: 0 (239 entries at this epoch)

Adjacency Table has 3 adjacencies

The commands shown above are just a few of the command options for show ip cef. For a full list, just type show ip cef ?

You can find more information on configuring CEF in the Cisco IOS IP Switching Command Reference. To learn how to choose the best switching method for your network, see this Cisco document, entitled How to Choose the Best Router Switching Path for Your Network

Do your routers use CEF? Did this article help you? Share your thoughts and opinions in this article's discussion.

Miss a column?

Check out the Cisco Routers and Switches Archive, and catch up on David Davis' most recent columns.

Want to learn more about router and switch management? Automatically sign up for our free Cisco Routers and Switches newsletter, delivered each Friday!

David Davis has worked in the IT industry for 12 years and holds several certifications, including CCIE, MCSE+I, CISSP, CCNA, CCDA, and CCNP. He currently manages a group of systems/network administrators for a privately owned retail company and performs networking/systems consulting on a part-time basis.