Skip to content

Instantly share code, notes, and snippets.

@wavvs
Created October 1, 2018 16:27
Show Gist options
  • Save wavvs/25d61aa075a0ce0d112cbf4f9ae95887 to your computer and use it in GitHub Desktop.
Save wavvs/25d61aa075a0ce0d112cbf4f9ae95887 to your computer and use it in GitHub Desktop.

BGP

Router1

[admin@MikroTik] > ip address add address=10.101.32.1/24 interface=ether2 
[admin@MikroTik] > ip address add address=10.101.33.1/24 interface=ether1 
[admin@MikroTik] > ip address add address=10.101.34.1/24 interface=ether3
[admin@MikroTik] > interface bridge add name=loopback
[admin@MikroTik] > ip address add address=10.101.55.1/32 interface=loopback
[admin@MikroTik] > routing ospf instance set 0 router-id=10.101.55.1
admin@MikroTik] > routing ospf network add network=10.101.32.0/24 area=backbone
[admin@MikroTik] > routing ospf network add network=10.101.33.0/24 area=backbone
[admin@MikroTik] > routing ospf network add network=10.101.34.0/24 area=backbone
[admin@MikroTik] > routing ospf network add network=10.101.55.1/32 area=backbone

Router2

[admin@MikroTik] > ip address add address=10.101.32.2/24 interface=ether1
[admin@MikroTik] > interface bridge add name=loopback
[admin@MikroTik] > ip address add address=10.101.55.2/32 interface=loopback
[admin@MikroTik] > routing ospf instance set 0 router-id=10.101.55.2
[admin@MikroTik] > routing ospf network add network=10.101.32.0/24 area=backbone
[admin@MikroTik] > routing ospf network add network=10.101.55.2/32 area=backbone

Router3

[admin@MikroTik] > ip address add address=10.101.33.2/24 interface=ether1 
[admin@MikroTik] > interface bridge add name=loopback
[admin@MikroTik] > ip address add address=10.101.55.3/32 interface=loopback
[admin@MikroTik] > routing ospf instance set 0 router-id=10.101.55.3
[admin@MikroTik] > routing ospf network add network=10.101.33.0/24 area=backbone

[admin@MikroTik] > routing ospf network add network=10.101.55.3/32 area=backbone

OpenBSD setup

BGP

ubi# rcctl enable bgpd

ubi# bgpctl show fib
flags: * = valid, B = BGP, C = Connected, S = Static, D = Dynamic
       N = BGP Nexthop reachable via this route R = redistributed
       r = reject route, b = blackhole route

flags prio destination          gateway
*B      48 1.1.1.1/32           10.77.0.6
*B      48 2.2.2.2/32           10.77.0.2
*B      48 10.20.0.0/16         10.77.0.2
*CN      4 10.77.0.0/24         link#2
*C       4 10.77.0.0/24         link#3
*B      48 10.77.0.0/24         10.77.0.6
*B      48 10.101.1.0/30        10.77.0.6
*B      48 10.101.1.4/30        10.77.0.6
*B      48 10.101.1.8/30        10.77.0.6
*B      48 10.101.2.0/24        10.77.0.6
*B      48 10.101.3.0/24        10.77.0.6
*B      48 10.101.10.0/24       10.77.0.6
*B      48 10.101.11.0/24       10.77.0.6
*B      48 10.101.20.0/24       10.77.0.6
*B      48 10.101.21.0/24       10.77.0.6
*B      48 10.101.22.0/24       10.77.0.6
*B      48 10.101.23.0/24       10.77.0.6
*B      48 10.101.24.0/24       10.77.0.6
*B      48 10.101.25.0/24       10.77.0.6
*B      48 10.101.26.0/24       10.77.0.6
*B      48 10.101.27.0/24       10.77.0.6
*       32 10.101.32.0/24       10.101.34.1
*       32 10.101.33.0/24       10.101.34.1
*C       4 10.101.34.0/24       link#1
*B      48 10.101.51.1/32       10.77.0.6
*B      48 10.101.51.2/32       10.77.0.6
*B      48 10.101.51.3/32       10.77.0.6
*B      48 10.101.51.4/32       10.77.0.6
*       32 10.101.55.1/32       10.101.34.1
*       32 10.101.55.2/32       10.101.34.1
*       32 10.101.55.3/32       10.101.34.1
*        1 10.101.55.4/32       10.101.55.4
*B      48 10.202.0.0/24        10.77.0.6
*B      48 10.203.0.0/24        10.77.0.6
*B      48 10.204.0.0/24        10.77.0.6
*B      48 10.205.0.0/24        10.77.0.6
*C       0 127.0.0.0/8          link#0
*S  r    8 127.0.0.0/8          127.0.0.1
*        1 127.0.0.1/32         127.0.0.1
*B      48 172.16.30.0/24       10.77.0.6
*B      48 172.16.31.0/24       10.77.0.6
*B      48 172.16.32.0/24       10.77.0.2
*S  r    8 224.0.0.0/4          127.0.0.1
*S  r    8 ::/96                ::1
*C       0 ::1/128              link#0
*        1 ::1/128              ::1
*S  r    8 ::ffff:0.0.0.0/96    ::1
*S  r    8 2002::/24            ::1
*S  r    8 2002:7f00::/24       ::1
*S  r    8 2002:e000::/20       ::1
*S  r    8 2002:ff00::/24       ::1
*S  r    8 fe80::/10            ::1
*        1 fe80:6::1/128        fe80:6::1
*S  r    8 fec0::/10            ::1
*S  r    8 ff01::/16            ::1
*        4 ff01:6::/32          ::1
*S  r    8 ff02::/16            ::1
*        4 ff02:6::/32          ::1

ubi# bgpctl show rib     
flags: * = Valid, > = Selected, I = via IBGP, A = Announced, S = Stale
origin: i = IGP, e = EGP, ? = Incomplete

flags destination          gateway          lpref   med aspath origin
*>    1.1.1.1/32           10.77.0.2          100     0 65002 65001 65000 i
*>    10.77.0.0/24         10.77.0.6          100     0 65002 ?
*>    10.101.1.0/30        10.77.0.2          100     0 65002 65001 ?
*>    10.101.1.4/30        10.77.0.2          100     0 65002 65001 ?
*>    10.101.1.8/30        10.77.0.2          100     0 65002 65001 ?
*>    10.101.2.0/24        10.77.0.2          100     0 65002 65001 ?
*>    10.101.3.0/24        10.77.0.2          100     0 65002 65001 ?
*>    10.101.10.0/24       10.77.0.2          100     0 65002 65001 65006 i
*>    10.101.11.0/24       10.77.0.2          100     0 65002 65001 65006 i
*>    10.101.20.0/24       10.77.0.6          100     0 65002 ?
*>    10.101.21.0/24       10.77.0.6          100     0 65002 ?
*>    10.101.22.0/24       10.77.0.6          100    21 65002 i
*>    10.101.23.0/24       10.77.0.6          100    21 65002 i
*>    10.101.24.0/24       10.77.0.6          100    21 65002 i
*>    10.101.25.0/24       10.77.0.6          100    21 65002 i
*>    10.101.26.0/24       10.77.0.6          100    21 65002 i
*>    10.101.27.0/24       10.77.0.6          100     0 65002 ?
AI*>  10.101.32.0/24       0.0.0.0            100     0 i
AI*>  10.101.33.0/24       0.0.0.0            100     0 i
AI*>  10.101.34.0/24       0.0.0.0            100     0 i
*>    10.101.51.1/32       10.77.0.2          100     0 65002 65001 ?
*>    10.101.51.2/32       10.77.0.2          100     0 65002 65001 ?
*>    10.101.51.3/32       10.77.0.2          100     0 65002 65001 ?
*>    10.101.51.4/32       10.77.0.2          100     0 65002 65001 ?
*>    10.102.3.0/24        10.77.0.2          100     0 65002 65001 65006 65000 65529 65528 i
*>    10.202.0.0/24        10.77.0.6          100    31 65002 i
*>    10.203.0.0/24        10.77.0.6          100    31 65002 i
*>    10.204.0.0/24        10.77.0.6          100    41 65002 i
*>    10.205.0.0/24        10.77.0.6          100    41 65002 i
*>    172.16.30.0/24       10.77.0.2          100     0 65002 65001 65000 i
*>    172.16.31.0/24       10.77.0.2          100     0 65002 65001 65000 i

ping Router2 routing table We can see that ips of redistributed ... appeared.

OpenBSD BGP setting bgpd.conf

AS 65456
router-id 10.101.55.4
network 10.101.32.0/24
network 10.101.33.0/24
network 10.101.34.0/24

match from any inet set rtlabel from_bgpd

neighbor 10.77.0.6 {
        descr "Dima AS"
        remote-as 65002
        tcp md5sig password "C1Sco0nJIovee"

ospfd.conf

router-id 10.101.55.4
redistribute connected
spf-delay msec 1000
spf-holdtime msec 5000

redistribute rtlabel from_bgpd
area 0.0.0.0 {
        interface em0 {
                metric 10
                retransmit-interval 5
                router-dead-time 40
                hello-interval 10
                router-priority 1
                transmit-delay 1
        }
        interface lo1 {
                passive
        }
}

any - Any neighbor will be matched. inet - is an alias for “prefix 0.0.0.0/0 prefixlen >= 0”; rtlabel label - Add the prefix to the kernel routing table with the specified label.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment