Welcome to the tutorial guide. The tutorial will provide a user with guidance and instructions on dynamic routing (OSPF and BGP).
Please note that when the network starts to get really big, or when a user considers the internet as his/her network then a user will need tools which dynamically route his/her data. Sites are often connected to each other with multiple links, and more are popping up all the time.
The Internet has mostly standardized on OSPF (RFC 2328) anc2d BGP4 (RFC 1771). Linux supports both, by way of gated and zebra.
Setting up OSPF with Zebra
It is good to know the principal features of OSPF. These features are mentioned below:
Hierachical
Networks are grouped by areas, which are interconnected by a backbone area which will be designated as area 0. All traffic goes through area 0, and all the routers in area 0 have routing information about all the other areas.
Short convergence
Routes are propagated very fast, compared with RIP, for example.
Bandwith efficient
Uses multicasting instead of broadcasting, so it doesn’t flood other hosts with routing information that may not be of interest for them, thus reducing network overhead. Also, Internal Routers (those which only have interfaces in one area) don’t have routing information about other areas. Routers with interfaces in more than one area are called Area Border Routers, and hold topological information about the areas they are connected to.
Cpu intensive
OSPF is based on Dijkstra’s Shortest Path First algorithm, which is expensive compared to other routing algorithms. But really is not that bad, since the Shortest Path is only calculated for each area, also for small to medium sized networks this will not be an issue.
Link state
OSPF counts with the special characteristics of networks and interfaces, such as bandwith, link failures, and monetary cost.
Open protocol and GPLed software
OSPF is an open protocol, and Zebra is GPL software, which has obvious advantages over propietary software and protocols.
Prerequisites
Please note the prerequisites of this.
Linux Kernel:
Compiled with CONFIG_NETLINK_DEV and CONFIG_IP_MULTICAST.
Iproute
Zebra
Configuring Zebra
An example for this network will be helpful:Let’s
| 192.168.0.0/24 |
| |
| Area 0 100BaseTX Switched |
| Backbone Ethernet |
—————————————————-
| | | |
| | | |
|eth1 |eth1 |eth0 |
|100BaseTX |100BaseTX |100BaseTX |100BaseTX
|.1 |.2 |.253 |
——— ———— ———– —————-
|R Omega| |R Atlantis| |R Legolas| |R Frodo |
——— ———— ———– —————-
|eth0 |eth0 | | |
| | | | |
|2MbDSL/ATM |100BaseTX |10BaseT |10BaseT |10BaseT
———— ———————————— ——————————-
| Internet | | 172.17.0.0/16 Area 1 | | 192.168.1.0/24 wlan Area 2|
———— | Student network (dorm) | | barcelonawireless |
———————————— ——————————-
Please note that zebra does most of the work automatically, so it won’t take any work to put all the routes up with zebra. It is hard work to maintain all those routes by hand in a day to day basis. A user should note that he/she has to clear the network topology and considerable care is required with Area 0. First configure zebra, editing zebra.conf and adapt it to a users needs:
hostname omega
password xxx
enable password xxx
!
! Interface’s description.
!
!interface lo
! description test of desc.
!
interface eth1
multicast
!
! Static default route
!
ip route 0.0.0.0/0 212.170.21.129
!
log file /var/log/zebra/zebra.log
In Debian, a user will also have to edit /etc/zebra/daemons so they start at boot:
zebra=yes
ospfd=yes
A user will need to edit ospfd.conf if he/she is still running IPV4 or ospf6d.conf if he/she is running IPV6. The ospfd.conf is provided below:
hostname omega
password xxx
enable password xxx
!
router ospf
network 192.168.0.0/24 area 0
network 172.17.0.0/16 area 1
!
! log stdout
log file /var/log/zebra/ospfd.log
How to run Zebra
A user can run or start Zebra in two ways:
• By typing “zebra -d”
• with some script “/etc/init.d/zebra start”.
When a user starts Zebra by typing or running script as mentioned above, by looking at the ospdfd logs following will be provided as below:
2010/12/13 22:46:24 OSPF: interface 192.168.0.1 join AllSPFRouters Multicast group.
2010/12/13 22:46:34 OSPF: SMUX_CLOSE with reason: 5
2010/12/13 22:46:44 OSPF: SMUX_CLOSE with reason: 5
2010/12/13 22:46:54 OSPF: SMUX_CLOSE with reason: 5
2010/12/13 22:47:04 OSPF: SMUX_CLOSE with reason: 5
2010/12/13 22:47:04 OSPF: DR-Election[1st]: Backup 192.168.0.1
2010/12/13 22:47:04 OSPF: DR-Election[1st]: DR 192.168.0.1
2010/12/13 22:47:04 OSPF: DR-Election[2nd]: Backup 0.0.0.0
2010/12/13 22:47:04 OSPF: DR-Election[2nd]: DR 192.168.0.1
2010/12/13 22:47:04 OSPF: interface 192.168.0.1 join AllDRouters Multicast group.
2010/12/13 22:47:06 OSPF: DR-Election[1st]: Backup 192.168.0.2
2010/12/13 22:47:06 OSPF: DR-Election[1st]: DR 192.168.0.1
2010/12/13 22:47:06 OSPF: Packet[DD]: Negotiation done (Slave).
2010/12/13 22:47:06 OSPF: nsm_change_status(): scheduling new router-LSA origination
2010/12/13 22:47:11 OSPF: ospf_intra_add_router: Start
Bhy looking at this, a user will note that 192.168.0.1 is the Designated Router and 192.168.0.2 is the Backup Designated Router
A user can also interact with the zebra or the ospfd interface by executing following:
$ telnet localhost zebra
$ telnet localhost ospfd
A user can log into zebra in order to view if the routes are propagating. After a user logs into zebra then he/she can type in following:
root@atlantis:~# telnet localhost zebra
Trying 127.0.0.1…
Connected to atlantis.
Escape character is ‘^]’.
Hello, this is zebra (version 0.92a).
Copyright 1996-2001 Kunihiro Ishiguro.
User Access Verification
Password:
atlantis> show ip route
Codes: K - kernel route, C - connected, S - static, R - RIP, O - OSPF,
B - BGP, > - selected route, * - FIB route
K>* 0.0.0.0/0 via 192.168.0.1, eth1
C>* 127.0.0.0/8 is directly connected, lo
O 172.17.0.0/16 [110/10] is directly connected, eth0, 06:21:53
C>* 172.17.0.0/16 is directly connected, eth0
O 192.168.0.0/24 [110/10] is directly connected, eth1, 06:21:53
C>* 192.168.0.0/24 is directly connected, eth1
atlantis> show ip ospf border-routers
============ OSPF router routing table =============
R 192.168.0.253 [10] area: (0.0.0.0), ABR
via 192.168.0.253, eth1
[10] area: (0.0.0.1), ABR
via 172.17.0.2, eth0
Or with iproute directly:
root@omega:~# ip route
212.170.21.128/26 dev eth0 proto kernel scope link src 212.170.21.172
192.168.0.0/24 dev eth1 proto kernel scope link src 192.168.0.1
172.17.0.0/16 via 192.168.0.2 dev eth1 proto zebra metric 20
default via 212.170.21.129 dev eth0 proto zebra
root@omega:~#
A user can see the zebra routes, that weren’t there before. The routes appear a few seconds after he/she starts zebra and ospfd. A user can check connectivity to other hosts with ping. Zebra routes are automatic, a user can just add another router to the network, configure zebra, and voila!
A user can use:
tcpdump -i eth1 ip[9] == 89
In order to capture OSPF packets for analysis, OSPF ip protocol number is 89, and the protocol field is the 9th octet on the ip header.
OSPF has a lot of tunable parameters, specially for large networks.
If a user follows advise and guidance as provided in this tutorial then he/she would have learnt about dynamic routing Open Shortest Path First (OSPF) and BGP.