Saturday 29 December 2007

Headless BSD Quagga Router

Objective Get an old box running as a bgp router for lab exercises.

Install a minimum installation of FreeBSD. See previous post for installation media.
Of note, My "Hard Drive" I am using for installation, is a 1gb Compact Flash Card, so to reduce "writes" to this I have not partitioned a "swap" space.

Also regards a headless install don't forget when asked if there are any last configurations you need to preform choose yes and navigate to the "TTYs" menu item. From here you need to edit thr /etc/ttys file.

scroll down to serial terminals section and edit so you can log on via the first serial console:
# Serial terminals
# The 'dialup' keyword identifies dialin lines to login, fingerd etc.
ttyd0 "/usr/libexec/getty std.9600" xterm on secure

so on reboot we should be at a login prompt.

Quagga Installation:
FreeBSD2# pkg_add -r quagga
Fetching ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-6.2-release/Latest/quagga.tbz... Done.
Added group "quagga".
Added user "quagga".
FreeBSD2#

Quagga is installed but we need two config files written to operate as a BGP router.
These go in /usr/local/etc/quagga/ and are "zebra.conf"
!
! Zebra configuration saved from vty
! 2007/12/22 22:25:59
!
hostname zebraBSD1
password zebra
enable password zebra
log stdout
!
debug zebra events
!
interface fxp0
ip address 10.2.2.2/24
ipv6 nd suppress-ra
!
interface fxp1
ipv6 nd suppress-ra
!
interface fxp2
ipv6 nd suppress-ra
!
interface lo0
!
interface plip0
ipv6 nd suppress-ra
!
!
line vty
password zebra
!

and "bgpd.conf"
!
!zebra BGP conf file
!
router bgp 65001
!
line vty
password zebra
!

now run zebra and bgpd as daemons.
freebsd1# zebra -d
2007/12/29 19:12:39 ZEBRA: MESSAGE: ZEBRA_INTERFACE_ADDRESS_ADD 10.2.2.2/24 on fxp0
2007/12/29 19:12:39 ZEBRA: rib_queue_add_qnode: work queue added
2007/12/29 19:12:39 ZEBRA: rib_queue_add_qnode: work queue added
2007/12/29 19:12:39 ZEBRA: rib_queue_add_qnode: work queue added
2007/12/29 19:12:39 ZEBRA: rib_queue_add_qnode: work queue added
2007/12/29 19:12:39 ZEBRA: rib_queue_add_qnode: work queue added
2007/12/29 19:12:39 ZEBRA: rib_queue_add_qnode: work queue added
2007/12/29 19:12:39 ZEBRA: rib_queue_add_qnode: work queue added
freebsd1# bgpd -d
freebsd1#

To access Quagga/zebra:
freebsd1# telnet localhost 2601
Trying ::1...
Connected to localhost.
Escape character is '^]'.

Hello, this is Quagga (version 0.99.4).
Copyright 1996-2005 Kunihiro Ishiguro, et al.


User Access Verification

Password:
zebraBSD1> exit
Connection closed by foreign host.

To access Quagga/bgpd:
freebsd1# telnet localhost 2605
Trying ::1...
Connected to localhost.
Escape character is '^]'.

Hello, this is Quagga (version 0.99.4).
Copyright 1996-2005 Kunihiro Ishiguro, et al.


User Access Verification

Password:
zebraBSD1> exit
Connection closed by foreign host.
freebsd1#


but you probably thinking this is going to be a hassle having to telnet into each daemon. Well the good news is quagga ships with a "vtysh". This enables one login for all daemons.
FreeBSD2# vtysh

Hello, this is Quagga (version 0.99.4).
Copyright 1996-2005 Kunihiro Ishiguro, et al.

best of all you get your trace and ping commands back!
FreeBSD2.home# ping 172.16.1.2
PING 172.16.1.2 (172.16.1.2): 56 data bytes
64 bytes from 172.16.1.2: icmp_seq=0 ttl=253 time=25.635 ms
64 bytes from 172.16.1.2: icmp_seq=1 ttl=253 time=25.425 ms
64 bytes from 172.16.1.2: icmp_seq=2 ttl=253 time=25.575 ms
64 by^C
--- 172.16.1.2 ping statistics ---
4 packets transmitted, 4 packets received, 0% packet loss
round-trip min/avg/max/stddev = 25.399/25.509/25.635/0.099 ms
FreeBSD2.home# trace 172.16.1.2
traceroute to 172.16.1.2 (172.16.1.2), 64 hops max, 40 byte packets
1 172.99.1.2 (172.99.1.2) 1.365 ms 1.306 ms 1.283 ms
2 172.16.20.2 (172.16.20.2) 15.764 ms 15.719 ms 15.741 ms
3 172.16.1.2 (172.16.1.2) 16.314 ms * 16.326 ms
FreeBSD2.home#


now, vi /etc/rc.conf to enable zebra & routing daemons on startup.
freebsd1# vi /etc/rc.conf

quagga_enable="YES"
quagga_daemons="zebra bgpd"


oh, and if you really want to forward packets, you will also have to add the following to /etc/rc.conf to enable FreeBSD as a router.

gateway_enable="YES"


bada bing!

No comments: