User Tools

Site Tools


documentation:examples:simple_vrrp_lab

Simple VRRP lab

Network Diagram

Starting the lab

More information on these BSDRP lab scripts available on How to build a BSDRP router lab.

Example with the bhyve lab script:

# ./BSDRP-lab-bhyve.sh -i /usr/obj/BSDRP.amd64/BSDRP-1.54-full-amd64-vga.img -n 5 -l 2
BSD Router Project (http://bsdrp.net) - bhyve full-meshed lab script
Setting-up a virtual lab with 5 VM(s):
- Working directory: /tmp/BSDRP
- Each VM have 1 core(s) and 256M RAM
- 2 LAN(s) between all VM
- Full mesh Ethernet links between each VM
VM 1 have the following NIC:
- vtnet0 connected to VM 2.
- vtnet1 connected to VM 3.
- vtnet2 connected to VM 4.
- vtnet3 connected to VM 5.
- vtnet4 connected to LAN number 1
- vtnet5 connected to LAN number 2
VM 2 have the following NIC:
- vtnet0 connected to VM 1.
- vtnet1 connected to VM 3.
- vtnet2 connected to VM 4.
- vtnet3 connected to VM 5.
- vtnet4 connected to LAN number 1
- vtnet5 connected to LAN number 2
VM 3 have the following NIC:
- vtnet0 connected to VM 1.
- vtnet1 connected to VM 2.
- vtnet2 connected to VM 4.
- vtnet3 connected to VM 5.
- vtnet4 connected to LAN number 1
- vtnet5 connected to LAN number 2
VM 4 have the following NIC:
- vtnet0 connected to VM 1.
- vtnet1 connected to VM 2.
- vtnet2 connected to VM 3.
- vtnet3 connected to VM 5.
- vtnet4 connected to LAN number 1
- vtnet5 connected to LAN number 2
VM 5 have the following NIC:
- vtnet0 connected to VM 1.
- vtnet1 connected to VM 2.
- vtnet2 connected to VM 3.
- vtnet3 connected to VM 4.
- vtnet4 connected to LAN number 1
- vtnet5 connected to LAN number 2
For connecting to VM'serial console, you can use:
- VM 1 : cu -l /dev/nmdm1B
- VM 2 : cu -l /dev/nmdm2B
- VM 3 : cu -l /dev/nmdm3B
- VM 4 : cu -l /dev/nmdm4B
- VM 5 : cu -l /dev/nmdm5B

Configuring Routers

Router 1 (R1)

sysrc hostname=R1
sysrc ifconfig_vtnet4="inet 192.168.1.1 netmask 255.255.255.0"
sysrc ifconfig_vtnet5="inet 192.168.2.1 netmask 255.255.255.0"
sysrc quagga_enable=NO
sysrc freevrrpd_enable=YES
cat <<EOF > /usr/local/etc/freevrrpd.conf 
[VRID]
serverid = 1
interface = vtnet4
# This router is the master
priority = 101
addr = 192.168.1.254/24
# We want that this state is dependant with the state of vrid 2
vridsdep = 2
password = vrid1

[VRID]
serverid = 2
interface = vtnet5
# This router is the master
priority = 101
addr = 192.168.2.254/24
password = vrid2
# We want that this state is dependant with the state of vrid 1
vridsdep = 1
EOF
service quagga stop
service netif restart
service freevrrpd start

Router 2 (R2)

sysrc hostname=R2
sysrc ifconfig_vtnet4="inet 192.168.1.2 netmask 255.255.255.0"
sysrc ifconfig_vtnet5="inet 192.168.2.2 netmask 255.255.255.0"
sysrc quagga_enable=NO
sysrc freevrrpd_enable=YES
cat <<EOF > /usr/local/etc/freevrrpd.conf 
[VRID]
serverid = 1
interface = vtnet4
# This router is the backup
priority = 100
addr = 192.168.1.254/24
# We want that this state is dependant with the state of vrid 2
vridsdep = 2
password = vrid1

[VRID]
serverid = 2
interface = vtnet5
# This router is the backup
priority = 100
addr = 192.168.2.254/24
password = vrid2
# We want that this state is dependant with the state of vrid 1
vridsdep = 1
EOF
service quagga stop
service netif restart
service freevrrpd start

Router 3 (R3)

sysrc hostname=R3
sysrc ifconfig_vtnet4="inet 192.168.1.3 netmask 255.255.255.0"
sysrc defaultrouter="192.168.1.254"
sysrc gateway_enable=NO
sysrc ipv6_gateway_enable=NO
sysrc quagga_enable=NO
service quagga stop
service netif restart
service routing restart

Router 4 (R4)

sysrc hostname=R4
sysrc ifconfig_vtnet5="inet 192.168.2.4 netmask 255.255.255.0"
sysrc defaultrouter="192.168.2.254"
sysrc gateway_enable=NO
sysrc ipv6_gateway_enable=NO
sysrc quagga_enable=NO
service quagga stop
service netif restart
service routing restart

Checking configuration

VRRP state

On R1:

[root@R1]~#grep vrrp /var/log/messages
Feb  2 13:20:17 R1 freevrrpd[2397]: launching daemon in background mode
Feb  2 13:20:17 R1 freevrrpd[2398]: initializing threads and all VRID
Feb  2 13:20:17 R1 freevrrpd[2398]: reading configuration file /usr/local/etc/freevrrpd.conf
Feb  2 13:20:17 R1 freevrrpd[2398]: monitored circuits engine initialized
Feb  2 13:20:18 R1 freevrrpd[2398]: server state vrid 1: backup
Feb  2 13:20:19 R1 freevrrpd[2398]: server state vrid 2: backup
Feb  2 13:20:22 R1 freevrrpd[2398]: server state vrid 1: master
Feb  2 13:20:23 R1 freevrrpd[2398]: server state vrid 2: master

R1 is VRRP master for vrid 1 and 2.

On R2:

[root@R2]~#  grep vrrp /var/log/messages
Feb  2 13:22:17 R2 freevrrpd[2333]: launching daemon in background mode
Feb  2 13:22:17 R2 freevrrpd[2334]: initializing threads and all VRID
Feb  2 13:22:17 R2 freevrrpd[2334]: reading configuration file /usr/local/etc/freevrrpd.conf
Feb  2 13:22:17 R2 freevrrpd[2334]: monitored circuits engine initialized
Feb  2 13:22:18 R2 freevrrpd[2334]: server state vrid 1: backup
Feb  2 13:22:19 R2 freevrrpd[2334]: server state vrid 2: backup

R2 is the VRRP backup for vrid 1 and 2.

Forwarding and ARP entry

Pinging R4 from R3:

[root@R3]~# ping 192.168.2.4
PING 192.168.2.4 (192.168.2.4): 56 data bytes
64 bytes from 192.168.2.4: icmp_seq=0 ttl=63 time=0.669 ms
64 bytes from 192.168.2.4: icmp_seq=1 ttl=63 time=0.749 ms
64 bytes from 192.168.2.4: icmp_seq=2 ttl=63 time=0.718 ms

And checking ARP cache for a VRRP MAC address (00:00:5e:00:01:xx)

[root@R3]~#arp -na | grep 192.168.1.254
? (192.168.1.254) at 00:00:5e:00:01:01 on vtnet4 expires in 802 seconds [ethernet]

Testing VRRP swap

Disable one interface on R1 for changing the VRRP states:

[root@R1]~#ifconfig vtnet4 down
Feb  2 13:33:15 R1 freevrrpd[2398]: can't write to socket: Network is down
Feb  2 13:33:15 R1 freevrrpd[2398]: There is a big problem here !
Feb  2 13:33:17 R1 freevrrpd[2398]: interface vtnet4 is faulty, deactivated from VRRP VRIDs
Feb  2 13:33:17 R1 freevrrpd[2398]: VRID 2 (interface vtnet5) has been deactivated due to dependance

And check that R2 became the master:

[root@R2]~#tail -f /var/log/messages
Feb  2 13:33:18 R2 freevrrpd[2334]: server state vrid 1: master
Feb  2 13:33:21 R2 freevrrpd[2334]: server state vrid 2: master

And check that R3 still can reach R4:

[root@R3]~#ping 192.168.2.4
PING 192.168.2.4 (192.168.2.4): 56 data bytes
64 bytes from 192.168.2.4: icmp_seq=0 ttl=63 time=0.571 ms
64 bytes from 192.168.2.4: icmp_seq=1 ttl=63 time=0.795 ms
documentation/examples/simple_vrrp_lab.txt · Last modified: 2015/02/02 13:42 by olivier