More information on these BSDRP lab scripts available on How to build a BSDRP router lab.
Example with the qemu lab script:
[root@d630]P#./BSDRP-lab-qemu.sh -n 5 -l 2 -i /tmp/BSDRP_0.32_full_amd64_serial.img BSD Router Project Qemu script Id Refs Name 307 1 kqemu Id Refs Name 294 1 aio filename guest a x86-64 image filename guests a serial image Will use standard console as input/output Starting qemu in lab mode... With BSDRP VM full meshed Starting a lab with 5 routers: - 2 LAN(s) between all routers - Full mesh ethernet links between each routers Router 1 network links matrix: em0 connected to router 2. em1 connected to router 3. em2 connected to router 4. em3 connected to router 5. em4 connected to LAN 1. em5 connected to LAN 2. Router 2 network links matrix: em0 connected to router 1. em1 connected to router 3. em2 connected to router 4. em3 connected to router 5. em4 connected to LAN 1. em5 connected to LAN 2. Router 3 network links matrix: em0 connected to router 1. em1 connected to router 2. em2 connected to router 4. em3 connected to router 5. em4 connected to LAN 1. em5 connected to LAN 2. Router 4 network links matrix: em0 connected to router 1. em1 connected to router 2. em2 connected to router 3. em3 connected to router 5. em4 connected to LAN 1. em5 connected to LAN 2. Router 5 network links matrix: em0 connected to router 1. em1 connected to router 2. em2 connected to router 3. em3 connected to router 5. em4 connected to LAN 1. em5 connected to LAN 2. Connect to the router 1 by telneting to localhost on port 8001 Connect to the router 2 by telneting to localhost on port 8002 Connect to the router 3 by telneting to localhost on port 8003 Connect to the router 4 by telneting to localhost on port 8004 Connect to the router 4 by telneting to localhost on port 8005
/etc/rc.conf
hostname="R1" # Don't need IPv6 for this lab: ipv6_enable="NO" # Polling not supported under Qemu: polling_enable="NO" # Configure IP addresses ifconfig_em4="inet 192.168.1.1 netmask 255.255.255.0" ifconfig_em5="inet 192.168.2.1 netmask 255.255.255.0" # Don't need Quagga for this lab: quagga_enable="NO" # Enable VRRP: freevrrpd_enable="YES"
/usr/local/etc/freevrrpd.conf
[VRID] serverid = 1 interface = em4 # We want that 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 = em5 # We want that 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
FreeVRRPd needs some netgraph module to be loaded:
mount -uw / echo 'ng_ether_load="YES"' >> /boot/loader.conf echo 'ng_bridge_load="YES"' >> /boot/loader.conf echo 'ng_eiface_load="YES"' >> /boot/loader.conf mount -ur / kldload ng_ether kldload ng_bridge kldload ng_eiface /usr/local/etc/rc.d/freevrrpd start
/etc/rc.conf
hostname="R2" # Don't need IPv6 for this lab: ipv6_enable="NO" # Polling not supported under Qemu: polling_enable="NO" # Configure IP addresses ifconfig_em4="inet 192.168.1.2 netmask 255.255.255.0" ifconfig_em5="inet 192.168.2.2 netmask 255.255.255.0" # Don't need Quagga for this lab: quagga_enable="NO" # Enable VRRP: freevrrpd_enable="YES"
/usr/local/etc/freevrrpd.conf
[VRID] serverid = 1 interface = em4 # We want that 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 = em5 # We want that 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
FreeVRRPd needs some netgraph module to be loaded before be started
mount -uw / echo 'ng_ether_load="YES"' >> /boot/loader.conf echo 'ng_bridge_load="YES"' >> /boot/loader.conf echo 'ng_eiface_load="YES"' >> /boot/loader.conf mount -ur / kldload ng_ether kldload ng_bridge kldload ng_eiface /usr/local/etc/rc.d/freevrrpd start
/etc/rc.conf
hostname="R3" # R3 doesn't need to be a router for this lab: gateway_enable="NO" # Don't need IPv6 for this lab: ipv6_enable="NO" defaultrouter="192.168.1.254" # Polling not supported under Qemu: polling_enable="NO" # Configure IP addresses ifconfig_em4="inet 192.168.1.10 netmask 255.255.255.0" # Don't need Quagga for this lab: quagga_enable="NO"
/etc/rc.conf
hostname="R4" # R4 doesn't need to be a router for this lab: gateway_enable="NO" # Don't need IPv6 for this lab: ipv6_enable="NO" defaultrouter="192.168.2.254" # Polling not supported under Qemu: polling_enable="NO" # Configure IP addresses ifconfig_em5="inet 192.168.2.10 netmask 255.255.255.0" # Don't need Quagga for this lab: quagga_enable="NO"
On R1:
[root@R1]~#cat /var/log/messages | grep vrrp Sep 15 14:24:45 R1 freevrrpd[1214]: server state vrid 1: backup Sep 15 14:25:24 R1 freevrrpd[1214]: server state vrid 2: backup Sep 15 14:27:24 R1 freevrrpd[1214]: server state vrid 1: master Sep 15 14:28:04 R1 freevrrpd[1214]: server state vrid 2: master
R1 is the VRRP master for vrid 1 and 2.
On R2:
[root@R2]~#cat /var/log/messages | grep vrrp Sep 15 14:30:06 R2 freevrrpd[1228]: server state vrid 1: backup Sep 15 14:30:33 R2 freevrrpd[1228]: server state vrid 2: backup
R2 is the VRRP backup for vrid 1 and 2.
Pinging R4 from R3:
[root@R3]~#ping 192.168.2.10 PING 192.168.2.10 (192.168.2.10): 56 data bytes 64 bytes from 192.168.2.10: icmp_seq=0 ttl=63 time=2.932 ms 64 bytes from 192.168.2.10: icmp_seq=1 ttl=63 time=2.360 ms
And checking ARP cache:
[root@R3]~#arp -a | grep 192.168.1.254 ? (192.168.1.254) at 00:00:5e:00:01:01 on em4 [ethernet]
Disable one interface on R1 for changing the VRRP states:
[root@R1]~#ifconfig em4 down [root@R1]~#Sep 15 15:08:33 R1 freevrrpd[1214]: can't write to socket: Network is down Sep 15 15:08:33 R1 freevrrpd[1214]: There is a big problem here ! Sep 15 15:08:35 R1 freevrrpd[1214]: interface em4 is faulty, deactivated from VRRP VRIDs Sep 15 15:08:35 R1 freevrrpd[1214]: VRID 2 (interface em5) has been deactivated due to dependance
And check that R2 became the master:
[root@R2]~#tail -f /var/log/messages Sep 15 15:09:58 R2 kernel: in_scrubprefix: deletion failed Sep 15 15:10:33 R2 freevrrpd[1228]: server state vrid 1: master Sep 15 15:10:38 R2 kernel: in_scrubprefix: deletion failed Sep 15 15:11:13 R2 freevrrpd[1228]: server state vrid 2: master
And check that R3 still can reach R4:
[root@R3]~#ping 192.168.2.10 PING 192.168.2.10 (192.168.2.10): 56 data bytes 64 bytes from 192.168.2.10: icmp_seq=0 ttl=63 time=9.536 ms 64 bytes from 192.168.2.10: icmp_seq=1 ttl=63 time=3.579 ms