cEOS supports four interfaces, but we only use its Cli and Bash interfaces in this lab. You can use the docker exec command to launch these two interfaces without an account and password. For example, use the following command to start a bash shell on device R1.
In the Cli interface, you get the device console and configure the device using its domain-specific commands. You can find a complete guide of all available commands on Arista's official document.
Note
Available commands and their usage may change on newer cEOS versions. Currently, we use cEOS 4.29.2F.
For example, we can check the routing table using show ip route.
R1>show ip route
VRF: default
Codes: C - connected, S - static, K - kernel,
O - OSPF, IA - OSPF inter area, E1 - OSPF external type 1,
E2 - OSPF external type 2, N1 - OSPF NSSA external type 1,
N2 - OSPF NSSA external type2, B - Other BGP Routes,
B I - iBGP, B E - eBGP, R - RIP, I L1 - IS-IS level 1,
I L2 - IS-IS level 2, O3 - OSPFv3, A B - BGP Aggregate,
A O - OSPF Summary, NG - Nexthop Group Static Route,
V - VXLAN Control Service, M - Martian,
DH - DHCP client installed default route,
DP - Dynamic Policy Route, L - VRF Leaked,
G - gRIBI, RC - Route Cache Route
Gateway of last resort is not set
C 1.1.1.0/24 is directly connected, Loopback0
C 10.1.1.0/24 is directly connected, Ethernet1
We will endlessly use this command during this lab to debug our configurations, but it's not very interesting currently. Since there is still no any running routing protocol, the router could only reach its two local interfaces.
If you are familiar with network devices, you must be accustomed to typing enable and configure to enter the privileged global configuration mode.
You could learn the current mode from the prompt: # means the privileged mode, the same as a root shell on Linux; () shows the current configuration "scope". You need to enter a specific configuration mode to configure certain resources.
For example, you need to enter the BGP configuration mode to add BGP peers, and you need to enter the interface configuration mode to assign an IP address to it. Using commands in incorrect configuration modes gives you an "invalid input" error response at the best, and ruins all your configurations at worst.
Topology
In Lab I, we set up 3 routers on 3 ASes, as shown below.
Lab 1 Target Network Topology
We use the same naming convention during three labs, so you could remember interface names and IP addresses more easily.
For a router N (N is a number from 1 to 9), it has a local IPv4 address N.N.N.N.
For a link L (L is also a number from 1 to 9) connecting router N and M, the interface on the side of N is assigned IPv4 address 10.1.L.N, while the interface on the side of M is assigned 10.1.L.M. We use the `/24`` subnet for all addresses for simplicity.
We say that router N is connected with router M only when it could send a packet to M.M.M.M using its local address N.N.N.N. Currently, Router 1 could send a packet to 10.1.1.2 from 10.1.1.1 since they are directly connected. But Router 1 has not learned how to reach 2.2.2.2, so Router 1 and Router 2 have not been connected yet.
BGP Configurations
We start the configuration from Router 1. Launch the Cli of Router 1, and enter the privileged mode using enable and configure. We omit these two steps and assume that you are already in the privileged mode in the following guidelines.
We can validate the state of BGP using the command show ip bgp summary. It's disabled by default. To make the router work as a BGP router, we need to enter the BGP configuration mode using router bgp <AS number>.
R1(config)#show ip bgp summaryBGP is disabled for VRF defaultR1(config)#router bgp 1R1(config-router-bgp)#show ip bgp summaryBGP summary information for VRF defaultRouter identifier 1.1.1.1, local AS number 1Neighbor Status Codes: m - Under maintenance Neighbor V AS MsgRcvd MsgSent InQ OutQ Up/Down State PfxRcd PfxAcc
We can see that the BGP is enabled now. But the router still knows nothing about the network as it has not talked to any neighbor yet. We need to configure the BGP neighbors on both endpoints using the command neighbor <IP address> remote-as <AS number> to establish BGP peers. Let's start with R1.
R1(config-router-bgp)#show ip bgp neighborR1(config-router-bgp)#neighbor 10.1.1.2 remote-as 2R1(config-router-bgp)#show ip bgp neighborBGP neighbor is 10.1.1.2, remote AS 2, external link Last read never, last write never ......
Configuring the BGP neighbor relationship on R2 using the same command, we can verify the BGP neighborship using the command show ip bgp neighbor on R1 again.
R1(config-router-bgp)#BGP neighbor is 10.1.1.2, remote AS 2, external link BGP version 4, remote router ID 2.2.2.2, VRF default Last read 00:00:37, last write 00:00:37 ......
R1(config-router-bgp)#show ip routeVRF: defaultCodes: C - connected, S - static, K - kernel, O - OSPF, IA - OSPF inter area, E1 - OSPF external type 1, E2 - OSPF external type 2, N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type2, B - Other BGP Routes, B I - iBGP, B E - eBGP, R - RIP, I L1 - IS-IS level 1, I L2 - IS-IS level 2, O3 - OSPFv3, A B - BGP Aggregate, A O - OSPF Summary, NG - Nexthop Group Static Route, V - VXLAN Control Service, M - Martian, DH - DHCP client installed default route, DP - Dynamic Policy Route, L - VRF Leaked, G - gRIBI, RC - Route Cache RouteGateway of last resort is not setC 1.1.1.0/24 is directly connected, Loopback0C 10.1.1.0/24 is directly connected, Ethernet1R1#exit
R2(config-router-bgp)#show ip routeVRF: defaultCodes: C - connected, S - static, K - kernel, O - OSPF, IA - OSPF inter area, E1 - OSPF external type 1, E2 - OSPF external type 2, N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type2, B - Other BGP Routes, B I - iBGP, B E - eBGP, R - RIP, I L1 - IS-IS level 1, I L2 - IS-IS level 2, O3 - OSPFv3, A B - BGP Aggregate, A O - OSPF Summary, NG - Nexthop Group Static Route, V - VXLAN Control Service, M - Martian, DH - DHCP client installed default route, DP - Dynamic Policy Route, L - VRF Leaked, G - gRIBI, RC - Route Cache RouteGateway of last resort is not setC 2.2.2.0/24 is directly connected, Loopback0C 10.1.1.0/24 is directly connected, Ethernet1C 10.1.2.0/24 is directly connected, Ethernet2
We can see that the BGP is not advertising any networks to its peers. We can request BGP to advertise a network to its peers using network <network address>. As an example, let's advertise the local address 1.1.1.1 on R1 to its peers, and 2.2.2.2 on R2 to its peers.
Check the routing table again, we could find that the routing information is correctly advertised. B indicates that the route is learned from BGP while E indicates that this is an external route.
R1(config-router-bgp)#show ip routeVRF: defaultCodes: C - connected, S - static, K - kernel, O - OSPF, IA - OSPF inter area, E1 - OSPF external type 1, E2 - OSPF external type 2, N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type2, B - Other BGP Routes, B I - iBGP, B E - eBGP, R - RIP, I L1 - IS-IS level 1, I L2 - IS-IS level 2, O3 - OSPFv3, A B - BGP Aggregate, A O - OSPF Summary, NG - Nexthop Group Static Route, V - VXLAN Control Service, M - Martian, DH - DHCP client installed default route, DP - Dynamic Policy Route, L - VRF Leaked, G - gRIBI, RC - Route Cache RouteGateway of last resort is not setC 1.1.1.0/24 is directly connected, Loopback0B E 2.2.2.0/24 [200/0] via 10.1.1.2, Ethernet1C 10.1.1.0/24 is directly connected, Ethernet1
R2(config-router-bgp)#show ip routeVRF: defaultCodes: C - connected, S - static, K - kernel, O - OSPF, IA - OSPF inter area, E1 - OSPF external type 1, E2 - OSPF external type 2, N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type2, B - Other BGP Routes, B I - iBGP, B E - eBGP, R - RIP, I L1 - IS-IS level 1, I L2 - IS-IS level 2, O3 - OSPFv3, A B - BGP Aggregate, A O - OSPF Summary, NG - Nexthop Group Static Route, V - VXLAN Control Service, M - Martian, DH - DHCP client installed default route, DP - Dynamic Policy Route, L - VRF Leaked, G - gRIBI, RC - Route Cache RouteGateway of last resort is not setB E 1.1.1.0/24 [200/0] via 10.1.1.1, Ethernet1C 2.2.2.0/24 is directly connected, Loopback0C 10.1.1.0/24 is directly connected, Ethernet1C 10.1.2.0/24 is directly connected, Ethernet2
We can also use the command redistribute connected to redistribute all "connected" routes altogether. It distributes all network that is directly connected to the router (noted as C in the output of the command show ip route), including the local interface.
We can configure R3 following identical steps. But don't forget to set up the peer relationship between R2 and R3 on R2.
R1>show ip routeVRF: defaultCodes: C - connected, S - static, K - kernel, O - OSPF, IA - OSPF inter area, E1 - OSPF external type 1, E2 - OSPF external type 2, N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type2, B - Other BGP Routes, B I - iBGP, B E - eBGP, R - RIP, I L1 - IS-IS level 1, I L2 - IS-IS level 2, O3 - OSPFv3, A B - BGP Aggregate, A O - OSPF Summary, NG - Nexthop Group Static Route, V - VXLAN Control Service, M - Martian, DH - DHCP client installed default route, DP - Dynamic Policy Route, L - VRF Leaked, G - gRIBI, RC - Route Cache RouteGateway of last resort is not setC 1.1.1.0/24 is directly connected, Loopback0B E 2.2.2.0/24 [200/0] via 10.1.1.2, Ethernet1B E 3.3.3.0/24 [200/0] via 10.1.1.2, Ethernet1C 10.1.1.0/24 is directly connected, Ethernet1
R2>show ip routeVRF: defaultCodes: C - connected, S - static, K - kernel, O - OSPF, IA - OSPF inter area, E1 - OSPF external type 1, E2 - OSPF external type 2, N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type2, B - Other BGP Routes, B I - iBGP, B E - eBGP, R - RIP, I L1 - IS-IS level 1, I L2 - IS-IS level 2, O3 - OSPFv3, A B - BGP Aggregate, A O - OSPF Summary, NG - Nexthop Group Static Route, V - VXLAN Control Service, M - Martian, DH - DHCP client installed default route, DP - Dynamic Policy Route, L - VRF Leaked, G - gRIBI, RC - Route Cache RouteGateway of last resort is not setB E 1.1.1.0/24 [200/0] via 10.1.1.1, Ethernet1C 2.2.2.0/24 is directly connected, Loopback0B E 3.3.3.0/24 [200/0] via 10.1.2.3, Ethernet2C 10.1.1.0/24 is directly connected, Ethernet1C 10.1.2.0/24 is directly connected, Ethernet2
R3>show ip routeVRF: defaultCodes: C - connected, S - static, K - kernel, O - OSPF, IA - OSPF inter area, E1 - OSPF external type 1, E2 - OSPF external type 2, N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type2, B - Other BGP Routes, B I - iBGP, B E - eBGP, R - RIP, I L1 - IS-IS level 1, I L2 - IS-IS level 2, O3 - OSPFv3, A B - BGP Aggregate, A O - OSPF Summary, NG - Nexthop Group Static Route, V - VXLAN Control Service, M - Martian, DH - DHCP client installed default route, DP - Dynamic Policy Route, L - VRF Leaked, G - gRIBI, RC - Route Cache RouteGateway of last resort is not setB E 1.1.1.0/24 [200/0] via 10.1.2.2, Ethernet1B E 2.2.2.0/24 [200/0] via 10.1.2.2, Ethernet1C 3.3.3.0/24 is directly connected, Loopback0C 10.1.2.0/24 is directly connected, Ethernet1
Configuration Review
We give a complete list of commands here for reference. You can start from scratch using sudo containerlab deploy -t start.clab.yaml --reconfigure if you make any mistake.
If you are curious about BGP, you may feel disappointed as you learned nothing about how BGP works internally in this lab yet. Though it is not necessary to know the details of BGP to use it in practice, it's not a bad idea to go deeper into BGP, especially when ContainerLab gives us a chance to do so.
Since network cards in containers are just virtual interfaces isolated by network namespaces, we could capture packets received and sent on network cards using tcpdump in the host machine. Specifically, we can capture packets on a network card in the router using the following command:
We provide a capture.sh script in the bgp directory that captures all non-local network interfaces in the background. You could execute it before configuring routers and kill all running tcpdump processes using sudo kill tcpdump after configurations are complete. It dumps packets captured from <interface> on <router> to a pcap file named <router>-<interface>.pcap. You may study the packet trace offline using Wireshark to learn how BGP agents interact.
Here we give an example analyzing a packet trace captured from interface eth1 on router R1 during the router configuration procedure described above.
BGP uses the TCP protocol to exchange routing messages and listens on port 179 to accept TCP connections from other BGP agents. So we can see that router R2 sends an OPEN Message to router R1 at first. It contains the BGP version number (Version 4 defined by RFC 4271), the Autonomous System number (2 as we set), the BGP Identifier (2.2.2.2, which is the IP address of R2's local interface), and the Hold Time (180 seconds). The Hold Time is the maximum time interval that the sender expects to receive a KEEPALIVE or UPDATE message from the receiver of the message.
Frame 20: 123 bytes on wire (984 bits), 123 bytes captured (984 bits)
Ethernet II, Src: aa:c1:ab:23:8f:66 (aa:c1:ab:23:8f:66), Dst: aa:c1:ab:e9:a4:33 (aa:c1:ab:e9:a4:33)
Internet Protocol Version 4, Src: 10.1.1.2, Dst: 10.1.1.1
Transmission Control Protocol, Src Port: 43415, Dst Port: 179, Seq: 1, Ack: 1, Len: 57
Border Gateway Protocol - OPEN Message
Marker: ffffffffffffffffffffffffffffffff
Length: 57
Type: OPEN Message (1)
Version: 4
My AS: 2
Hold Time: 180
BGP Identifier: 2.2.2.2
Optional Parameters Length: 28
Optional Parameters
Optional Parameter: Capability
Parameter Type: Capability (2)
Parameter Length: 26
Capability: Route refresh capability
Capability: Enhanced route refresh capability
Capability: Support for 4-octet AS number capability
Capability: Multiprotocol extensions capability
Capability: Graceful Restart capability
Capability: Support for Additional Paths
R2 sends a route message after a while using BGP UPDATE Message. This packet is an IGP packet (ORIGIN: IGP), it traverses only AS 2 (AS_PATH: 2) and tells R1 that you could reach 10.1.2.0/24, 2.2.2.0/24 and 10.1.1.0/24 (Network Layer Reachability Information) via 10.1.1.2/24 as the next hop (NEXT_HOP: 10.1.1.2).
In our toy topology, BGP messages are straightforward to understand. As the current base of the Internet, practical BGP deployments are more challenging to understand and operate. With ContainerLab, you could design more complicated topologies, apply more extensive routing policies and examine the captured packets to learn how BGP works, in a more realistic approach than reading textbooks or RFCs.