Recently, I need to study about Calico over Kubernetis. In fact, I like Flannel rather than this. However, this Calico is also best practice. During start this Calico, I read about the Brid. In this post, I will how to install and configure this Bird.

 

1. What is Bird?

In this site, it is explained "what kinds of dynamic routing is supported?". It is working on Linux also. In my environment, I will use Ubuntu.

 

2. Install the Bird

I will follow this instruction, It show the best way to install like below. I will use first one.

To add the repository for bird, I refer to this instruction,

# sudo add-apt-repository ppa:cz.nic-labs/bird
# sudo apt-get update
# apt-get install bird

After then, I can verify the version like below.

 

3. Configuration for Bird for the system

There are servaral configuration to work as the router or switch. First I will edit the system file "/etc/sysctl.conf"

# vi /etc/sysctl.conf
Uncomment the next line to enable packet forwarding for IPv4
net.ipv4.ip_forward=1

# sysctl -p /etc/sysctl.conf
net.ipv4.ip_forward = 1

I will edit some configure for logging in "/etc/bird/bird.conf". In this file, it is look like below default. I will follow this instruction.

# Change this into your BIRD router ID. It's a world-wide unique identification
# of your router, usually one of router's IPv4 addresses.
router id 198.51.100.1;

# The Kernel protocol is not a real routing protocol. Instead of communicating
# with other routers in the network, it performs synchronization of BIRD's
# routing tables with the OS kernel.
protocol kernel {
        scan time 60;
        import none;
#       export all;   # Actually insert routes into the kernel routing table
}

# The Device protocol is not a real routing protocol. It doesn't generate any
# routes and it only serves as a module for getting information about network
# interfaces from the kernel. 
protocol device {
        scan time 60;
}

# logging
log syslog { debug, trace, info, remote, warning, error, auth, fatal, bug };
log stderr all;
log "/var/log/bird.log" all;

The bold above will be added. However, sometimes you will get the error message like below. Thus In my case I will update file properties.

# chmod 777 /var/log/bird.log

Now I can start this bird.

# systemctl restart bird
# systemctl enable bird

# ps aux | grep -i bird
bird       796  0.0  0.2  15724  2556 ?        Ss   07:33   0:00 /usr/sbin/bird6 -f -u bird -g bird
root      1167  0.0  0.1  14856  1116 pts/0    S+   07:37   0:00 grep --color=auto -i bird

4. Configure the simple BGP routing

This is my environment. I have 2 instance, which have IP address like below. I need to edit "/etc/bird/bird.conf" file

In the default configuration, there is something important variable. 

protocol kernel {
        scan time 60;
        import none;
#       export all;   # Actually insert routes into the kernel routing table
}

# The Device protocol is not a real routing protocol. It doesn't generate any
# routes and it only serves as a module for getting information about network
# interfaces from the kernel. 
protocol device {
        scan time 60;
}

For the Simple BGP configuration, I will follow this sample instruction. I will try to configure I-BGP which mean each host has same as number. 

Host #1 Host #2
# BGP Routing Protocol
protocol static static_bgp { 
        route 1.1.1.1:255.255.255.255 via 10.10.0.159; 
        route 1.1.1.2:255.255.255.255 via 10.10.0.159; 
}

protocol bgp {
        import all;
        export where proto = "static_bgp";

        local as 65001;
        neighbor 10.10.0.205 as 65001;
}

# BGP Routing Protocol 
protocol static static_bgp { 
        route 2.2.2.1:255.255.255.255 via 10.10.0.205; 
        route 2.2.2.2:255.255.255.255 via 10.10.0.205; 
}

protocol bgp {
        import all;
        export where proto = "static_bgp";

        local as 65001;
        neighbor 10.10.0.159 as 65001;
}

In my senario, I will announce the loopback IP address into the BGP routing protocol. "export" is look like "redestribute" option. In the above there is some important option "import" and "export". In this instruction, there is some explain like below.

I need to install into the BGP routing table which received. I need to edit "import all". Now I can verify the status with "birdc" command.

Host #1

Host #2

root@ip-10-10-0-159:~# birdc

BIRD 1.6.8 ready.

bird> show route

1.1.1.1/32         via 10.10.0.159 on ens5 [static_bgp 12:08:06] * (200)

2.2.2.2/32         via 10.10.0.205 on ens5 [bgp1 12:08:11] * (100) [AS65002i]

1.1.1.2/32         via 10.10.0.159 on ens5 [static_bgp 12:08:06] * (200)

2.2.2.1/32         via 10.10.0.205 on ens5 [bgp1 12:08:11] * (100) [AS65002i]

root@ip-10-10-0-205:~# birdc

BIRD 1.6.8 ready.

bird> show route

2.2.2.2/32         via 10.10.0.205 on ens5 [static_bgp 12:07:51] * (200)

1.1.1.1/32         via 10.10.0.159 on ens5 [bgp1 12:08:11] * (100) [AS65001i]

2.2.2.1/32         via 10.10.0.205 on ens5 [static_bgp 12:07:51] * (200)

1.1.1.2/32         via 10.10.0.159 on ens5 [bgp1 12:08:11] * (100) [AS65001i]

I can see the BGP routing table "1.1.1.1", "1.1.1.2", "2.2.2.1" and "2.2.2.2" are updated. Also I can see the status with "show protocols all" command

bird> show protocols all 

name     proto    table    state  since       info

kernel1  Kernel   master   up     12:08:06    

  Preference:     10

  Input filter:   ACCEPT

  Output filter:  REJECT

  Routes:         0 imported, 0 exported, 0 preferred

  Route change stats:     received   rejected   filtered    ignored   accepted

    Import updates:              0          0          0          0          0

    Import withdraws:            0          0        ---          0          0

    Export updates:              6          0          6        ---          0

    Export withdraws:            0        ---        ---        ---          0

device1  Device   master   up     12:08:06    

  Preference:     240

  Input filter:   ACCEPT

  Output filter:  REJECT

  Routes:         0 imported, 0 exported, 0 preferred

  Route change stats:     received   rejected   filtered    ignored   accepted

    Import updates:              0          0          0          0          0

    Import withdraws:            0          0        ---          0          0

    Export updates:              0          0          0        ---          0

    Export withdraws:            0        ---        ---        ---          0

static_bgp Static   master   up     12:08:06    

  Preference:     200

  Input filter:   ACCEPT

  Output filter:  REJECT

  Routes:         2 imported, 0 exported, 2 preferred

  Route change stats:     received   rejected   filtered    ignored   accepted

    Import updates:              2          0          0          0          2

    Import withdraws:            0          0        ---          0          0

    Export updates:              0          0          0        ---          0

    Export withdraws:            0        ---        ---        ---          0

bgp1     BGP      master   up     12:08:11    Established   

  Preference:     100

  Input filter:   ACCEPT

  Output filter:  (unnamed)

  Routes:         2 imported, 2 exported, 2 preferred

  Route change stats:     received   rejected   filtered    ignored   accepted

    Import updates:              2          0          0          0          2

    Import withdraws:            0          0        ---          0          0

    Export updates:              4          2          0        ---          2

    Export withdraws:            0        ---        ---        ---          0

  BGP state:          Established

    Neighbor address: 10.10.0.205

    Neighbor AS:      65002

    Neighbor ID:      10.10.0.205

    Neighbor caps:    refresh enhanced-refresh restart-aware llgr-aware AS4

    Session:          external AS4

    Source address:   10.10.0.159

    Hold timer:       186/240

    Keepalive timer:  52/80

 

5. Installing over the Kernal Routing table

Even if bird has the routing table, I can not see the routing table over the system. 

root@ip-10-10-0-159:~# netstat -nr

Kernel IP routing table

Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface

0.0.0.0         10.10.0.1       0.0.0.0         UG        0 0          0 ens5

10.10.0.0       0.0.0.0         255.255.255.0   U         0 0          0 ens5

10.10.0.1       0.0.0.0         255.255.255.255 UH        0 0          0 ens5

Because of this, It is not easy to verify the status if this routing work or not. I need to edit "/etc/bird/bird.conf"

protocol kernel {

        scan time 60;

        import all;

        export all;

}

After then, the routing table will be like below.

Host #1

Host #2

root@ip-10-10-0-159:~# netstat -nr

Kernel IP routing table

Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface

0.0.0.0         10.10.0.1       0.0.0.0         UG        0 0          0 ens5

1.1.1.1         10.10.0.159     255.255.255.255 UGH       0 0          0 ens5

1.1.1.2         10.10.0.159     255.255.255.255 UGH       0 0          0 ens5

2.2.2.1         10.10.0.205     255.255.255.255 UGH       0 0          0 ens5

2.2.2.2         10.10.0.205     255.255.255.255 UGH       0 0          0 ens5

10.10.0.0       0.0.0.0         255.255.255.0   U         0 0          0 ens5

10.10.0.1       0.0.0.0         255.255.255.255 UH        0 0          0 ens5

root@ip-10-10-0-205:~# netstat -nr

Kernel IP routing table

Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface

0.0.0.0         10.10.0.1       0.0.0.0         UG        0 0          0 ens5

1.1.1.1         10.10.0.159     255.255.255.255 UGH       0 0          0 ens5

1.1.1.2         10.10.0.159     255.255.255.255 UGH       0 0          0 ens5

2.2.2.1         10.10.0.205     255.255.255.255 UGH       0 0          0 ens5

2.2.2.2         10.10.0.205     255.255.255.255 UGH       0 0          0 ens5

10.10.0.0       0.0.0.0         255.255.255.0   U         0 0          0 ens5

10.10.0.1       0.0.0.0         255.255.255.255 UH        0 0          0 ens5

I will use the AWS instance. To verify I need to change the option, "source and destination checking option". This option will drop the packet when the source and destination does not match.

And then, I can transfer ICMP packet like below.

Host #1 Host #2

This is the simple BGP routing with Bird. If I have chance to learn more deep-dive. I will handle about it next time. 

Reference 

[ 1 ] https://bird.network.cz/

[ 2 ] https://gitlab.labs.nic.cz/labs/bird

[ 3 ] https://launchpad.net/~cz.nic-labs/+archive/ubuntu/bird

[ 4 ] https://bird.network.cz/pipermail/bird-users/2011-September/002425.html

[ 5 ] https://blog.marquis.co/configuring-bgp-using-bird-on-ubuntu-14-04lts/

[ 6 ] https://skyenet.tech/bird/

 

 

Recently, I have some questions about the ECMP load-balancing on CISCO switch. I have already known that the traffic will be distrubute according to each interfaces. However, I can not understand the method for this. This is good chance for me to learn.

 

I have read this instruction. I read some terms, "Per Destination" and "Per Packet". In this instruction. It will be more useful to understand.

By this instruction, I can see the configuration paramter on interface like below.

For this verification, I will set up the GNS simulator like below. There are 3 links connected each other.

I will see the wireshark packet over each interface.

 

 

1. Per-Destination Algorithm 

 

"Per-Desination" is default configuration. Therefore, it is now shown when I enter the CLI "ip load-sharing per-destination".

This algorithm is more similar with hashing method. The traffic will transfer over same interface. R1 has 3 loopback IP address, 1.1.1.1, 1.1.1.2 and 1.1.1.3. I will do ICMP with source. The traffic will use different links. However, It will be the same link when the source and destination are same.

 

[R1# ping 2.2.2.2 source 1.1.1.1 repeat 1]

R1 send ICMP request over Fa 2/1 and received over Fa 2/3.

 

[R1# ping 2.2.2.2 source 1.1.1.2 repeat 1]

R1 send ICMP request over Fa 2/2 and received over Fa 2/1.

 

[R1# ping 2.2.2.2 source 1.1.1.3 repeat 1]

R1 send ICMP request over Fa 2/2 and received over Fa 2/1.

 

Now I will do again in 10 minutes. It will be the same result. 

[R1# ping 2.2.2.2 source 1.1.1.2 repeat 1]

R1 send ICMP request over Fa 2/2 and received over Fa 2/1.

 

2. Select load-sharing algorithm for "Per-Destination"

 

This configuration give some option between R1 and R2. "Per-Destination" is the hashing algorithm. Thus R1 and R2 will show the same result. Because of this, some link can be intensive. For example, R1 --> Link 1 --> R2, R2 --> Link 1 --> R1 can be happend. Thus "Universal algorithm" make more dynmic distrubution on each switch with difference link.

 

3. Per Packet Algorithm.

 

I will configure like below on R1 and R2 switch.

After then, I will try to ping to R2. R2 has loopback IP address, 2.2.2.2/32. 

I will get the result like below. This result show that the traffic are distributed by packet, even if it is single connection (source-destination IP address pair)

[FastEthernet 2/1]

[FastEthernet 2/2]

[FastEthernet 2/3]

 

 

Reference

[ 1 ] https://networkengineering.stackexchange.com/questions/27914/example-of-ecmp-uses-hashing-technique

[ 2 ] https://www.cisco.com/c/en/us/td/docs/switches/datacenter/sw/4_2/nx-os/unicast/configuration/guide/l3_cli_nxos/l3_manage-routes.html#wp1114960

[ 3 ] https://www.cisco.com/c/en/us/td/docs/ios-xml/ios/ipswitch_cef/configuration/15-mt/isw-cef-15-mt-book/isw-cef-load-balancing.html#GUID-303F07B8-A52B-4BD3-A1F8-54DF24493D8E

I am the beginner in this Golang. If you are looking for expert, I am not that guy. Anyway, I will tri to write this post as the beginner.

 

1. var and type

 

I think these "var" and  "type" are most used elements.

package main

import "fmt"

func main(){

 var i = 10;

 fmt.Printf("%d\n",i);

}

This is the sample case. "var 1 = 10;" is the part to define the variable. It is different from others. There is no type such as int, float or string. In the Golang, the fomular is like below.

var <names> <type> = <expression>

Value names can be multiple. With this statements, the same case should be written like below.

package main

import "fmt"

func main(){

 var i int = 10;

 fmt.Printf("%d\n",i);

}

In the GoLang, there is implicit statments like below. The "type" is followed from expression type. 

<names> := <expression>

Because of this, the sample case will be re-written like below

package main

import "fmt"

func main(){

 i := 10;

 fmt.Printf("%d\n",i);

}

 

'Programming Basic > GoLang' 카테고리의 다른 글

How to install GoLang in Ubuntu  (0) 2020.03.22

+ Recent posts