Your networks aren't all that complex, but you don't want to hassle with manually configuring routes. Isn't this the kind of work that computers should be doing, the repetitive boring stuff? Your routers are Debian-based.
Indeed, this is the sort of drudgery that computers excel at handling. There are two categories of dynamic routing protocols: interior and exterior. In this recipe, we shall look at Routing Information Protocol, the simplest interior routing protocol. RIP is included in the Quagga suite of routing protocols.
Installation is boringly easy:
# aptitude install quagga
Now, you must edit some configuration files. Start with /etc/quagga/daemons, and enable zebra and ripd:
##/etc/quagga/daemons zebra=yes bgpd=no ospfd=no ospf6d=no ripd=yes ripngd=no isisd=no
Next, create /etc/quagga/zebra.conf:
!/etc/quagga/zebra.conf hostname router1 password bigsecret enable password bigsecret service advanced-vty log file /var/log/quagga/zebra.log ! !administrative access controls- local machine only ! access-list localhost permit 127.0.0.1/32 access-list localhost deny any ! line vty access-class localhost
Now, create /etc/quagga/ripd.conf:
!/etc/quagga/ripd.conf hostname router1 password moresecret enable password moresecret router rip network eth1 redistribute static redistribute connected service advanced-vty log file /var/log/quagga/ripd.log ! !administrative access controls- local machine only ! access-list localhost permit 127.0.0.1/32 access-list localhost deny any ! line vty access-class localhost
And now, set correct ownership and file permissions:
# chown quagga:quagga ripd.conf zebra.conf
# chown :quaggavty vtysh.conf
Add these lines to /etc/services:
zebrasrv 2600/tcp # zebra service zebra 2601/tcp # zebra vty ripd 2602/tcp # RIPd vty
Finally, add this line to /etc/environment:
VTYSH_PAGER=more
Now, fire it up:
# /etc/init.d/quagga start
Do this on all of your routers, and you're finished.
Give it a couple of minutes, then fire up your favorite command to view your routing table:
$ /sbin/route
$ ip route show
$ netstat -rn
Quagga's configuration files use exclamation marks for comments.
All of the Quagga daemons are controlled from a single startup file:
# /etc/init.d/quagga {start|stop|restart|force-reload| [daemon]}
You could do no more than this recipe and be content. Each Quagga daemon broadcasts its routing table every 30 seconds via multicast to your other RIP-enabled routers, and so you don't have to hassle with creating static routes all over the place.
Debian, by default, limits vty access to the local machine in /etc/quagga/debian/conf, and Fedora uses /etc/sysconfig/quagga. See Recipe 6.10 to learn how to enable remote logins.
Some definitions for ripd.conf:
hostname
This is arbitrary, and has nothing to do with the router's Linux hostname. It controls the hostname you see displayed on the vtysh or telnet command line.
router rip
Specify the rip
routing
protocol here. The default is to send v2 and receive 1 and 2.
Other protocol options are ripng, ospf,
ospf6
, and bgp
,
which of course you would use in their respective configuration
files.
network eth1
Which interface or interfaces ripd should listen on. Name additional interfaces on separate lines.
redistribute
static
redistribute
connected
Share directly connected routes. For example, your router is connected to the 10.0.0.1/24 network, so it will tell your other routers how to get to it.
service
advanced-vty
Enables advanced vty functions such as command history and tab-completion.
access-list
The two access-list
lines define a new class, localhost
. The class name can be
anything you want; it doesn't have to be localhost
. After defining the class,
the
line vty access-class localhost
lines mean "only allow vty logins on the local machine. No remote logins allowed."
The default logging level is debugging
, which creates the most output.
You may specify any of the following loglevels: emergencies, alerts, critical, errors, warnings,
notifications, information
, or debugging
, like this:
log file /var/log/quagga/ripd.log warnings
If you don't have a logfile, a crash will generate a /var/tmp/quagga.[daemon name]. crashlog file. This must be deleted to allow new crashlog files to be generated.
RIP has two versions. RIPv1 is pretty limited, and should be avoided
if possible. It does not support classless network notation, and is
slow to respond to changing conditions such as a down router. RIPv2
understands classless notation, doesn't get stuck in low gear, and
uses triggered updates for quick responses to changes. It is
compatible with RIPv1, in case you're stuck with some really old gear.
The default is to send v2 and to receive 1 and 2. The version 2
option tells it to send and
receive v2 only.
RIP is limited to 15 hops, so it's no good for large complex networks.
Quagga includes five routing daemons: ripd, ripngd, ospfd, ospf6d, and bgpd, and one manager daemon, zebra. zebra must always be started first. Each daemon has its own port that it listens on:
zebrasrv 2600/tcp zebra 2601/tcp ripd 2602/tcp ripngd 2603/tcp ospfd 2604/tcp bgpd 2605/tcp ospf6d 2606/tcp ospfapi 2607/tcp isisd 2608/tcp
Quagga documentation: http://www.quagga.net/docs/docs-info.php
man 8 ripd
man 8 zebra