When you like to test, how a topology behaves with lots of routes, it’s not that easy to generate them. If you need some few hundred you can use static routes in a router and export them into a routing protocol. But if you need more (and don’t want to connect to a live network) PC based routing software gets handy.

In the following I’m using BIRD (see The BIRD Internet Routing Daemon Project) to generate 20.000 OSPF and 1.000.000 BGP routes.

GNS3 Project

I’m using the BIRD appliance from the GNS3 Marketplace and two IOU router for this test.

GNS3 project

For working with that many routes I have to increase the memory size. I changed the BIRD VM to use 512 MB of RAM (right click / configure). Both IOU router were changed to use 1024 MB of RAM (select both IOU routers / right click / configure).

IOU device config

BIRD appliance base configuration

Edit /opt/bootlocal.sh to set IP address and routes, it should look like this:

#!/bin/sh
# put other system startup commands here
modprobe ipv6
sysctl -w net.ipv4.ip_forward=1
sysctl -w net.ipv6.conf.all.forwarding=1

# Boot parameter "nodhcp": network interfaces are configured statically
if grep -q -w nodhcp /proc/cmdline; then
	# This waits until all devices have registered
	/sbin/udevadm settle --timeout=10

	# configure static interface addresses and routes
	ifconfig eth0 10.1.2.2 netmask 255.255.255.0 up
	route add default gw 10.1.2.1

	# dummy interfaces for announced subnets
	ifconfig lo:1 11.0.0.0 netmask 255.0.0.0
	ifconfig lo:2 12.0.0.0 netmask 255.0.0.0
fi

/usr/local/sbin/bird -u gns3 -g staff
#/usr/local/sbin/bird6 -u gns3 -g staff

Configuring 11.0.0.0/8 and 12.0.0.0/8 as secondary loopback addresses allows us to ping these networks.

This script will later ease the creation of a lot of routes, copy/paste it into the BIRD appliance.

gns3@box:~$ cat > .local/bin/create_routes
#!/usr/bin/awk -f

BEGIN {
	if (ARGC < 3 || ARGC > 4) {
		print "Usage: create_routes <start IP> <count> [<output file>]"
		exit 1
	}

	split(ARGV[1], ip, ".")
	ip[1] += 0; ip[2] += 0; ip[3] += 0; ip[4] += 0
	cnt = ARGV[2]
	out = "/dev/stdout"
	if (ARGC > 3) out = ARGV[3]

	while (--cnt >= 0) {
		print "route " ip[1] "." ip[2] "." ip[3] "." ip[4] "/32 unreachable;" > out

		for (i=4; i>0 && ++ip[i] >= 256; i--)
			ip[i] = 0
	}
}
gns3@box:~$ chmod +x .local/bin/create_routes

Now save these changes and reboot the BIRD appliance.

gns3@box:~$ backup
Backup device is set to: sda1/
Perform backup now? (y/N)y
Backing up files to /mnt/sda1//mydata.tgz/
Done.
gns3@box:~$ sudo reboot

IOU base configuration

After configuring the IP addresses all devices should be able to ping it’s neighbor.

IOU1:

interface Loopback0
 ip address 172.16.1.1 255.255.255.255
!
interface Ethernet0/0
 description link to IOU2
 ip address 10.1.1.1 255.255.255.0
 no shutdown
!
interface Ethernet0/1
 description link to bird appliance
 ip address 10.1.2.1 255.255.255.0
 no shutdown
!

IOU2:

interface Loopback0
 ip address 172.16.1.2 255.255.255.255
!
interface Ethernet0/0
 description link to IOU1
 ip address 10.1.1.2 255.255.255.0
 no shutdown
!

IOU routing protocol configuration

Very basic setup of OSPF and BGP.

The networks 20.1.1.0/24 and 20.1.2.0/24 are announced via BGP, to have a route even without BIRD.

IOU1:

router ospf 1
 router-id 172.16.1.1
 passive-interface Loopback0
 network 0.0.0.0 255.255.255.255 area 0
!
router bgp 65000
 bgp log-neighbor-changes
 network 20.1.1.0 mask 255.255.255.0
 neighbor 10.1.2.2 remote-as 65099
 neighbor 172.16.1.2 remote-as 65000
 neighbor 172.16.1.2 update-source Loopback0
!
ip route 20.1.1.0 255.255.255.0 Null0

IOU2:

router ospf 1
 router-id 172.16.1.2
 passive-interface Loopback0
 network 0.0.0.0 255.255.255.255 area 0
!
router bgp 65000
 bgp log-neighbor-changes
 network 20.1.2.0 mask 255.255.255.0
 neighbor 172.16.1.1 remote-as 65000
 neighbor 172.16.1.1 update-source Loopback0
!
ip route 20.1.2.0 255.255.255.0 Null0

BIRD routing protocol configuration

This configuration reads static routes from /usr/local/etc/bird/static2ospf resp. /usr/local/etc/bird/static2bgp and annouces them via OSPF resp. BGP. Additionally 4 internal OSPF routes are advertized. The routes are not announced to the linux kernel, linux knows only the default route configured in /opt/bootlocal.sh.

Initially we create only 10 OSPF and 10 BGP routes. We want to check, that everything works, before the big test starts.

Don’t forget to save the changes with backup, otherwise they will be lost on the next boot of the BIRD appliance.

gns3@box:~$ cat > /usr/local/etc/bird/bird.conf
log "/var/log/bird.log" all;

router id 172.16.1.100;

protocol device {
	scan time 10;		# Scan interfaces every 10 seconds
}

table ospf_routes;
protocol static static_ospf {
	table ospf_routes;
	import all;

	include "/usr/local/etc/bird/static2ospf";
}

table bgp_routes;
protocol static static_bgp {
	table bgp_routes;
	import all;

	include "/usr/local/etc/bird/static2bgp";
}

protocol ospf ospf1 {
	table ospf_routes;
	import all;
	export filter {
		if source = RTS_STATIC then {
			ospf_metric1 = 1000;		# for E1 routes
			# ospf_metric2 = 1000;		# for E2 routes
			accept;
		}
		reject;
	};

	area 0 {
		# announce some internal routes
		stubnet 11.255.0.0/32;
		stubnet 11.255.0.1/32;
		stubnet 11.255.0.2/32;
		stubnet 11.255.0.3/32;

		# use all ethernet interfaces
		interface "eth*" {
		};
	};
}

protocol bgp bgp1 {
	table bgp_routes;
	import all;
	export filter {
		if source = RTS_STATIC then {
			# Artificially increase path length
			# by advertising local AS number twice
			bgp_path.prepend(65099);
			accept;
		}
		reject;
	};

	local as 65099;
	neighbor 10.1.2.1 as 65000;
}
gns3@box:~$ create_routes
Usage: create_routes <start IP> <count> [<output file>]
gns3@box:~$ create_routes 11.0.0.0 10 /usr/local/etc/bird/static2ospf
gns3@box:~$ create_routes 12.0.0.0 10 /usr/local/etc/bird/static2bgp
gns3@box:~$ backup
Backup device is set to: sda1/
Perform backup now? (y/N)y
Backing up files to /mnt/sda1//mydata.tgz/
Done.
gns3@box:~$

Tests

With birdc configure soft we instruct BIRD to reread the configuration. IOU1 tells us, that the BIRD appliance is detected as a new OSPF and BGP neighbor.

*Mar  9 13:52:56.424: %BGP-5-ADJCHANGE: neighbor 10.1.2.2 Up
*Mar  9 13:52:57.430: %OSPF-5-ADJCHG: Process 1, Nbr 172.16.1.100 on Ethernet0/1 from LOADING to FULL, Loading Done

Furthermore both IOU1 and IOU2 should see the BIRD routes and should be able to ping them.

IOU2#sh ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP
       a - application route
       + - replicated route, % - next hop override

Gateway of last resort is not set

      10.0.0.0/8 is variably subnetted, 3 subnets, 2 masks
C        10.1.1.0/24 is directly connected, Ethernet0/0
L        10.1.1.2/32 is directly connected, Ethernet0/0
O        10.1.2.0/24 [110/20] via 10.1.1.1, 00:50:13, Ethernet0/0
      11.0.0.0/32 is subnetted, 14 subnets
O E1     11.0.0.0 [110/1020] via 10.1.1.1, 00:25:42, Ethernet0/0
O E1     11.0.0.1 [110/1020] via 10.1.1.1, 00:25:42, Ethernet0/0
O E1     11.0.0.2 [110/1020] via 10.1.1.1, 00:25:42, Ethernet0/0
O E1     11.0.0.3 [110/1020] via 10.1.1.1, 00:25:42, Ethernet0/0
O E1     11.0.0.4 [110/1020] via 10.1.1.1, 00:25:42, Ethernet0/0
O E1     11.0.0.5 [110/1020] via 10.1.1.1, 00:25:42, Ethernet0/0
O E1     11.0.0.6 [110/1020] via 10.1.1.1, 00:25:42, Ethernet0/0
O E1     11.0.0.7 [110/1020] via 10.1.1.1, 00:25:42, Ethernet0/0
O E1     11.0.0.8 [110/1020] via 10.1.1.1, 00:25:42, Ethernet0/0
O E1     11.0.0.9 [110/1020] via 10.1.1.1, 00:25:42, Ethernet0/0
O        11.255.0.0 [110/30] via 10.1.1.1, 00:25:42, Ethernet0/0
O        11.255.0.1 [110/30] via 10.1.1.1, 00:25:42, Ethernet0/0
O        11.255.0.2 [110/30] via 10.1.1.1, 00:25:42, Ethernet0/0
O        11.255.0.3 [110/30] via 10.1.1.1, 00:25:42, Ethernet0/0
      12.0.0.0/32 is subnetted, 10 subnets
B        12.0.0.0 [200/0] via 10.1.2.2, 00:25:49
B        12.0.0.1 [200/0] via 10.1.2.2, 00:25:49
B        12.0.0.2 [200/0] via 10.1.2.2, 00:25:49
B        12.0.0.3 [200/0] via 10.1.2.2, 00:25:49
B        12.0.0.4 [200/0] via 10.1.2.2, 00:25:49
B        12.0.0.5 [200/0] via 10.1.2.2, 00:25:49
B        12.0.0.6 [200/0] via 10.1.2.2, 00:25:49
B        12.0.0.7 [200/0] via 10.1.2.2, 00:25:49
B        12.0.0.8 [200/0] via 10.1.2.2, 00:25:49
B        12.0.0.9 [200/0] via 10.1.2.2, 00:25:49
      20.0.0.0/24 is subnetted, 2 subnets
B        20.1.1.0 [200/0] via 172.16.1.1, 00:47:19
S        20.1.2.0 is directly connected, Null0
      172.16.0.0/32 is subnetted, 2 subnets
O        172.16.1.1 [110/11] via 10.1.1.1, 00:50:13, Ethernet0/0
C        172.16.1.2 is directly connected, Loopback0
IOU2#ping 11.0.0.0
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 11.0.0.0, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/1 ms
IOU2#ping 12.0.0.0
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 12.0.0.0, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/4/6 ms
IOU2#

Now we increase the number of routes to 20.000 external OSPF and 1.000.000 BGP routes.

gns3@box:~$ create_routes 11.0.0.0 20000 /usr/local/etc/bird/static2ospf
gns3@box:~$ create_routes 12.0.0.0 1000000 /usr/local/etc/bird/static2bgp
gns3@box:~$ birdc configure soft
BIRD 1.5.0 ready.
Reading configuration from /usr/local/etc/bird.conf
Reconfigured
gns3@box:~$

After a short time the routes should have been distributed.

IOU2#show ip route summary
IP routing table name is default (0x0)
IP routing table maximum-paths is 32
Route Source    Networks    Subnets     Replicates  Overhead    Memory (bytes)
connected       0           3           0           204         540
static          0           1           0           68          180
application     0           0           0           0           0
ospf 1          0           20006       0           1360408     3681104
  Intra-area: 6 Inter-area: 0 External-1: 20000 External-2: 0
  NSSA External-1: 0 NSSA External-2: 0
bgp 65000       0           1000001     0           68000068    180000180
  External: 0 Internal: 1000001 Local: 0
internal        5                                               40801500
Total           5           1020011     0           69360748    224483504
IOU2#ping 11.0.78.31
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 11.0.78.31, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/5 ms
IOU2#ping 12.15.66.63
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 12.15.66.63, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/4/6 ms
IOU2#

But show memory statistics shows, that the IOU memory is almost exhausted, only 32 MB RAM are free. For a bigger number of routes the IOUs need more RAM configured.

IOU2#show memory statistics
                Head    Total(b)     Used(b)     Free(b)   Lowest(b)  Largest(b)
Processor   C0C1C008   912777928   880592384    32185544    32184504    31713900

The BIRD appliance has still 155 MB free, but for much more routes it also needs more RAM.

gns3@box:~$ free
             total         used         free       shared      buffers
Mem:        506852       351764       155088            0         1656
-/+ buffers:             350108       156744
Swap:       115768            0       115768