Skip to content

Instantly share code, notes, and snippets.

@higebu
Last active April 10, 2023 06:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save higebu/35ea9ff4960976ab2469a1c3993e97cc to your computer and use it in GitHub Desktop.
Save higebu/35ea9ff4960976ab2469a1c3993e97cc to your computer and use it in GitHub Desktop.
IETF116 Hackathon GoBGP Configuration

OS

Ubuntu 22.04

cloud-init

#cloud-config
hostname: gobgp
manage_etc_hosts: True
timezone: Asia/Tokyo
system_info:
  default_user:
    name: cisco
password: cisco
chpasswd: { expire: False }
ssh_pwauth: True
ssh_authorized_keys:
    - "YOUR_SSH_PUBLIC_KEY"

Network

/etc/netplan/50-cloud-init.yaml

network:
    ethernets:
        lo:
            addresses: ["2001::2/128"]
        ens2:
            dhcp4: true
        ens3:
          routes:
            - to: "2001::8"
              via: "fe80::5054:ff:fe11:88fb"
              on-link: true
            - to: "2001::4"
              via: "fe80::4"
              on-link: true
    version: 2

GoBGP

install_gobgp.sh

#!/usr/bin/env bash
set -e
wget https://go.dev/dl/go1.20.2.linux-amd64.tar.gz
tar xf go1.20.2.linux-amd64.tar.gz
mv go /usr/local/
export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export PATH=$GOPATH/bin:$GOROOT/bin:$PATH
wget https://github.com/osrg/gobgp/archive/refs/heads/master.zip
unzip master.zip
cd gobgp-master
go build ./cmd/gobgp
go build ./cmd/gobgpd
mv gobgpd /usr/bin/
mv gobgp /usr/bin/
wget https://raw.githubusercontent.com/osrg/gobgp/master/tools/contrib/centos/gobgpd.service
mv gobgpd.service /etc/systemd/system/
mkdir /etc/gobgpd
cat <<'EOF' | tee /etc/gobgpd/gobgpd.conf
[global.config]
    as = 65182
    router-id = "2.2.2.2"
    local-address-list = ["2001::2"]
EOF
groupadd --system gobgpd
useradd --system -d /var/lib/gobgpd -s /bin/bash -g gobgpd gobgpd
systemctl enable gobgpd
systemctl start gobgpd

/etc/gobgpd/gobgpd.conf

[global.config]
    as = 65182
    router-id = "2.2.2.2"
    local-address-list = ["2001::2"]
[[neighbors]]
    [neighbors.config]
        peer-as = 65182
        local-as = 65182
        neighbor-address = "2001::1"
    [[neighbors.afi-safis]]
        [neighbors.afi-safis.config]
            afi-safi-name = "ipv4-mup"
    [[neighbors.afi-safis]]
        [neighbors.afi-safis.config]
            afi-safi-name = "ipv6-mup"
[[neighbors]]
    [neighbors.config]
        peer-as = 65182
        local-as = 65182
        neighbor-address = "2001::4"
    [[neighbors.afi-safis]]
        [neighbors.afi-safis.config]
            afi-safi-name = "ipv4-mup"
    [[neighbors.afi-safis]]
        [neighbors.afi-safis.config]
            afi-safi-name = "ipv6-mup"
[[neighbors]]
    [neighbors.config]
        peer-as = 65182
        local-as = 65182
        neighbor-address = "2001::5"
    [[neighbors.afi-safis]]
        [neighbors.afi-safis.config]
            afi-safi-name = "ipv4-mup"
    [[neighbors.afi-safis]]
        [neighbors.afi-safis.config]
            afi-safi-name = "ipv6-mup"
[[neighbors]]
    [neighbors.config]
        peer-as = 65182
        local-as = 65182
        neighbor-address = "2001::7"
    [[neighbors.afi-safis]]
        [neighbors.afi-safis.config]
            afi-safi-name = "ipv4-mup"
    [[neighbors.afi-safis]]
        [neighbors.afi-safis.config]
            afi-safi-name = "ipv6-mup"
[[neighbors]]
    [neighbors.config]
        peer-as = 65182
        local-as = 65182
        neighbor-address = "2001::8"
    [[neighbors.afi-safis]]
        [neighbors.afi-safis.config]
            afi-safi-name = "ipv4-mup"
    [[neighbors.afi-safis]]
        [neighbors.afi-safis.config]
            afi-safi-name = "ipv6-mup"
[[neighbors]]
    [neighbors.config]
        peer-as = 65182
        local-as = 65182
        neighbor-address = "2001::9"
    [[neighbors.afi-safis]]
        [neighbors.afi-safis.config]
            afi-safi-name = "ipv4-mup"
    [[neighbors.afi-safis]]
        [neighbors.afi-safis.config]
            afi-safi-name = "ipv6-mup"

Commmands

gobgp global rib add -a ipv4-mup isd 10.0.0.0/24 rd 2.2.2.2:1 prefix 2001:db8:1:1::/64 locator-node-length 24 function-length 16 behavior ENDM_GTP4E rt 100:1000 nexthop 2001::2
gobgp global rib add -a ipv4-mup dsd 10.0.0.1 rd 2.2.2.2:1 prefix 2001:db8:1:1::/64 locator-node-length 24 function-length 16 behavior END_DT4 rt 100:1000 mup 10:10 nexthop 2001::2
gobgp global rib add -a ipv4-mup t1st 192.168.0.0/24 rd 2.2.2.2:1 rt 10:10 teid 12345 qfi 9 endpoint 10.0.0.1 nexthop 2001::2
gobgp global rib add -a ipv4-mup t2st 10.0.0.1 rd 2.2.2.2:1 rt 10:10 endpoint-address-length 64 teid 12345 mup 10:10 nexthop 2001::2

gobgp global rib add -a ipv6-mup isd 2001::/64 rd 2.2.2.2:1 prefix 2001:db8:1:1::/64 locator-node-length 24 function-length 16 behavior ENDM_GTP6E rt 100:1000 nexthop 2001::2
gobgp global rib add -a ipv6-mup dsd 2001::1 rd 2.2.2.2:1 prefix 2001:db8:2:2::/64 locator-node-length 24 function-length 16 behavior END_DT6 rt 100:1000 mup 10:10 nexthop 2001::2
gobgp global rib add -a ipv6-mup t1st 2001:db8:1:1::1/128 rd 2.2.2.2:1 rt 10:10 teid 12345 qfi 9 endpoint 2001::2 nexthop 2001::2
gobgp global rib add -a ipv6-mup t2st 2001::1 rd 2.2.2.2:1 rt 10:10 endpoint-address-length 160 teid 12345 mup 10:10 nexthop 2001::2

gobgp global rib del -a ipv4-mup isd 10.0.0.0/24 rd 2.2.2.2:1 prefix 2001:db8:1:1::/64 locator-node-length 24 function-length 16 behavior ENDM_GTP4E rt 10:10 nexthop 2001::2
gobgp global rib del -a ipv4-mup dsd 10.0.0.1 rd 2.2.2.2:1 prefix 2001:db8:1:1::/64 locator-node-length 24 function-length 16 behavior END_DT4 rt 10:10 mup 10:10 nexthop 2001::2
gobgp global rib del -a ipv4-mup t1st 192.168.0.0/24 rd 2.2.2.2:1 rt 10:10 teid 12345 qfi 9 endpoint 10.0.0.1 nexthop 2001::2
gobgp global rib del -a ipv4-mup t2st 10.0.0.1 rd 2.2.2.2:1 rt 10:10 endpoint-address-length 64 teid 12345 mup 10:10 nexthop 2001::2

gobgp global rib del -a ipv6-mup isd 2001::/64 rd 2.2.2.2:1 prefix 2001:db8:1:1::/64 locator-node-length 24 function-length 16 behavior ENDM_GTP6E rt 10:10 nexthop 2001::2
gobgp global rib del -a ipv6-mup dsd 2001::1 rd 2.2.2.2:1 prefix 2001:db8:2:2::/64 locator-node-length 24 function-length 16 behavior END_DT6 rt 10:10 mup 10:10 nexthop 2001::2
gobgp global rib del -a ipv6-mup t1st 2001:db8:1:1::1/128 rd 2.2.2.2:1 rt 10:10 teid 12345 qfi 9 endpoint 2001::2 nexthop 2001::2
gobgp global rib del -a ipv6-mup t2st 2001::1 rd 2.2.2.2:1 rt 10:10 endpoint-address-length 160 teid 12345 mup 10:10 nexthop 2001::2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment