Skip to content

Instantly share code, notes, and snippets.

@takehaya
Last active May 18, 2023 01:03
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 takehaya/f64396cdf309f1bdc0866aa93d1d3d51 to your computer and use it in GitHub Desktop.
Save takehaya/f64396cdf309f1bdc0866aa93d1d3d51 to your computer and use it in GitHub Desktop.
cml2 のラボ情報です。
lab:
description: ''
notes: ''
title: takemio_exabpg_gobgp
version: 0.1.0
links:
- id: l0
n1: n1
n2: n0
i1: i0
i2: i0
label: unmanaged-switch-0-port0<->ext-conn-0-port
- id: l1
n1: n1
n2: n2
i1: i1
i2: i0
label: unmanaged-switch-0-port1<->ubuntu-0-ens2
- id: l2
n1: n1
n2: n3
i1: i2
i2: i0
label: unmanaged-switch-0-port2<->ubuntu-1-ens2
- id: l3
n1: n3
n2: n2
i1: i1
i2: i1
label: ubuntu-1-ens3<->ubuntu-0-ens3
nodes:
- boot_disk_size: 0
configuration: virbr0
cpu_limit: 100
cpus: 0
data_volume: 0
hide_links: false
id: n0
label: ext-conn-0
node_definition: external_connector
ram: 0
tags: []
x: 711
y: 94
interfaces:
- id: i0
label: port
slot: 0
type: physical
- boot_disk_size: 0
configuration: ums-001ba2f0-08
cpu_limit: 100
cpus: 0
data_volume: 0
hide_links: false
id: n1
label: unmanaged-switch-0
node_definition: unmanaged_switch
ram: 0
tags: []
x: 714
y: 247
interfaces:
- id: i0
label: port0
slot: 0
type: physical
- id: i1
label: port1
slot: 1
type: physical
- id: i2
label: port2
slot: 2
type: physical
- id: i3
label: port3
slot: 3
type: physical
- id: i4
label: port4
slot: 4
type: physical
- id: i5
label: port5
slot: 5
type: physical
- id: i6
label: port6
slot: 6
type: physical
- id: i7
label: port7
slot: 7
type: physical
- boot_disk_size: 64
configuration: |2-
#cloud-config
hostname: exabgp1
manage_etc_hosts: True
timezone: Asia/Tokyo
system_info:
default_user:
name: cisco
password: cisco
chpasswd: { expire: False }
ssh_pwauth: True
ssh_authorized_keys:
- "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIACOor1kHlXoIicx/opFdgJ+E/ltzHDj2I5fDmhlZOOE higebu"
- "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBXdvi0JZGUBQGb4YNEg3/RzwPGdnBw0+0yfW74g64PQ takemio"
packages:
- unzip
- make
- python3
- python3-pip
write_files:
- path: /root/install-exabgp.sh
permissions: 0744
owner: root
content: |
#!/usr/bin/env bash
set -e
apt-get update
curl -sSL https://install.python-poetry.org | python3 -
wget https://github.com/Exa-Networks/exabgp/archive/refs/heads/main.zip
unzip main.zip
pushd exabgp-main
make build
pip install --system ./dist/exabgp-5.0.0-py3-none-any.whl
cat << EOF >/etc/systemd/system/exabgp.service
[Unit]
Description=ExaBGP
Documentation=man:exabgp(1)
Documentation=man:exabgp.conf(5)
Documentation=https://github.com/Exa-Networks/exabgp/wiki
After=network.target
ConditionPathExists=/etc/exabgp/exabgp.conf
[Service]
User=exabgp
Group=exabgp
Environment=exabgp_daemon_daemonize=false
RuntimeDirectory=exabgp
RuntimeDirectoryMode=0750
ExecStartPre=-/usr/bin/mkfifo /run/exabgp/exabgp.in
ExecStartPre=-/usr/bin/mkfifo /run/exabgp/exabgp.out
ExecStart=/usr/local/bin/exabgp /etc/exabgp/exabgp.conf
ExecReload=/bin/kill -USR1 $MAINPID
Restart=always
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
popd
mkdir /etc/exabgp
cat << EOF > /etc/exabgp/exabgp.conf
neighbor 10.0.1.2 {
router-id 10.0.1.1;
local-address 10.0.1.1;
local-as 65000;
peer-as 65000;
family {
ipv4 mup;
ipv6 mup;
}
announce {
ipv4 {
mup \
mup-isd 10.0.2.0/24 rd 100:100 \
next-hop 2001::1 \
extended-community [ target:10:10 ] \
bgp-prefix-sid-srv6 ( l3-service 2001:db8:1:1:: 0x48 [64,24,16,0,0,0] );
mup \
mup-dsd 10.0.1.1 rd 100:100 \
next-hop 2001::2 \
extended-community [ target:10:10 mup:10:10 ] \
bgp-prefix-sid-srv6 ( l3-service 2001:db8:1:1:: 0x13 [64,24,16,0,0,0] );
mup \
mup-t1st 192.168.0.1/32 rd 100:100 teid 12345 qfi 9 endpoint 10.0.1.1 \
next-hop 10.0.1.2 \
extended-community [ target:10:10 ];
mup \
mup-t2st 10.0.1.1 rd 100:100 teid 12345/32 \
next-hop 10.0.1.2 \
extended-community [ target:10:10 mup:10:10 ];
}
ipv6 {
mup \
mup-isd 2001::/64 rd 100:100 \
next-hop 2001::2 \
extended-community [ target:10:10 ] \
bgp-prefix-sid-srv6 ( l3-service 2001:db8:1:1:: 0x47 [64,24,16,0,0,0] );
mup \
mup-dsd 2001::1 rd 100:100 \
next-hop 2001::2 \
extended-community [ target:10:10 mup:10:10 ] \
bgp-prefix-sid-srv6 ( l3-service 2001:db8:2:2:: 0x18 [64,24,16,0,0,0] );
mup \
mup-t1st 2001:db8:1:1::1/128 rd 100:100 teid 12345 qfi 9 endpoint 2001::1\
next-hop 10.0.1.2 \
extended-community [ target:10:10 ];
mup \
mup-t2st 2001::1 rd 100:100 teid 12345/32 \
next-hop 10.0.1.2 \
extended-community [ target:10:10 mup:10:10 ];
}
}
}
EOF
groupadd --system exabgp
useradd --system -d /var/lib/exabgp -s /bin/bash -g exabgp exabgp
systemctl enable exabgp
systemctl start exabgp
- path: /etc/netplan/50-cloud-init.yaml
content: |
network:
ethernets:
ens2:
dhcp4: true
ens3:
addresses:
- 10.0.1.1/24
dhcp4: false
nameservers:
addresses:
- 1.1.1.1
version: 2
runcmd:
- sudo netplan apply
- sudo bash /root/install-exabgp.sh
cpu_limit: 100
cpus: 1
data_volume: 0
hide_links: false
id: n2
label: exabgp
node_definition: ubuntu
ram: 2048
tags: []
x: 576
y: 399
interfaces:
- id: i0
label: ens2
slot: 0
type: physical
- id: i1
label: ens3
slot: 1
type: physical
- boot_disk_size: 64
configuration: |-
#cloud-config
hostname: gobgp1
manage_etc_hosts: True
timezone: Asia/Tokyo
system_info:
default_user:
name: cisco
password: cisco
chpasswd: { expire: False }
ssh_pwauth: True
ssh_authorized_keys:
- "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIACOor1kHlXoIicx/opFdgJ+E/ltzHDj2I5fDmhlZOOE higebu"
- "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBXdvi0JZGUBQGb4YNEg3/RzwPGdnBw0+0yfW74g64PQ takemio"
packages:
- unzip
write_files:
- path: /home/cisco/install-gobgp.sh
permissions: 0744
owner: root
content: |
#!/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 = 65000
router-id = "10.0.1.2"
local-address-list = ["10.0.1.2"]
[[neighbors]]
[neighbors.config]
neighbor-address = "10.0.1.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"
EOF
groupadd --system gobgpd
useradd --system -d /var/lib/gobgpd -s /bin/bash -g gobgpd gobgpd
systemctl enable gobgpd
systemctl start gobgpd
- path: /etc/netplan/50-cloud-init.yaml
content: |
network:
ethernets:
ens2:
dhcp4: true
ens3:
addresses:
- 10.0.1.2/24
dhcp4: false
nameservers:
addresses:
- 1.1.1.1
version: 2
runcmd:
- sudo netplan apply
- sudo bash /home/cisco/install-gobgp.sh
cpu_limit: 100
cpus: 1
data_volume: 0
hide_links: false
id: n3
label: gobgp
node_definition: ubuntu
ram: 2048
tags: []
x: 834
y: 402
interfaces:
- id: i0
label: ens2
slot: 0
type: physical
- id: i1
label: ens3
slot: 1
type: physical
@takehaya
Copy link
Author

gobgp global rib add \
    -a ipv4-mup \
    isd 10.0.1.0/24 \
    rd 100:100 \
    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 add \
      -a ipv4-mup \
      dsd 10.0.1.2 \
      rd 100:100 \
      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 add \
      -a ipv4-mup \
      t1st 192.168.1.1/32 \
      rd 100:100 \
      rt 10:10 \
      teid 12345 \
      qfi 9 \
      endpoint 10.0.1.2 \
      nexthop 10.0.1.1
  gobgp global rib add \
      -a ipv4-mup \
      t2st 10.0.1.2 \
      rd 100:100 \
      rt 10:10 \
      teid 12345 \
      mup 10:10 \
      endpoint-address-length 64 \
      nexthop 10.0.1.1
  gobgp global rib add \
    -a ipv6-mup isd 2002::/64 \
    rd 100:100 \
    prefix 2002:db8:1:1::/64 \
    locator-node-length 24 \
    function-length 16 \
    behavior ENDM_GTP6E \
    rt 10:10 \
    nexthop 2002::2
  gobgp global rib add \
      -a ipv6-mup \
      dsd 2002::1 \
      rd 100:100 \
      prefix 2002:db8:2:2::/64 \
      locator-node-length 24 \
      function-length 16 \
      behavior END_DT6 \
      rt 10:10 \
      mup 10:10 \
      nexthop 2002::2
gobgp global rib add \
    -a ipv6-mup \
    t1st 2002:db8:1:1::1/128 \
    rd 100:100 \
    rt 10:10 \
    teid 12345 \
    qfi 9 \
    endpoint 2002::1 \
    nexthop 10.0.0.1
gobgp global rib add \
      -a ipv6-mup \
      t2st 2002::1 \
      rd 100:100 \
      rt 10:10 \
     endpoint-address-length 160 \
      teid 12345 \
      mup 10:10 \
      nexthop 10.0.0.1

@takehaya
Copy link
Author

takehaya commented May 18, 2023

cisco@exabgp1:~$ sudo exabgp-cli show adj-rib in
command: show adj-rib in
neighbor 10.0.1.2 ipv4 mup mup:isd::100:100:10.0.1.0/24
neighbor 10.0.1.2 ipv4 mup mup:dsd::100:100:10.0.1.2
neighbor 10.0.1.2 ipv4 mup mup:t1st::100:100:192.168.1.1/32:12345:9:32:10.0.1.2
neighbor 10.0.1.2 ipv4 mup mup:t2st::100:100:64:10.0.1.2:12345:
cisco@exabgp1:~$ sudo exabgp-cli show adj-rib out
command: show adj-rib out
neighbor 10.0.1.2 ipv4 mup mup:isd::100:100:10.0.2.0/24
neighbor 10.0.1.2 ipv4 mup mup:dsd::100:100:10.0.1.1
neighbor 10.0.1.2 ipv4 mup mup:t1st::100:100:192.168.0.1/32:12345:9:32:10.0.1.1
neighbor 10.0.1.2 ipv4 mup mup:t2st::100:100:64:10.0.1.1:12345:
neighbor 10.0.1.2 ipv6 mup mup:isd::100:100:2001::/64
neighbor 10.0.1.2 ipv6 mup mup:dsd::100:100:2001::1
neighbor 10.0.1.2 ipv6 mup mup:t1st::100:100:2001:db8:1:1::1/128:12345:9:128:2001::1
neighbor 10.0.1.2 ipv6 mup mup:t2st::100:100:160:2001::1:12345:

@takehaya
Copy link
Author

takehaya commented May 18, 2023

cisco@gobgp1:~$ gobgp neighbor 10.0.1.1 adj-in -a ipv4-mup 
   ID  Network                                                                                Next Hop             AS_PATH              Age        Attrs
   0   [type:t1st][rd:100:100][prefix:192.168.0.1/32]                                         10.0.1.2                                  00:44:52   [{Origin: i} {LocalPref: 100} {Extcomms: [10:10]}]
   0   [type:t2st][rd:100:100][endpoint-address-length:64][endpoint:10.0.1.1][teid:0.0.48.57] 10.0.1.2                                  00:44:52   [{Origin: i} {LocalPref: 100} {Extcomms: [10:10], [10:10]}]
   0   [type:isd][rd:100:100][prefix:10.0.2.0/24]                                             2001::1                                   00:44:52   [{Origin: i} {LocalPref: 100} {Extcomms: [10:10]} {Prefix SID attributes: {SRv6 L3 Service Attribute: {SRv6 Information Sub TLV: SID: 2001:db8:1:1:: Flag: 0 Endpoint Behavior: 72 {SRv6 Structure Sub Sub TLV: [ Locator Block Length: 64, Locator Node Length: 24, Function Length: 16, Argument Length: 0, Transposition Length: 0, Transposition Offset: 0] } } } }]
   0   [type:dsd][rd:100:100][prefix:10.0.1.1]                                                2001::2                                   00:44:52   [{Origin: i} {LocalPref: 100} {Extcomms: [10:10], [10:10]} {Prefix SID attributes: {SRv6 L3 Service Attribute: {SRv6 Information Sub TLV: SID: 2001:db8:1:1:: Flag: 0 Endpoint Behavior: 19 {SRv6 Structure Sub Sub TLV: [ Locator Block Length: 64, Locator Node Length: 24, Function Length: 16, Argument Length: 0, Transposition Length: 0, Transposition Offset: 0] } } } }]
cisco@gobgp1:~$ gobgp neighbor 10.0.1.1 adj-in -a ipv6-mup 
   ID  Network                                                                                Next Hop             AS_PATH              Age        Attrs
   0   [type:isd][rd:100:100][prefix:2001::/64]                                               2001::2                                   00:44:59   [{Origin: i} {LocalPref: 100} {Extcomms: [10:10]} {Prefix SID attributes: {SRv6 L3 Service Attribute: {SRv6 Information Sub TLV: SID: 2001:db8:1:1:: Flag: 0 Endpoint Behavior: 71 {SRv6 Structure Sub Sub TLV: [ Locator Block Length: 64, Locator Node Length: 24, Function Length: 16, Argument Length: 0, Transposition Length: 0, Transposition Offset: 0] } } } }]
   0   [type:dsd][rd:100:100][prefix:2001::1]                                                 2001::2                                   00:44:59   [{Origin: i} {LocalPref: 100} {Extcomms: [10:10], [10:10]} {Prefix SID attributes: {SRv6 L3 Service Attribute: {SRv6 Information Sub TLV: SID: 2001:db8:2:2:: Flag: 0 Endpoint Behavior: 24 {SRv6 Structure Sub Sub TLV: [ Locator Block Length: 64, Locator Node Length: 24, Function Length: 16, Argument Length: 0, Transposition Length: 0, Transposition Offset: 0] } } } }]
   0   [type:t1st][rd:100:100][prefix:2001:db8:1:1::1/128]                                    10.0.1.2                                  00:44:59   [{Origin: i} {LocalPref: 100} {Extcomms: [10:10]}]
   0   [type:t2st][rd:100:100][endpoint-address-length:160][endpoint:2001::1][teid:0.0.48.57] 10.0.1.2                                  00:44:59   [{Origin: i} {LocalPref: 100} {Extcomms: [10:10], [10:10]}]
cisco@gobgp1:~$ gobgp neighbor 10.0.1.1 adj-out -a ipv4-mup 
   ID  Network                                                                                Next Hop             AS_PATH              Attrs
   1   [type:t1st][rd:100:100][prefix:192.168.1.1/32]                                         10.0.1.1                                  [{Origin: ?} {LocalPref: 100} {Extcomms: [10:10]}]
   1   [type:t2st][rd:100:100][endpoint-address-length:64][endpoint:10.0.1.2][teid:0.0.48.57] 10.0.1.1                                  [{Origin: ?} {LocalPref: 100} {Extcomms: [10:10], [10:10]}]
   1   [type:isd][rd:100:100][prefix:10.0.1.0/24]                                             2001::2                                   [{Origin: ?} {LocalPref: 100} {Extcomms: [10:10]} {Prefix SID attributes: {SRv6 L3 Service Attribute: {SRv6 Information Sub TLV: SID: 2001:db8:1:1:: Flag: 0 Endpoint Behavior: 72 {SRv6 Structure Sub Sub TLV: [ Locator Block Length: 64, Locator Node Length: 24, Function Length: 16, Argument Length: 0, Transposition Length: 0, Transposition Offset: 0] } } } }]
   1   [type:dsd][rd:100:100][prefix:10.0.1.2]                                                2001::2                                   [{Origin: ?} {LocalPref: 100} {Extcomms: [10:10], [10:10]} {Prefix SID attributes: {SRv6 L3 Service Attribute: {SRv6 Information Sub TLV: SID: 2001:db8:1:1:: Flag: 0 Endpoint Behavior: 19 {SRv6 Structure Sub Sub TLV: [ Locator Block Length: 64, Locator Node Length: 24, Function Length: 16, Argument Length: 0, Transposition Length: 0, Transposition Offset: 0] } } } }]
cisco@gobgp1:~$ gobgp neighbor 10.0.1.1 adj-out -a ipv6-mup 
   ID  Network                                                                                Next Hop             AS_PATH              Attrs
   1   [type:dsd][rd:100:100][prefix:2002::1]                                                 2002::2                                   [{Origin: ?} {LocalPref: 100} {Extcomms: [10:10], [10:10]} {Prefix SID attributes: {SRv6 L3 Service Attribute: {SRv6 Information Sub TLV: SID: 2002:db8:2:2:: Flag: 0 Endpoint Behavior: 18 {SRv6 Structure Sub Sub TLV: [ Locator Block Length: 64, Locator Node Length: 24, Function Length: 16, Argument Length: 0, Transposition Length: 0, Transposition Offset: 0] } } } }]
   1   [type:t1st][rd:100:100][prefix:2002:db8:1:1::1/128]                                    10.0.0.1                                  [{Origin: ?} {LocalPref: 100} {Extcomms: [10:10]}]
   1   [type:t2st][rd:100:100][endpoint-address-length:160][endpoint:2002::1][teid:0.0.48.57] 10.0.0.1                                  [{Origin: ?} {LocalPref: 100} {Extcomms: [10:10], [10:10]}]
   1   [type:isd][rd:100:100][prefix:2002::/64]                                               2002::2                                   [{Origin: ?} {LocalPref: 100} {Extcomms: [10:10]} {Prefix SID attributes: {SRv6 L3 Service Attribute: {SRv6 Information Sub TLV: SID: 2002:db8:1:1:: Flag: 0 Endpoint Behavior: 71 {SRv6 Structure Sub Sub TLV: [ Locator Block Length: 64, Locator Node Length: 24, Function Length: 16, Argument Length: 0, Transposition Length: 0, Transposition Offset: 0] } } } }]

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