Programming routers
This month's article will introduce network router programming. If you have not worked with IT infrastructure, you may be surprised at the number of options and possible configurations available to advanced programmers. The majority of this article will focus on Cisco routers and their operating system called IOS. There are several reasons for this. First, I am familiar with IOS. Second, I have seen a lot of Cisco equipment in media facilities, so it is likely you will come across this at some point. Third, there is a huge surplus market for Cisco routers; you can likely pick up a device to experiment with for much less than $100. Also, while this article uses the term “router,” be aware that sometimes the distinction between a router, a switch and a firewall can get blurry. In the Cisco world, all three of these devices can be programmed.
Why program?
Why you would ever want to learn about how to configure a router? The most straightforward answer is that by learning how to program a router, you can make it do what you want. But here are some specific reasons you might want to know how to program a router:
- You can get predictable performance from the network when you set specific quality of service (QoS) parameters.
- Knowing how to program a router allows you to set up virtual private networks (VPNs), which can provide high-performance, secure remote connections.
- You can also set up virtual LANs (VLANS) to segment traffic, increasing the performance and predictability of the network, simplifying network traffic management.
- Programming allows full access to a variety of network security measures and provides a way to change network security parameters on the fly.
How to program a router
Almost every router, even the ones bought in an office supply store, have a Web interface. The router creates this Web interface by running an embedded HTTP server, which provides access to the router's configuration. Typically, this Web page allows you to configure basic parameters. Many consumer routers are combined with wireless access points, so this Web interface also allows you to configure wireless parameters as well.
This configuration method has a number of advantages. It is straightforward and ubiquitous. The configuration parameters offered are usually easily understood. It is an efficient way to become acquainted with the capabilities of a router, and configuration capabilities can be quickly explained to other network engineers and even end users. The most obvious problem with this configuration method is that it is necessarily simplistic.
A second way to program the router is through uploadable configuration files. This method is not supported on consumer routers, but it is quite common in commercial routers. Configuration files can be created using a text editor, or they can be obtained from the manufacturer. Configuration files can also be prebuilt on the Internet.
Get the TV Tech Newsletter
The professional video industry's #1 source for news, trends and product and tech information. Sign up below.
A word of caution: Be sure to understand every single line of a configuration file, especially if you have not created it yourself. In the best case, a file may crash the router. Worst case, the file can open security holes, which can be exploited.
A third way, and perhaps the most common way to program a commercial-grade router, is through a command line interface (CLI). For those of you who have been working with *NIX or who are old enough to remember using DOS, working with a CLI will be a familiar experience. When using a CLI, type simple commands, and the router provides a text-based response. While the CLI tends to be a little terse, it is an extremely powerful interface, and once learned, it can be much quicker to make changes using a CLI than using a Web interface.
Default configurations
Before you start programming using a Web interface or a CLI, it would be good to have a general idea of how the router behaves in its default configuration. Consumer routers are configured to plug and play. The manufacturer makes a host of assumptions about how you will use the router so that, when plugged in, it is pretty much ready to go.
Commercial routers are completely different. In fact, in the default configuration, Cisco routers must be programmed from the ground up. This can be quite a shock for a technician who is just beginning to work with this type of equipment.
Cisco IOS
This article will conclude with a high level overview of Cisco IOS. IOS contains a command interpreter that interprets commands you type and creates a stored configuration in the router based on your input. Viewed from where a network engineer sits, IOS is almost like learning a computer programming language.
Property of Mega-Corporation
User Access Verification
Username: YourUsername
Password:
Router1>_
Figure 1. The Cisco IOS command line interface (CLI) is terse but extremely powerful. Users working with the CLI for the first time will see a screen similar to the one above.
Once logged into the IOS, your screen may look similar to Figure 1. Entering a question mark (“?”) at the prompt will generate a list of possible commands. Many commands such as “show” take additional arguments, so entering “show ?” at the prompt will generate a list of allowable words to follow the word “show.”
IOS has hundreds of commands, but many of them are intuitive. For example, if you were to type “ip name-server 192.168.2.1,” and then typed “show run” (short for “show running-config”), you would see a configuration line that tells the router to use 192.168.2.1 as the name server for the router.
Once you learn IOS, it can be used to configure just about everything on the router. Beyond that, it can help troubleshoot network devices in real time, make backups of the configuration for archival and even copy a running configuration to a new router.
There are many different versions of IOS available. Depending upon what you are trying to do, you may need the most current version. However, an older version may work just fine. Generally speaking, newer versions of IOS require more memory, and newer versions of IOS may require newer hardware. Check hardware compatibility and memory requirements before upgrading the IOS on an existing router.
Conclusion
There are many resources available for learning about router programming. Cisco does a particularly good job of producing courses, books, online tutorials, FAQs, sample configuration files, and other Web resources for learning IOS and for working with their routers. Other manufacturers provide similar resources.
While you could work on a live router, or find a simulator to use as you begin learning about router programming, there is a large aftermarket for used router hardware. IOS versions build on each other, and IOS basics are similar across most Cisco router products. Therefore, buy an inexpensive small router, connect it up to a couple of computers and start experimenting. Also, take an introductory course. This may save you many hours as you begin working with IOS.
Brad Gilmer is president of Gilmer & Associates, executive director of the Advanced Media Workflow Association and executive director of the Video Services Forum.
Send questions and comments to: brad.gilmer@penton.com