2
0
mirror of https://github.com/knorrie/network-examples synced 2025-08-30 05:58:31 +00:00

bgp-contd: lxc files

This commit is contained in:
Hans van Kranenburg 2015-08-11 15:04:05 +02:00
parent 2c25bfb1c2
commit 62f11b9ae2
15 changed files with 854 additions and 0 deletions

View File

@ -0,0 +1,88 @@
router id 10.0.0.0;
log "/var/log/bird/bird6.log" all;
debug protocols { states, routes, filters, interfaces }
protocol kernel {
import none;
export all;
}
protocol device {
# defaults...
}
protocol ospf {
area 0 {
# BIRD ignores the IPv6 lo because it has no link local address
stubnet 2001:db8::ff/128;
interface "ibgp" {
};
interface "ebgp_r10" {
stub;
};
};
}
protocol static {
import all;
route 2001:db8::/48 blackhole;
}
##############################################################################
# BGP table
#
# Use this routing table to gather external routes received via BGP which we
# want push to the kernel via our master table and to other routers in our AS
# via iBGP or even to other routers outside our AS again (transit), which can
# be connected here or to a router elsewhere on the border of our AS.
table t_bgp;
protocol pipe p_master_to_bgp {
table master;
peer table t_bgp;
import all; # default
export none; # default
}
##############################################################################
# eBGP R10
#
table t_r10;
protocol static originate_to_r10 {
table t_r10;
import all; # originate here
route 2001:db8::/48 blackhole;
}
protocol bgp ebgp_r10 {
table t_r10;
local 2001:db8:0:3::ff as 65000;
neighbor 2001:db8:0:3::10 as 65010;
import all;
export all;
}
protocol pipe p_bgp_to_r10 {
table t_bgp;
peer table t_r10;
import where proto = "ebgp_r10";
export none;
}
##############################################################################
# iBGP
#
protocol bgp ibgp_r2 {
table t_bgp;
igp table master;
import none;
export all;
local 2001:db8::ff as 65000;
neighbor 2001:db8::2 as 65000;
}

View File

@ -0,0 +1,18 @@
auto lo
iface lo inet loopback
up ip addr add 2001:db8::ff/128 dev lo
down ip addr del 2001:db8::ff/128 dev lo
auto ibgp
iface ibgp inet manual
up ip link set up dev ibgp
up ip addr add 2001:db8:0:1::ff/120 dev ibgp
down ip addr del 2001:db8:0:1::ff/120 dev ibgp
down ip link set down dev ibgp
auto ebgp_r10
iface ebgp_r10 inet manual
up ip link set up dev ebgp_r10
up ip addr add 2001:db8:0:3::ff/120 dev ebgp_r10
down ip addr del 2001:db8:0:3::ff/120 dev ebgp_r10
down ip link set down dev ebgp_r10

View File

@ -0,0 +1,118 @@
router id 10.0.0.1;
log "/var/log/bird/bird6.log" all;
debug protocols { states, routes, filters, interfaces }
protocol kernel {
import none;
export all;
}
protocol device {
# defaults...
}
protocol ospf {
area 0 {
# BIRD ignores the IPv6 lo because it has no link local address
stubnet 2001:db8::1/128;
interface "ibgp" {
};
interface "ebgp_r11" {
stub;
};
interface "ebgp_r20" {
stub;
};
};
}
protocol static {
import all;
route 2001:db8::/48 blackhole;
}
##############################################################################
# BGP table
#
# Use this routing table to gather external routes received via BGP which we
# want push to the kernel via our master table and to other routers in our AS
# via iBGP or even to other routers outside our AS again (transit), which can
# be connected here or to a router elsewhere on the border of our AS.
table t_bgp;
protocol pipe p_master_to_bgp {
table master;
peer table t_bgp;
import all; # default
export none; # default
}
##############################################################################
# eBGP R11
#
table t_r11;
protocol static originate_to_r11 {
table t_r11;
import all; # originate here
route 2001:db8::/48 blackhole;
}
protocol bgp ebgp_r11 {
table t_r11;
local 2001:db8:10:4::1 as 65000;
neighbor 2001:db8:10:4::11 as 65010;
import all;
export all;
}
protocol pipe p_bgp_to_r11 {
table t_bgp;
peer table t_r11;
import where proto = "ebgp_r11";
export none;
}
##############################################################################
# eBGP R20
#
table t_r20;
protocol static originate_to_r20 {
table t_r20;
import all; # originate here
route 2001:db8::/48 blackhole;
}
protocol bgp ebgp_r20 {
table t_r20;
local 2001:db8:0:5::1 as 65000;
neighbor 2001:db8:0:5::20 as 65020;
import all;
export all;
}
protocol pipe p_bgp_to_r20 {
table t_bgp;
peer table t_r20;
import where proto = "ebgp_r20";
export none;
}
##############################################################################
# iBGP
#
protocol bgp ibgp_r2 {
table t_bgp;
igp table master;
import none;
export all;
local 2001:db8::1 as 65000;
neighbor 2001:db8::2 as 65000;
}

View File

@ -0,0 +1,25 @@
auto lo
iface lo inet loopback
up ip addr add 2001:db8::1/128 dev lo
down ip addr del 2001:db8::1/128 dev lo
auto ibgp
iface ibgp inet manual
up ip link set up dev ibgp
up ip addr add 2001:db8:0:1::1/120 dev ibgp
down ip addr del 2001:db8:0:1::1/120 dev ibgp
down ip link set down dev ibgp
auto ebgp_r11
iface ebgp_r11 inet manual
up ip link set up dev ebgp_r11
up ip addr add 2001:db8:10:4::1/120 dev ebgp_r11
down ip addr del 2001:db8:10:4::1/120 dev ebgp_r11
down ip link set down dev ebgp_r11
auto ebgp_r20
iface ebgp_r20 inet manual
up ip link set up dev ebgp_r20
up ip addr add 2001:db8:0:5::1/120 dev ebgp_r20
down ip addr del 2001:db8:0:5::1/120 dev ebgp_r20
down ip link set down dev ebgp_r20

View File

@ -0,0 +1,118 @@
router id 10.0.0.10;
log "/var/log/bird/bird6.log" all;
debug protocols { states, routes, filters, interfaces }
protocol kernel {
import none;
export all;
}
protocol device {
# defaults...
}
protocol ospf {
area 0 {
# BIRD ignores the IPv6 lo because it has no link local address
stubnet 2001:db8:10::10/128;
interface "ibgp" {
};
interface "ebgp_r0" {
stub;
};
interface "ebgp_r20" {
stub;
};
};
}
protocol static {
import all;
route 2001:db8:10::/48 blackhole;
}
##############################################################################
# BGP table
#
# Use this routing table to gather external routes received via BGP which we
# want push to the kernel via our master table and to other routers in our AS
# via iBGP or even to other routers outside our AS again (transit), which can
# be connected here or to a router elsewhere on the border of our AS.
table t_bgp;
protocol pipe p_master_to_bgp {
table master;
peer table t_bgp;
import all; # default
export none; # default
}
##############################################################################
# eBGP R0
#
table t_r0;
protocol static originate_to_r0 {
table t_r0;
import all; # originate here
route 2001:db8:10::/48 blackhole;
}
protocol bgp ebgp_r0 {
table t_r0;
local 2001:db8:0:3::10 as 65010;
neighbor 2001:db8:0:3::ff as 65000;
import all;
export all;
}
protocol pipe p_bgp_to_r0 {
table t_bgp;
peer table t_r0;
import where proto = "ebgp_r0";
export none;
}
##############################################################################
# eBGP R20
#
table t_r20;
protocol static originate_to_r20 {
table t_r20;
import all; # originate here
route 2001:db8:10::/48 blackhole;
}
protocol bgp ebgp_r20 {
table t_r20;
local 2001:db8:10:6::10 as 65010;
neighbor 2001:db8:10:6::20 as 65020;
import all;
export all;
}
protocol pipe p_bgp_to_r20 {
table t_bgp;
peer table t_r20;
import where proto = "ebgp_r20";
export none;
}
##############################################################################
# iBGP
#
protocol bgp ibgp_r12 {
table t_bgp;
igp table master;
import none;
export all;
local 2001:db8:10::10 as 65010;
neighbor 2001:db8:10::12 as 65010;
}

View File

@ -0,0 +1,25 @@
auto lo
iface lo inet loopback
up ip addr add 2001:db8:10::10/128 dev lo
down ip addr del 2001:db8:10::10/128 dev lo
auto ibgp
iface ibgp inet manual
up ip link set up dev ibgp
up ip addr add 2001:db8:10:2::10/120 dev ibgp
down ip addr del 2001:db8:10:2::10/120 dev ibgp
down ip link set down dev ibgp
auto ebgp_r0
iface ebgp_r0 inet manual
up ip link set up dev ebgp_r0
up ip addr add 2001:db8:0:3::10/120 dev ebgp_r0
down ip addr del 2001:db8:0:3::10/120 dev ebgp_r0
down ip link set down dev ebgp_r0
auto ebgp_r20
iface ebgp_r20 inet manual
up ip link set up dev ebgp_r20
up ip addr add 2001:db8:10:6::10/120 dev ebgp_r20
down ip addr del 2001:db8:10:6::10/120 dev ebgp_r20
down ip link set down dev ebgp_r20

View File

@ -0,0 +1,88 @@
router id 10.0.0.11;
log "/var/log/bird/bird6.log" all;
debug protocols { states, routes, filters, interfaces }
protocol kernel {
import none;
export all;
}
protocol device {
# defaults...
}
protocol ospf {
area 0 {
# BIRD ignores the IPv6 lo because it has no link local address
stubnet 2001:db8:10::11/128;
interface "ibgp" {
};
interface "ebgp_r1" {
stub;
};
};
}
protocol static {
import all;
route 2001:db8:10::/48 blackhole;
}
##############################################################################
# BGP table
#
# Use this routing table to gather external routes received via BGP which we
# want push to the kernel via our master table and to other routers in our AS
# via iBGP or even to other routers outside our AS again (transit), which can
# be connected here or to a router elsewhere on the border of our AS.
table t_bgp;
protocol pipe p_master_to_bgp {
table master;
peer table t_bgp;
import all; # default
export none; # default
}
##############################################################################
# eBGP R1
#
table t_r1;
protocol static originate_to_r1 {
table t_r1;
import all; # originate here
route 2001:db8:10::/48 blackhole;
}
protocol bgp ebgp_r1 {
table t_r1;
local 2001:db8:10:4::11 as 65010;
neighbor 2001:db8:10:4::1 as 65000;
import all;
export all;
}
protocol pipe p_bgp_to_r1 {
table t_bgp;
peer table t_r1;
import where proto = "ebgp_r1";
export none;
}
##############################################################################
# iBGP
#
protocol bgp ibgp_r12 {
table t_bgp;
igp table master;
import none;
export all;
local 2001:db8:10::11 as 65010;
neighbor 2001:db8:10::12 as 65010;
}

View File

@ -0,0 +1,18 @@
auto lo
iface lo inet loopback
up ip addr add 2001:db8:10::11/128 dev lo
down ip addr del 2001:db8:10::11/128 dev lo
auto ibgp
iface ibgp inet manual
up ip link set up dev ibgp
up ip addr add 2001:db8:10:2::11/120 dev ibgp
down ip addr del 2001:db8:10:2::11/120 dev ibgp
down ip link set down dev ibgp
auto ebgp_r1
iface ebgp_r1 inet manual
up ip link set up dev ebgp_r1
up ip addr add 2001:db8:10:4::11/120 dev ebgp_r1
down ip addr del 2001:db8:10:4::11/120 dev ebgp_r1
down ip link set down dev ebgp_r1

View File

@ -0,0 +1,45 @@
router id 10.0.0.12;
log "/var/log/bird/bird6.log" all;
debug protocols { states, routes, filters, interfaces }
protocol kernel {
import none;
export all;
}
protocol device {
# defaults...
}
protocol ospf {
area 0 {
# BIRD ignores the IPv6 lo because it has no link local address
stubnet 2001:db8:10::12/128;
interface "ibgp" {
};
};
}
protocol static {
import all;
route 2001:db8:10::/48 blackhole;
}
##############################################################################
# iBGP
#
protocol bgp ibgp_r10 {
import all;
export none;
local 2001:db8:10::12 as 65010;
neighbor 2001:db8:10::10 as 65010;
}
protocol bgp ibgp_r11 {
import all;
export none;
local 2001:db8:10::12 as 65010;
neighbor 2001:db8:10::11 as 65010;
}

View File

@ -0,0 +1,11 @@
auto lo
iface lo inet loopback
up ip addr add 2001:db8:10::12/128 dev lo
down ip addr del 2001:db8:10::12/128 dev lo
auto ibgp
iface ibgp inet manual
up ip link set up dev ibgp
up ip addr add 2001:db8:10:2::12/120 dev ibgp
down ip addr del 2001:db8:10:2::12/120 dev ibgp
down ip link set down dev ibgp

View File

@ -0,0 +1,45 @@
router id 10.0.0.2;
log "/var/log/bird/bird6.log" all;
debug protocols { states, routes, filters, interfaces }
protocol kernel {
import none;
export all;
}
protocol device {
# defaults...
}
protocol ospf {
area 0 {
# BIRD ignores the IPv6 lo because it has no link local address
stubnet 2001:db8::2/128;
interface "ibgp" {
};
};
}
protocol static {
import all;
route 2001:db8::/48 blackhole;
}
##############################################################################
# iBGP
#
protocol bgp ibgp_r0 {
import all;
export none;
local 2001:db8::2 as 65000;
neighbor 2001:db8::ff as 65000;
}
protocol bgp ibgp_r1 {
import all;
export none;
local 2001:db8::2 as 65000;
neighbor 2001:db8::1 as 65000;
}

View File

@ -0,0 +1,11 @@
auto lo
iface lo inet loopback
up ip addr add 2001:db8::2/128 dev lo
down ip addr del 2001:db8::2/128 dev lo
auto ibgp
iface ibgp inet manual
up ip link set up dev ibgp
up ip addr add 2001:db8:0:1::2/120 dev ibgp
down ip addr del 2001:db8:0:1::2/120 dev ibgp
down ip link set down dev ibgp

View File

@ -0,0 +1,103 @@
router id 10.0.0.20;
log "/var/log/bird/bird6.log" all;
debug protocols { states, routes, filters, interfaces }
protocol kernel {
import none;
export all;
}
protocol device {
# defaults...
}
protocol ospf {
area 0 {
# BIRD ignores the IPv6 lo because it has no link local address
stubnet 2001:db8:20::20/128;
interface "ebgp_r1" {
stub;
};
interface "ebgp_r10" {
stub;
};
};
}
protocol static {
import all;
route 2001:db8:20::/48 blackhole;
}
##############################################################################
# BGP table
#
# Use this routing table to gather external routes received via BGP which we
# want push to the kernel via our master table and to other routers in our AS
# via iBGP or even to other routers outside our AS again (transit), which can
# be connected here or to a router elsewhere on the border of our AS.
table t_bgp;
protocol pipe p_master_to_bgp {
table master;
peer table t_bgp;
import all; # default
export none; # default
}
##############################################################################
# eBGP R1
#
table t_r1;
protocol static originate_to_r1 {
table t_r1;
import all; # originate here
route 2001:db8:20::/48 blackhole;
}
protocol bgp ebgp_r1 {
table t_r1;
local 2001:db8:0:5::20 as 65020;
neighbor 2001:db8:0:5::1 as 65000;
import all;
export all;
}
protocol pipe p_bgp_to_r1 {
table t_bgp;
peer table t_r1;
import where proto = "ebgp_r1";
export none;
}
##############################################################################
# eBGP R10
#
table t_r10;
protocol static originate_to_r10 {
table t_r10;
import all; # originate here
route 2001:db8:20::/48 blackhole;
}
protocol bgp ebgp_r10 {
table t_r10;
local 2001:db8:10:6::20 as 65020;
neighbor 2001:db8:10:6::10 as 65010;
import all;
export all;
}
protocol pipe p_bgp_to_r10 {
table t_bgp;
peer table t_r10;
import where proto = "ebgp_r10";
export none;
}

View File

@ -0,0 +1,18 @@
auto lo
iface lo inet loopback
up ip addr add 2001:db8:20::20/128 dev lo
down ip addr del 2001:db8:20::20/128 dev lo
auto ebgp_r1
iface ebgp_r1 inet manual
up ip link set up dev ebgp_r1
up ip addr add 2001:db8:0:5::20/120 dev ebgp_r1
down ip addr del 2001:db8:0:5::20/120 dev ebgp_r1
down ip link set down dev ebgp_r1
auto ebgp_r10
iface ebgp_r10 inet manual
up ip link set up dev ebgp_r10
up ip addr add 2001:db8:10:6::20/120 dev ebgp_r10
down ip addr del 2001:db8:10:6::20/120 dev ebgp_r10
down ip link set down dev ebgp_r10

123
bgp-contd/lxc/fixnetwork.sh Normal file
View File

@ -0,0 +1,123 @@
#!/bin/sh
sed -i '/lxc.network/d' R*/config
cat <<EOF >> R0/config
lxc.network.type = veth
lxc.network.flags = up
lxc.network.name = ibgp
lxc.network.veth.pair = r0.1
lxc.network.script.up = /etc/lxc/lxc-openvswitch
lxc.network.script.down = /etc/lxc/lxc-openvswitch
lxc.network.type = veth
lxc.network.flags = up
lxc.network.name = ebgp_r10
lxc.network.veth.pair = r0.3
lxc.network.script.up = /etc/lxc/lxc-openvswitch
lxc.network.script.down = /etc/lxc/lxc-openvswitch
EOF
cat <<EOF >> R1/config
lxc.network.type = veth
lxc.network.flags = up
lxc.network.name = ibgp
lxc.network.veth.pair = r1.1
lxc.network.script.up = /etc/lxc/lxc-openvswitch
lxc.network.script.down = /etc/lxc/lxc-openvswitch
lxc.network.type = veth
lxc.network.flags = up
lxc.network.name = ebgp_r11
lxc.network.veth.pair = r1.4
lxc.network.script.up = /etc/lxc/lxc-openvswitch
lxc.network.script.down = /etc/lxc/lxc-openvswitch
lxc.network.type = veth
lxc.network.flags = up
lxc.network.name = ebgp_r20
lxc.network.veth.pair = r1.5
lxc.network.script.up = /etc/lxc/lxc-openvswitch
lxc.network.script.down = /etc/lxc/lxc-openvswitch
EOF
cat <<EOF >> R2/config
lxc.network.type = veth
lxc.network.flags = up
lxc.network.name = ibgp
lxc.network.veth.pair = r2.1
lxc.network.script.up = /etc/lxc/lxc-openvswitch
lxc.network.script.down = /etc/lxc/lxc-openvswitch
EOF
cat <<EOF >> R10/config
lxc.network.type = veth
lxc.network.flags = up
lxc.network.name = ibgp
lxc.network.veth.pair = r10.2
lxc.network.script.up = /etc/lxc/lxc-openvswitch
lxc.network.script.down = /etc/lxc/lxc-openvswitch
lxc.network.type = veth
lxc.network.flags = up
lxc.network.name = ebgp_r0
lxc.network.veth.pair = r10.3
lxc.network.script.up = /etc/lxc/lxc-openvswitch
lxc.network.script.down = /etc/lxc/lxc-openvswitch
lxc.network.type = veth
lxc.network.flags = up
lxc.network.name = ebgp_r20
lxc.network.veth.pair = r10.6
lxc.network.script.up = /etc/lxc/lxc-openvswitch
lxc.network.script.down = /etc/lxc/lxc-openvswitch
EOF
cat <<EOF >> R11/config
lxc.network.type = veth
lxc.network.flags = up
lxc.network.name = ibgp
lxc.network.veth.pair = r11.2
lxc.network.script.up = /etc/lxc/lxc-openvswitch
lxc.network.script.down = /etc/lxc/lxc-openvswitch
lxc.network.type = veth
lxc.network.flags = up
lxc.network.name = ebgp_r1
lxc.network.veth.pair = r11.4
lxc.network.script.up = /etc/lxc/lxc-openvswitch
lxc.network.script.down = /etc/lxc/lxc-openvswitch
EOF
cat <<EOF >> R12/config
lxc.network.type = veth
lxc.network.flags = up
lxc.network.name = ibgp
lxc.network.veth.pair = r12.2
lxc.network.script.up = /etc/lxc/lxc-openvswitch
lxc.network.script.down = /etc/lxc/lxc-openvswitch
EOF
cat <<EOF >> R20/config
lxc.network.type = veth
lxc.network.flags = up
lxc.network.name = ebgp_r1
lxc.network.veth.pair = r20.5
lxc.network.script.up = /etc/lxc/lxc-openvswitch
lxc.network.script.down = /etc/lxc/lxc-openvswitch
lxc.network.type = veth
lxc.network.flags = up
lxc.network.name = ebgp_r10
lxc.network.veth.pair = r20.6
lxc.network.script.up = /etc/lxc/lxc-openvswitch
lxc.network.script.down = /etc/lxc/lxc-openvswitch
EOF