2
0
mirror of https://github.com/knorrie/network-examples synced 2025-08-22 18:19:12 +00:00

OSPF Intro: fixes

* Move removal of old network config into fix_network.sh
* Fix openvswitch port removal on shutdown
* Fix logging
This commit is contained in:
Hans van Kranenburg 2015-06-14 23:51:29 +02:00
parent cccbb10869
commit bb5236f280
6 changed files with 25 additions and 3 deletions

View File

@ -96,7 +96,6 @@ To create the eight containers we need, connected together in different networks
3. Set up the network interfaces in the lxc configuration. This can be done by removing all network related configuration that remains from the cloned birdbase container, and then appending all needed interface configuration by running the fixnetwork.sh script that can be found in `ospf-intro/lxc/` in this git repository. Of course, have a look at the contents of the script first, before executing it. Since this example is only using IPv4 and single IP addresses on the interfaces, I simply added them to the lxc configuration instead of the network/interfaces file inside the container.
sed -i '/lxc.network/d' R*/config H*/config
. ./fixnetwork.sh
4. Copy extra configuration into the containers. The ospf-intro/lxc/ directory inside this git repository contains a little file hierarchy that can just be copied over the configuration of the containers. For each router, it's a network/interfaces configuration file which adds an IP address that corresponds with the Router ID to the loopback interface, and a simple BIRD configuration file that serves as a starting point for our next steps.
@ -176,6 +175,9 @@ Let's have a look at the BIRD configuration of R6:
# cat R6/rootfs/etc/bird/bird.conf
router id 10.9.99.6;
log "/var/log/bird/bird.log" all;
debug protocols { states, routes, filters, interfaces }
protocol kernel {
import none;
export all;
@ -378,8 +380,6 @@ First of all, don't forget to take a look at the BIRD documentation about OSPF.
* Equal cost multipath routing (ECMP) is a big thing nowadays, which is used a lot to load balance traffic over multiple paths to a destination instead of choosing only one as best path. You can even enable that in the network we just built by just specifying `ecmp yes` in the OSPF configuration (try it on R2 or R6) and see what effect it has on the output of `ip r` on the linux command line. Just search for information on it on the Internet to learn more.
* 'Cost' is an aspect that is fundamental to OSPF and the calculation of the shortest paths in the network. Traditionally, cost is related to the bandwith of a link between routers, and causes higher bandwith connections to be prefered above lower bandwith connections. Since we're working with switched Gigabit/s networks by default now, if it's not 10Gb/s, in the datacenter and even in our office, I've just been ignoring that.
Enabling logging is also a nice way to get more insight in the way routing changes happen. There is no syslog daemon running in the containers which are used here, but BIRD can also directly log to a file. An example is to create `/var/log/bird` inside the container, chown it to the bird user, and then set `log "/var/log/bird/bird.log" all;` in `bird.conf`.
Another thing you can play with is rolling out IPv6 on this little network that was just built. It needs a `bird6.conf` configuration file, and you'll soon find out doing IPv6 is very similar to what we did here with IPv4. Just pick some subnets from the `2001:db8::/32` network to work with and there you go.
After completing this tutorial, I also encourage you to start reading the other "An Introduction to OSPF" like pages on the internet, since they should be a lot easier to understand while having seen it work for real! Have fun.

View File

@ -1,6 +1,7 @@
router id 10.9.99.1;
log "/var/log/bird/bird.log" all;
debug protocols { states, routes, filters, interfaces }
protocol kernel {
import none;

View File

@ -1,6 +1,7 @@
router id 10.9.99.2;
log "/var/log/bird/bird.log" all;
debug protocols { states, routes, filters, interfaces }
protocol kernel {
import none;

View File

@ -1,6 +1,7 @@
router id 10.9.99.5;
log "/var/log/bird/bird.log" all;
debug protocols { states, routes, filters, interfaces }
protocol kernel {
import none;

View File

@ -1,5 +1,8 @@
router id 10.9.99.6;
log "/var/log/bird/bird.log" all;
debug protocols { states, routes, filters, interfaces }
protocol kernel {
import none;
export all;

View File

@ -1,11 +1,14 @@
#!/bin/sh
sed -i '/lxc.network/d' R*/config H*/config
cat <<EOF >> R1/config
lxc.network.type = veth
lxc.network.flags = up
lxc.network.name = vlan1001
lxc.network.veth.pair = r1.1001
lxc.network.script.up = /etc/lxc/lxc-openvswitch
lxc.network.script.down = /etc/lxc/lxc-openvswitch
lxc.network.hwaddr = 02:00:0a:00:01:05
lxc.network.ipv4 = 10.0.1.5/24
lxc.network.type = veth
@ -13,6 +16,7 @@ lxc.network.flags = up
lxc.network.name = vlan1012
lxc.network.veth.pair = r1.1012
lxc.network.script.up = /etc/lxc/lxc-openvswitch
lxc.network.script.down = /etc/lxc/lxc-openvswitch
lxc.network.hwaddr = 02:00:0a:01:02:07
lxc.network.ipv4 = 10.1.2.7/24
lxc.network.type = veth
@ -20,6 +24,7 @@ lxc.network.flags = up
lxc.network.name = vlan1356
lxc.network.veth.pair = r1.1356
lxc.network.script.up = /etc/lxc/lxc-openvswitch
lxc.network.script.down = /etc/lxc/lxc-openvswitch
lxc.network.hwaddr = 02:00:0a:03:38:01
lxc.network.ipv4 = 10.3.56.1/24
EOF
@ -30,6 +35,7 @@ lxc.network.flags = up
lxc.network.name = vlan1012
lxc.network.veth.pair = r2.1012
lxc.network.script.up = /etc/lxc/lxc-openvswitch
lxc.network.script.down = /etc/lxc/lxc-openvswitch
lxc.network.hwaddr = 02:00:0a:01:02:7b
lxc.network.ipv4 = 10.1.2.123/24
lxc.network.type = veth
@ -37,6 +43,7 @@ lxc.network.flags = up
lxc.network.name = vlan1082
lxc.network.veth.pair = r2.1082
lxc.network.script.up = /etc/lxc/lxc-openvswitch
lxc.network.script.down = /etc/lxc/lxc-openvswitch
lxc.network.hwaddr = 02:00:0a:08:02:01
lxc.network.ipv4 = 10.8.2.1/24
lxc.network.type = veth
@ -44,6 +51,7 @@ lxc.network.flags = up
lxc.network.name = vlan1050
lxc.network.veth.pair = r2.1050
lxc.network.script.up = /etc/lxc/lxc-openvswitch
lxc.network.script.down = /etc/lxc/lxc-openvswitch
lxc.network.hwaddr = 02:00:0a:32:01:01
lxc.network.ipv4 = 10.50.1.1/24
EOF
@ -54,6 +62,7 @@ lxc.network.flags = up
lxc.network.name = vlan1001
lxc.network.veth.pair = r5.1001
lxc.network.script.up = /etc/lxc/lxc-openvswitch
lxc.network.script.down = /etc/lxc/lxc-openvswitch
lxc.network.hwaddr = 02:00:0a:00:01:04
lxc.network.ipv4 = 10.0.1.4/24
lxc.network.type = veth
@ -61,6 +70,7 @@ lxc.network.flags = up
lxc.network.name = vlan1012
lxc.network.veth.pair = r5.1012
lxc.network.script.up = /etc/lxc/lxc-openvswitch
lxc.network.script.down = /etc/lxc/lxc-openvswitch
lxc.network.hwaddr = 02:00:0a:01:02:38
lxc.network.ipv4 = 10.1.2.56/24
EOF
@ -71,6 +81,7 @@ lxc.network.flags = up
lxc.network.name = vlan1001
lxc.network.veth.pair = r6.1001
lxc.network.script.up = /etc/lxc/lxc-openvswitch
lxc.network.script.down = /etc/lxc/lxc-openvswitch
lxc.network.hwaddr = 02:00:0a:00:01:08
lxc.network.ipv4 = 10.0.1.8/24
lxc.network.type = veth
@ -78,6 +89,7 @@ lxc.network.flags = up
lxc.network.name = vlan1034
lxc.network.veth.pair = r6.1034
lxc.network.script.up = /etc/lxc/lxc-openvswitch
lxc.network.script.down = /etc/lxc/lxc-openvswitch
lxc.network.hwaddr = 02:00:0a:2b:02:01
lxc.network.ipv4 = 10.34.2.1/24
EOF
@ -88,6 +100,7 @@ lxc.network.flags = up
lxc.network.name = vlan1050
lxc.network.veth.pair = h12.1050
lxc.network.script.up = /etc/lxc/lxc-openvswitch
lxc.network.script.down = /etc/lxc/lxc-openvswitch
lxc.network.hwaddr = 02:00:0a:32:01:0c
lxc.network.ipv4 = 10.50.1.12/24
lxc.network.ipv4.gateway = 10.50.1.1
@ -99,6 +112,7 @@ lxc.network.flags = up
lxc.network.name = vlan1082
lxc.network.veth.pair = h10.1082
lxc.network.script.up = /etc/lxc/lxc-openvswitch
lxc.network.script.down = /etc/lxc/lxc-openvswitch
lxc.network.hwaddr = 02:00:0a:08:02:0a
lxc.network.ipv4 = 10.8.2.10/24
lxc.network.ipv4.gateway = 10.8.2.1
@ -110,6 +124,7 @@ lxc.network.flags = up
lxc.network.name = vlan1356
lxc.network.veth.pair = h8.1356
lxc.network.script.up = /etc/lxc/lxc-openvswitch
lxc.network.script.down = /etc/lxc/lxc-openvswitch
lxc.network.hwaddr = 02:00:0a:03:38:08
lxc.network.ipv4 = 10.3.56.8/24
lxc.network.ipv4.gateway = 10.3.56.1
@ -121,6 +136,7 @@ lxc.network.flags = up
lxc.network.name = vlan1034
lxc.network.veth.pair = h5.1034
lxc.network.script.up = /etc/lxc/lxc-openvswitch
lxc.network.script.down = /etc/lxc/lxc-openvswitch
lxc.network.hwaddr = 02:00:0a:2b:02:05
lxc.network.ipv4 = 10.34.2.5/24
lxc.network.ipv4.gateway = 10.34.2.1