Routing

ginglyformweekNetworking and Communications

Oct 29, 2013 (3 years and 9 months ago)

74 views

6
-
1

Module 6



Routing





FreeBSD can be used as a router.



Juniper Networks use FreeBSD as the base operating system for their router.

6.1.

IP Forwarding




By default, FreeBSD will not forward traffic
between interfaces
.



To enable routing on FreeBSD, IP forwarding must be
enabled so that traffic
between interfaces could be forwarded.



To enable IP Forwarding, we can use the
sysctl

utility:

# sysctl net.inet.ip.forwarding=1



To make this configuration permanent, add the following line to
/etc/rc.conf
:

gateway_enable=”YES”



Once

IP
forwarding is enabled, forwarding behavior can be controlled by modifying
the routing table.



Routing table can be modified using the following methods:

1.

Automatic:

“Directly connected” network will be added to the routing table

automatically.

2.

Manual:

We can update the routing table using the
route(8)

utility.

3.

Dynamic:

Using dynamic routing daemon
like

Quagga which supports

dynamic routing protocols such as
BGP, ISIS, OSPF
and
RIP
.



IPv4 routing table can be displayed using the following command:

#
netstat

rn

finet

Routing tables


Internet:

Destination Gateway Flags Refs Use Netif Expire

default 10.20.63.1 UGS 0 1258611 em0

10.20.63.0/24 link#1 UC 0 0 em0

10.20.63.1 00:04:96:1e:42:40 UHLW 2 0 em0 1191

127.0.0.1 127.0.0.1 UH 0 264 lo0




Each routing entry has four important fields: Destination, Gateway, Flags and Netif.

6
-
2



Kernel will route traffic f
or
Destination

to
Gateway

via
Netif

(network interface).



Flags are special bits associated to each route.



Flags description are as follows:

Flags

Description

1

Protocol specific routing flag #1

2

Protocol specific routing flag #2

3

Protocol specific
routing flag #3

B

Just discard pkts (during updates)

b

Broadcast address

C

Generate new routes on use

c

Protocol
-
specified generates new routes on use

D

Dynamic route (created by redirect)

G

Gateway

H

Host entry (represents network entry if flag is not pre
sent)

L

Valid protocol to link address translation

M

Mod
ified dynamically (by redirect)

R

Host or network unreachable

S

Static route (manual entry)

U

Usable

W

Generated from cloning

X

External daemon translates proto to link address


6.2.

Static Routing




We can

manually add static route using the
route(8)

utility.



For example, to add route to subnet 172.16.23.0/24 via 10.20.13.2 gateway:

# route add 172.16.23.0/24 10.20.13.2

add net 172.16.23.0: gateway
10.20.13.2



As previously mentioned in module 3, to add
default route, let’s say via 10.20.13.254
use:

# route add default 10.20.13.254



To modify existing route, use
route change
. Example, to change route to subnet
172.16.23.0/24 now via 10.20.13.3:

# route change 172.16.23.0/24 10.20.13.3

change net 172.16.23.
0: gateway 10.20.13.3



To view routing table entry for specific route, use
route get
. Example:

# route get 172.16.23.0/24

route to: 172.16.23.0

destination: 172.16.23.0


mask: 255.255.255.0


gateway:
10.20.13.3


interface:
bge
0


flags: <UP,GA
TEWAY,DONE,STATIC>


recvpipe sendpipe ssthresh rtt,msec rttvar hopcount mtu expire


0 0 0 0 0 0 1500 0

6
-
3




The command
netstat

rn

as shown in
6.1
, can be used to view
all

routing
ent
ries
.



To delete a route from the routing table, use
route delete
. Example:

# route delete 172.16.23.0/24



To make the change permanent, the routes must be added at system startup.
T
his
can be done by adding the route
s

to
/etc/rc.conf
. Example of adding two
static
routes to
/etc/rc.conf
:

static_routes=”r1 r2”

route_r1=”172.16.23.0/24 10.20.13.3”

route_r2=”172.16.24.0/24 10.20.13.4”



To manually reload the routes configured in
/etc/rc.conf

without rebooting:

# /etc/rc.d/routing stop

# /etc/rc.d/routing static


6.3.

Dynamic Routing




To use dynamic routing in FreeBSD, we can install routing daemon such as
Quagga
.



Quagga system architecture is as follows:

+
----
+ +
----
+ +
-----
+ +
-----
+

|bgpd| |ripd| |ospfd| |zebra|

+
----
+ +
----
+ +
-----
+ +
-----
+



|

+
---------------------------
|
--
+

| v |

| UNIX Kernel routing table |

| |

+
------------------------------
+



Different processes handle

different routing protocol.



Example, BGP daemon
handles BGP protocol, OSPF daemon handles OSPF protocol.



F
or changing the kernel routing table and for redistribution of routes between
different routing protocols, there is a kernel routing table manager
zebra

daemon.



We will configure
OSPF
in
Quagga
duri
ng our lab session.

6.3.1

OSPF Overview


6
-
4



Open Shortest Path First (OSPF) is a dynamic routing protocol for use in IP
networks.



OSPF is a link
-
state routing protocol that falls into the group of interior gateway
protocols, operating within a single autonomous sys
tem (AS).



OSPF is perhaps the most widely
-
used interior gateway protocol (IGP) in large
enterprise networks.



OSPF detects changes in the topology, such as link failures, very quickly and
converges on a new loop
-
free routing structure within seconds.



OSPF c
omputes the shortest path tree for each route using a method based on
Dijkstra's algorithm, a shortest path first algorithm.



The link
-
state information is maintained on each router as a link
-
state database
(LSDB) which is a tree
-
image of the entire network

topology.



Identical copies of the LSDB are periodically updated through flooding on all OSPF
routers.



OSPF networks are divided into routing areas to simplify administration and
optimize traffic and resource utilization.



Areas are identified by 32
-
bit num
bers, expressed either simply in decimal, or often
in octet
-
based dot
-
decimal notation, familiar from IPv4 address notation.



By convention, area 0 or 0.0.0.0 represents the backbone region of an OSPF network.



The identifications of other areas may be chose
n at will.



Each additional area must have a direct or virtual connection to the backbone OSPF
area.

6
-
5



The following figure shows a typical OSPF network:


Figure 6.1: A typical OSPF network

6.3.2

Configuring Quagga




Once installed, to enable Quagga, we need to add the following to
/etc/rc.conf:

quagga_enable="YES"



Quagga configuration files are stored in
/usr/local/etc/quagga/

directory.



Initially, this directory will be empty.



To enable basic Quagga functionalities a
nd managing static routing with Quagga, the
file zebra.conf must be created in the directory.



To enable OSPF daemon in Quagga, we must create ospfd.conf file.



This could be done by:

# cd /usr/local/etc/quagga

# touch zebra.conf

# touch ospfd.conf



Once this

is done, we can start the Quagga daemon by:

#/usr/local/etc/rc.d/quagga start

6
-
6



Quagga command line interface is

very similar to
Cisco
-
IOS
.



To enter into Quagga’s
CLI:

# vtysh

Hello, this is Quagga (version 0.99.11).

Copyright 1996
-
2005 Kunihiro Ishiguro,
et al.

#



Now, we’re in Quagga’s CLI.



To show the current configuration:

# show running
-
config

Building configuration...


Current configuration:

!

end

!

interface em0


ipv6 nd suppress
-
ra

!

interface lo0

!

interface plip0


ipv6 nd suppress
-
ra

!




To start
configuring Quagga, just type “
configure terminal
” from the CLI.



Note that we can configure the interfaces IP address and default gateway in Quagga.



Basic

network configuration
example
with
Quagga:

# configure terminal

(config)# interface em0

(config
-
if)#

ip address 192.168.4.131/24

(config
-
if)# no shut

(config
-
if)# exit

(config)# ip route 0.0.0.0/0 192.168.4.2

(config)# hostname myquagga

myquagga(config)# exit

myquagga# wri mem

Building Configuration...

Configuration saved to /usr/local/etc/qua
gga/zebra.conf

Configuration saved to /usr/local/etc/quagga/ospfd.conf

[OK]



Some IOS
-
like commands in Quagga’s vtysh are shown in the example below:

myquagga# show interface em0

Interface em0 is up, line protocol detection is disabled


index 1 metric 1 mt
u 1500


flags: <UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST>

6
-
7


inet 192.168.4.131/24 broadcast 192.168.4.255


input packets 11023, bytes 7055660, dropped 0, multicast packets 42


input errors 0


output packets 7371, bytes 925661, multicast packets 0


output errors 0


collisions 0

myquagga# show ip route

Codes: K
-

kernel route, C
-

connected, S
-

static, R
-

RIP, O
-

OSPF,


I
-

ISIS, B
-

BGP, >
-

selected route, *
-

FIB route


S 0.0.0.0/0 [1/0] via 192.168.4.2, em0

K>* 0.0.0.0/0 via 192.
168.4.2, em0

K>* 10.20.13.0/24 via 192.168.4.132, em0

K>* 10.20.14.0/24 via 192.168.4.133, em0

C>* 127.0.0.0/8 is directly connected, lo0

C>* 192.168.4.0/24 is directly connected, em0

myquagga# show version

Quagga 0.99.11 (myquagga).

Copyright 1996
-
2005 Ku
nihiro Ishiguro, et al.

myquagga# show ip forwarding

IP forwarding is on

6.3.3

Setting up OSPF Routing with Quagga




We will now see an example on how we could
configure

Quagga to
use

OSPF
to
exchange routing information
with a Cisco router in a
n IP

network.



Refer to the scenario below:


Figure 6.2: Sample OSPF scenario



I
n this
scenario
, we see an example where two Desktops are connected
to

each other
through two routers,
a

Cisco 2651 router and
a

Quagga router.

6
-
8



The configuration on the Cisco router will be
like this:

interface FastEthernet0/0


description link to
Quagga

router


ip address 200.0.0.2 255.255.255.0



interface FastEthernet0/1


description link to Desktop A


ip address 10.1.0.2 255.255.255.0



interface Loopback1


ip address 10.200.1.1 255.
255.255.255


router ospf 1


network 10.1.0.0 0.0.0.255 area 0


network 10.200.1.1 0.0.0.0 area 0


network 200.0.0.0 0.0.0.255 area 0



The configuration on Quagga should look as follows:

interface em0


description link to Cisco router


ip address 200.0.0.1/24


link
-
detect

interface em1


description link to Desktop B


ip address 10.2.0.1/24


link
-
detect

interface lo1


ip address 10.200.1.2/32


link
-
detect

router ospf


network 10.2.0.0/24 area 0


network 10.200.1.2/32 area 0


n
etwork 200.0.0.0/24 area 0


6.3.4

Troubeshooting Quagga




We can use the following commands to troubleshoot routing & OSPF issues on
Quagga:

# show ip route

# show ip route ospf

# show ip ospf neighbor

# show ip ospf database

# show ip ospf interface