Networking optimize

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
Router(config)#

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
0.0.0.0/0           192.168.1.5          FastEthernet0/0
0.0.0.0/32          receive
192.168.0.0/24         192.168.10.1         Serial0/2/0
192.168.2.0/30       192.168.10.1         Serial0/2/0
192.168.3.0/30       192.168.10.1         Serial0/2/0
192.168.4.0/24       192.168.10.1         Serial0/2/0
192.168.5.0/30       192.168.10.1         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
Router#

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.

8 comments
figolwr
figolwr

You need to configure ip route-cache cef on individual interface as well

figolwr
figolwr

You need to configure ip route-cache cef on individual interface as well

georgeou
georgeou

Can you use CEF on 800, 1800, 2800, 3800 series? Would it make sense to? If so, which of these would make sense to enable CEF?

wizard57m-cnet
wizard57m-cnet

Let the zombies sleep, no need to resurrect dead discussions, with 2 posts no less

IT cowgirl
IT cowgirl

I was reviewing a new configuration on a router today to increase my learning, and noticed the ip cef and intended to go to Cisco to research the subject. However, an issue arose which took all my time and I forgot about it. Now I see a great article which provides more precise information and a wonderful discussion with the main points. This is better than Cisco!! I look forward to this article series every Thursday! Thanks!

craig.norborg
craig.norborg

I actually found it funny that one of the articles that this one links to over at Cisco is on what switching method you should use. It pretty much says "Always use CEF" which is what I hear from every Cisco tech. As for what routers support it? I think all newer routers do. I know for sure its on the 3800, 2800, the newer 800 series and I think the 1800 series routers too. The only time I found I shouldn't run it was when there was a bug associated with using it and IPSEC on a 877W router. Other than that it works great on the newer routers for sure...

halibut
halibut

And is this available on the new ASA devices? Or is it worthwhile to enable it? Why are the Cisco Tech's pushing this? What are the true benefits?

rburts
rburts

But I do not believe that it works for the ASA. If it is supported on the platform that you are using it is worth using. The comment in the article that CEF is enabled by default only on 7000 routers is very old and outdated information. I do not doubt that you can find sources on CCO that say that, but if you look at when they were written it was a long time ago. CEF is now supportd on pretty much every IOS platform and is enabled by default on them. Cisco techs are pushing the use of CEF because it is the most efficient switching path in the current IOS. It will improve performance and reduce CPU overhead. Also there are a number of features now that are dependent on CEF. One of the comparisons between CEF and fast switching is that fast switching is demand driven. The fast switching cache is built when a packet is switched to a destination - so the first packet (and sometimes other packets - depending on the periodic clearing of the fast switching cache) will be fast switched, for which you take a performance hit. The CEF tables are built when the routing table is built, so with CEF there is no need for any packet to be process switched.