BGP (Border Gateway Protocol)
Objective
BGP (Border Gateway Protocol) is the protocol that enables the global routing system of the internet. It manages how packets get routed from network to network by exchanging routing and reachability information among edge routers.
BGP enables peering to send packets between autonomous systems (ASes), which are networks managed by a single enterprise or service provider. Together, these ASes make up the public internet.
Establish iBGP session
Establish eBGP session
Establish iBGP with peer group
Establish eBGP with peer group
Establish iBGP with route-reflector
Establish eBGP with access-list
BGP summarization
EBGP Attributes
Weight
Local Preference
MED
Prerequisites
Hardware:
Switches or routers that support VLANs
(e.g., edgecore, ufispace)
Software:
Network operating systems that support VLAN configuration
(e.g., SONiC.master )
Access:
Administrative or privileged CLI access
Network:
Established IP connectivity between BGP neighbors.
Public or private AS numbers, IP addresses for peerings, and agreed routing policies.
Establish iBGP session
Internal Border Gateway Protocol (EBGP) is a Border Gateway Protocol (BGP) extension that is used for communication within autonomous systems (AS). IBGP enables network connections inside autonomous systems (AS).
Topology:
Example:
Basic Configuration Steps
Note: Commands are to be executed in sudo and vtysh mode
Step 1: Configure ip address for interfaces and loopbacks
R1
root@sonic:/home/admin#config interface ip add Ethernet60 10.1.1.2/24
root@sonic:/home/admin#config interface ip add Loopback1 1.1.1.1/32
R2
root@sonic:/home/admin#config interface ip add Ethernet60 10.1.1.4/24
root@sonic:/home/admin#config interface ip add Loopback1 2.2.2.2/32
Step 2: Enter vtysh shell
root@sonic:/home/admin# vtysh
Hello, this is FRRouting (version 8.2.2).
Copyright 1996-2005 Kunihiro Ishiguro, et al.
sonic.PALCNETWORKS.COM#
Step 3: configure BGP router id, network and neighbor session
R1
sonic.PALCNETWORKS.COM# config terminal
Sonic.PALCNETWORKS.COM(config)# router bgp 100
Sonic.PALCNETWORKS.COM(config-router)# bgp router-id 1.1.1.1
Sonic.PALCNETWORKS.COM(config-router)# no bgp ebgp-requires-policy
Sonic.PALCNETWORKS.COM(config-router)# neighbor 10.1.1.4 remote-as 100
Sonic.PALCNETWORKS.COM(config-router)# address-family ipv4 unicast
Sonic.PALCNETWORKS.COM(config-router-af)# network 1.1.1.1/32
Sonic.PALCNETWORKS.COM(config-router-af)# network 10.1.1.0/24
Sonic.PALCNETWORKS.COM(config-router-af) #exit-address-family
Sonic.PALCNETWORKS.COM(config-router)# exit
R2
sonic.PALCNETWORKS.COM# config terminal
Sonic.PALCNETWORKS.COM(config)# router bgp 100
Sonic.PALCNETWORKS.COM(config-router)# bgp router-id 2.2.2.2
Sonic.PALCNETWORKS.COM(config-router)# no bgp ebgp-requires-policy
Sonic.PALCNETWORKS.COM(config-router)# neighbor 10.1.1.2 remote-as 100
Sonic.PALCNETWORKS.COM(config-router)# address-family ipv4 unicast
Sonic.PALCNETWORKS.COM(config-router-af)# network 2.2.2.2/32
Sonic.PALCNETWORKS.COM(config-router-af)# network 10.1.1.0/24
Sonic.PALCNETWORKS.COM(config-router-af) #exit-address-family
Sonic.PALCNETWORKS.COM(config-router)# exit
Note:
Router ID is used to identify routers in AS(autonomous systems). Router ID must be unique for each BGP router in the network.
Step 4: Checking the BGP neighbors
R1
sonic.PALCNETWORKS.COM# show bgp summary
IPv4 Unicast Summary (VRF default):
BGP router identifier 1.1.1.1, local AS number 100 vrf-id 0
BGP table version 3
RIB entries 5, using 920 bytes of memory
Peers 1, using 723 KiB of memory
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt Desc
10.1.1.4 4 100 16 16 0 0 0 00:11:28 2 2 N/A
Total number of neighbors 1
sonic.PALCNETWORKS.COM# show ip bgp neighbors
BGP neighbor is 10.1.1.4, remote AS 100, local AS 100, internal link
Hostname: sonic
BGP version 4, remote router ID 2.2.2.2, local router ID 1.1.1.1
BGP state = Established, up for 00:14:15
Last read 00:00:15, Last write 00:00:15
Hold time is 180, keepalive interval is 60 seconds
Neighbor capabilities:
4 Byte AS: advertised and received
Extended Message: advertised and received
AddPath:
IPv4 Unicast: RX advertised and received
Long-lived Graceful Restart: advertised and received
Address families by peer:
Route refresh: advertised and received(old & new)
Enhanced Route Refresh: advertised and received
Address Family IPv4 Unicast: advertised and received
Hostname Capability: advertised (name: sonic,domain name: n/a) received (name: sonic,domain name: n/a)
Graceful Restart Capability: advertised and received
Remote Restart timer is 120 seconds
Address families by peer:
none
Graceful restart information:
End-of-RIB send: IPv4 Unicast
End-of-RIB received: IPv4 Unicast
Local GR Mode: Helper*
Remote GR Mode: Helper
R bit: True
Timers:
Configured Restart Time(sec): 120
Received Restart Time(sec): 120
IPv4 Unicast:
F bit: False
End-of-RIB sent: Yes
End-of-RIB sent after update: No
End-of-RIB received: Yes
Timers:
Configured Stale Path Time(sec): 360
Message statistics:
Inq depth is 0
Outq depth is 0
Sent Rcvd
Opens: 1 1
Notifications: 0 0
Updates: 3 3
Keepalives: 15 15
Route Refresh: 0 0
Capability: 0 0
Total: 19 19
Minimum time between advertisement runs is 0 seconds
For address family: IPv4 Unicast
Update group 2, subgroup 2
Packet Queue length 0
Community attribute sent to this neighbor(all)
2 accepted prefixes
Connections established 1; dropped 0
Last reset 00:17:54, No AFI/SAFI activated for peer
Local host: 10.1.1.2, Local port: 179
Foreign host: 10.1.1.4, Foreign port: 59054
Nexthop: 10.1.1.2
Nexthop global: fe80::1644:8fff:febc:a2c8
Nexthop local: fe80::1644:8fff:febc:a2c8
BGP connection: shared network
BGP Connect Retry Timer in Seconds: 120
Estimated round trip time: 1 ms
Read thread: on Write thread: on FD used: 26
R2
sonic.PALCNETWORKS.COM# show bgp summary
IPv4 Unicast Summary (VRF default):
BGP router identifier 2.2.2.2, local AS number 100 vrf-id 0
BGP table version 4
RIB entries 5, using 920 bytes of memory
Peers 1, using 723 KiB of memory
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt Desc
10.1.1.2 4 100 17 17 0 0 0 00:12:29 2 2 N/A
Total number of neighbors 1
sonic.PALCNETWORKS.COM# show ip bgp neighbors
BGP neighbor is 10.1.1.2, remote AS 100, local AS 100, internal link
Hostname: sonic
BGP version 4, remote router ID 1.1.1.1, local router ID 2.2.2.2
BGP state = Established, up for 00:12:52
Last read 00:00:52, Last write 00:00:52
Hold time is 180, keepalive interval is 60 seconds
Neighbor capabilities:
4 Byte AS: advertised and received
Extended Message: advertised and received
AddPath:
IPv4 Unicast: RX advertised and received
Long-lived Graceful Restart: advertised and received
Address families by peer:
Route refresh: advertised and received(old & new)
Enhanced Route Refresh: advertised and received
Address Family IPv4 Unicast: advertised and received
Hostname Capability: advertised (name: sonic,domain name: n/a) received (name: sonic,domain name: n/a)
Graceful Restart Capability: advertised and received
Remote Restart timer is 120 seconds
Address families by peer:
none
Graceful restart information:
End-of-RIB send: IPv4 Unicast
End-of-RIB received: IPv4 Unicast
Local GR Mode: Helper*
Remote GR Mode: Helper
R bit: False
Timers:
Configured Restart Time(sec): 120
Received Restart Time(sec): 120
IPv4 Unicast:
F bit: False
End-of-RIB sent: Yes
End-of-RIB sent after update: No
End-of-RIB received: Yes
Timers:
Configured Stale Path Time(sec): 360
Message statistics:
Inq depth is 0
Outq depth is 0
Sent Rcvd
Opens: 1 1
Notifications: 0 0
Updates: 3 3
Keepalives: 13 13
Route Refresh: 0 0
Capability: 0 0
Total: 17 17
Minimum time between advertisement runs is 0 seconds
For address family: IPv4 Unicast
Update group 2, subgroup 2
Packet Queue length 0
Community attribute sent to this neighbor(all)
2 accepted prefixes
Connections established 1; dropped 0
Last reset 00:12:53, Waiting for peer OPEN
Local host: 10.1.1.4, Local port: 59054
Foreign host: 10.1.1.2, Foreign port: 179
Nexthop: 10.1.1.4
Nexthop global: fe80::1644:8fff:febc:a3c8
Nexthop local: fe80::1644:8fff:febc:a3c8
BGP connection: shared network
BGP Connect Retry Timer in Seconds: 120
Estimated round trip time: 8 ms
Read thread: on Write thread: on FD used: 26
Verification
R1
sonic.PALCNETWORKS.COM# show ip route
Codes: K - kernel route, C - connected, S - static, R - RIP,
O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
T - Table, v - VNC, V - VNC-Direct, A - Babel, F - PBR,
f - OpenFabric,
> - selected route, * - FIB route, q - queued, r - rejected, b - backup
t - trapped, o - offload failure
K>* 0.0.0.0/0 [0/0] via 172.26.1.1, eth0, 02:15:59
C>* 1.1.1.1/32 is directly connected, Loopback1, 01:51:42
B>* 2.2.2.2/32 [200/0] via 10.1.1.4, Ethernet60, weight 1, 00:09:12
C>* 10.0.0.24/31 is directly connected, Ethernet12, 02:15:56
C>* 10.0.0.48/31 is directly connected, Ethernet24, 02:15:55
C>* 10.1.0.1/32 is directly connected, Loopback0, 02:15:55
C>* 10.1.1.0/24 is directly connected, Ethernet60, 01:55:54
C>* 172.26.1.0/24 is directly connected, eth0, 02:15:59
R2
sonic.PALCNETWORKS.COM# show ip route
Codes: K - kernel route, C - connected, S - static, R - RIP,
O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
T - Table, v - VNC, V - VNC-Direct, A - Babel, F - PBR,
f - OpenFabric,
> - selected route, * - FIB route, q - queued, r - rejected, b - backup
t - trapped, o - offload failure
K>* 0.0.0.0/0 [0/0] via 172.26.1.1, eth0, 03:02:31
B>* 1.1.1.1/32 [200/0] via 10.1.1.2, Ethernet60, weight 1, 00:12:31
C>* 2.2.2.2/32 is directly connected, Loopback1, 01:52:37
C>* 10.0.0.4/31 is directly connected, Ethernet2, 05:31:45
C>* 10.0.0.8/31 is directly connected, Ethernet4, 00:16:03
C>* 10.0.0.24/31 is directly connected, Ethernet12, 02:19:24
C>* 10.0.0.48/31 is directly connected, Ethernet24, 02:19:23
C>* 10.1.0.1/32 is directly connected, Loopback0, 05:34:48
C>* 10.1.1.0/24 is directly connected, Ethernet60, 01:52:50
C>* 172.26.1.0/24 is directly connected, eth0, 03:02:31
Verify the contents of BGP routing table
R1
sonic.PALCNETWORKS.COM# show ip bgp
BGP table version is 3, local router ID is 1.1.1.1, vrf id 0
Default local pref 100, local AS 100
Status codes: s suppressed, d damped, h history, * valid, > best, = multipath,
i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
Network Next Hop Metric LocPrf Weight Path
*> 1.1.1.1/32 0.0.0.0 0 32768 i
*>i2.2.2.2/32 10.1.1.4 0 100 0 i
* i10.1.1.0/24 10.1.1.4 0 100 0 i
*> 0.0.0.0 0 32768 i
Displayed 3 routes and 4 total paths
R2
sonic.PALCNETWORKS.COM# show ip bgp
BGP table version is 4, local router ID is 2.2.2.2, vrf id 0
Default local pref 100, local AS 100
Status codes: s suppressed, d damped, h history, * valid, > best, = multipath,
i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
Network Next Hop Metric LocPrf Weight Path
*>i1.1.1.1/32 10.1.1.2 0 100 0 i
*> 2.2.2.2/32 0.0.0.0 0 32768 i
*> 10.1.1.0/24 0.0.0.0 0 32768 i
* i 10.1.1.2 0 100 0 i
Displayed 3 routes and 4 total paths
Check reachability of remote network
R1
sonic.PALCNETWORKS.COM# ping 2.2.2.2
PING 2.2.2.2 (2.2.2.2) 56(84) bytes of data.
64 bytes from 2.2.2.2: icmp_seq=1 ttl=64 time=0.996 ms
64 bytes from 2.2.2.2: icmp_seq=2 ttl=64 time=0.328 ms
64 bytes from 2.2.2.2: icmp_seq=3 ttl=64 time=0.330 ms
^C
--- 2.2.2.2 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2005ms
rtt min/avg/max/mdev = 0.328/0.551/0.996/0.314 ms
R2
sonic.PALCNETWORKS.COM# ping 1.1.1.1
PING 1.1.1.1 (1.1.1.1) 56(84) bytes of data.
64 bytes from 1.1.1.1: icmp_seq=1 ttl=64 time=0.289 ms
64 bytes from 1.1.1.1: icmp_seq=2 ttl=64 time=0.315 ms
64 bytes from 1.1.1.1: icmp_seq=3 ttl=64 time=0.344 ms
^C
--- 1.1.1.1 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2043ms
rtt min/avg/max/mdev = 0.289/0.316/0.344/0.022 ms
Establish eBGP session
External Border Gateway Protocol (EBGP) is a Border Gateway Protocol (BGP) extension that is used for communication between distinct autonomous systems (AS). EBGP enables network connections between autonomous systems and autonomous systems implemented with BGP.
Topology:
Basic Configuration Steps
Note: Commands are to be executed in sudo and vtysh mode
Step 1: Configure ip address for interfaces and loopbacks
R1
root@sonic:/home/admin#config interface ip add Ethernet60 10.1.1.2/24
root@sonic:/home/admin#config interface ip add Loopback1 1.1.1.1/32
R2
root@sonic:/home/admin#config interface ip add Ethernet60 10.1.1.4/24
root@sonic:/home/admin#config interface ip add Loopback1 2.2.2.2/32
Step 2: Enter vtysh shell
root@sonic:/home/admin# vtysh
Hello, this is FRRouting (version 8.2.2).
Copyright 1996-2005 Kunihiro Ishiguro, et al.
sonic.PALCNETWORKS.COM#
Step 3: configure BGP router id, network and neighbor session
R1
sonic.PALCNETWORKS.COM# config terminal
Sonic.PALCNETWORKS.COM(config)# router bgp 100
Sonic.PALCNETWORKS.COM(config-router)# bgp router-id 1.1.1.1
Sonic.PALCNETWORKS.COM(config-router)# no bgp ebgp-requires-policy
Sonic.PALCNETWORKS.COM(config-router)# neighbor 10.1.1.4 remote-as 200
Sonic.PALCNETWORKS.COM(config-router)# address-family ipv4 unicast
Sonic.PALCNETWORKS.COM(config-router-af)# network 1.1.1.1/32
Sonic.PALCNETWORKS.COM(config-router-af)# network 10.1.1.0/24
Sonic.PALCNETWORKS.COM(config-router-af) #exit-address-family
Sonic.PALCNETWORKS.COM(config-router)# exit
R2
sonic.PALCNETWORKS.COM# config terminal
Sonic.PALCNETWORKS.COM(config)# router bgp 200
Sonic.PALCNETWORKS.COM(config-router)# bgp router-id 2.2.2.2
Sonic.PALCNETWORKS.COM(config-router)# no bgp ebgp-requires-policy
Sonic.PALCNETWORKS.COM(config-router)# neighbor 10.1.1.2 remote-as 100
Sonic.PALCNETWORKS.COM(config-router)# address-family ipv4 unicast
Sonic.PALCNETWORKS.COM(config-router-af)# network 2.2.2.2/32
Sonic.PALCNETWORKS.COM(config-router-af)# network 10.1.1.0/24
Sonic.PALCNETWORKS.COM(config-router-af) #exit-address-family
Sonic.PALCNETWORKS.COM(config-router)# exit
Step 4: Checking the BGP neighbors
R1
sonic.PALCNETWORKS.COM# show bgp summary
IPv4 Unicast Summary (VRF default):
BGP router identifier 1.1.1.1, local AS number 100 vrf-id 0
BGP table version 3
RIB entries 5, using 920 bytes of memory
Peers 1, using 723 KiB of memory
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt Desc
10.1.1.4 4 200 16 16 0 0 0 00:11:28 2 2 N/A
Total number of neighbors 1
sonic.PALCNETWORKS.COM# show ip bgp neighbors
BGP neighbor is 10.1.1.4, remote AS 200, local AS 100, external link
Hostname: sonic
BGP version 4, remote router ID 2.2.2.2, local router ID 1.1.1.1
BGP state = Established, up for 00:14:15
Last read 00:00:15, Last write 00:00:15
Hold time is 180, keepalive interval is 60 seconds
Neighbor capabilities:
4 Byte AS: advertised and received
Extended Message: advertised and received
AddPath:
IPv4 Unicast: RX advertised and received
Long-lived Graceful Restart: advertised and received
Address families by peer:
Route refresh: advertised and received(old & new)
Enhanced Route Refresh: advertised and received
Address Family IPv4 Unicast: advertised and received
Hostname Capability: advertised (name: sonic,domain name: n/a) received (name: sonic,domain name: n/a)
Graceful Restart Capability: advertised and received
Remote Restart timer is 120 seconds
Address families by peer:
none
Graceful restart information:
End-of-RIB send: IPv4 Unicast
End-of-RIB received: IPv4 Unicast
Local GR Mode: Helper*
Remote GR Mode: Helper
R bit: True
Timers:
Configured Restart Time(sec): 120
Received Restart Time(sec): 120
IPv4 Unicast:
F bit: False
End-of-RIB sent: Yes
End-of-RIB sent after update: No
End-of-RIB received: Yes
Timers:
Configured Stale Path Time(sec): 360
Message statistics:
Inq depth is 0
Outq depth is 0
Sent Rcvd
Opens: 1 1
Notifications: 0 0
Updates: 3 3
Keepalives: 15 15
Route Refresh: 0 0
Capability: 0 0
Total: 19 19
Minimum time between advertisement runs is 0 seconds
For address family: IPv4 Unicast
Update group 2, subgroup 2
Packet Queue length 0
Community attribute sent to this neighbor(all)
2 accepted prefixes
Connections established 1; dropped 0
Last reset 00:17:54, No AFI/SAFI activated for peer
Local host: 10.1.1.2, Local port: 179
Foreign host: 10.1.1.4, Foreign port: 59054
Nexthop: 10.1.1.2
Nexthop global: fe80::1644:8fff:febc:a2c8
Nexthop local: fe80::1644:8fff:febc:a2c8
BGP connection: shared network
BGP Connect Retry Timer in Seconds: 120
Estimated round trip time: 1 ms
Read thread: on Write thread: on FD used: 26
R2
sonic.PALCNETWORKS.COM# show bgp summary
IPv4 Unicast Summary (VRF default):
BGP router identifier 2.2.2.2, local AS number 100 vrf-id 0
BGP table version 4
RIB entries 5, using 920 bytes of memory
Peers 1, using 723 KiB of memory
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt Desc
10.1.1.2 4 200 17 17 0 0 0 00:12:29 2 2 N/A
Total number of neighbors 1
sonic.PALCNETWORKS.COM# show ip bgp neighbors
BGP neighbor is 10.1.1.2, remote AS 100, local AS 200, external link
Hostname: sonic
BGP version 4, remote router ID 1.1.1.1, local router ID 2.2.2.2
BGP state = Established, up for 00:12:52
Last read 00:00:52, Last write 00:00:52
Hold time is 180, keepalive interval is 60 seconds
Neighbor capabilities:
4 Byte AS: advertised and received
Extended Message: advertised and received
AddPath:
IPv4 Unicast: RX advertised and received
Long-lived Graceful Restart: advertised and received
Address families by peer:
Route refresh: advertised and received(old & new)
Enhanced Route Refresh: advertised and received
Address Family IPv4 Unicast: advertised and received
Hostname Capability: advertised (name: sonic,domain name: n/a) received (name: sonic,domain name: n/a)
Graceful Restart Capability: advertised and received
Remote Restart timer is 120 seconds
Address families by peer:
none
Graceful restart information:
End-of-RIB send: IPv4 Unicast
End-of-RIB received: IPv4 Unicast
Local GR Mode: Helper*
Remote GR Mode: Helper
R bit: False
Timers:
Configured Restart Time(sec): 120
Received Restart Time(sec): 120
IPv4 Unicast:
F bit: False
End-of-RIB sent: Yes
End-of-RIB sent after update: No
End-of-RIB received: Yes
Timers:
Configured Stale Path Time(sec): 360
Message statistics:
Inq depth is 0
Outq depth is 0
Sent Rcvd
Opens: 1 1
Notifications: 0 0
Updates: 3 3
Keepalives: 13 13
Route Refresh: 0 0
Capability: 0 0
Total: 17 17
Minimum time between advertisement runs is 0 seconds
For address family: IPv4 Unicast
Update group 2, subgroup 2
Packet Queue length 0
Community attribute sent to this neighbor(all)
2 accepted prefixes
Connections established 1; dropped 0
Last reset 00:12:53, Waiting for peer OPEN
Local host: 10.1.1.4, Local port: 59054
Foreign host: 10.1.1.2, Foreign port: 179
Nexthop: 10.1.1.4
Nexthop global: fe80::1644:8fff:febc:a3c8
Nexthop local: fe80::1644:8fff:febc:a3c8
BGP connection: shared network
BGP Connect Retry Timer in Seconds: 120
Estimated round trip time: 8 ms
Read thread: on Write thread: on FD used: 26
Result:
Verify the BGP routes in routing table
R1
sonic.PALCNETWORKS.COM# show ip route
Codes: K - kernel route, C - connected, S - static, R - RIP,
O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
T - Table, v - VNC, V - VNC-Direct, A - Babel, F - PBR,
f - OpenFabric,
> - selected route, * - FIB route, q - queued, r - rejected, b - backup
t - trapped, o - offload failure
K>* 0.0.0.0/0 [0/0] via 172.26.1.1, eth0, 02:15:59
C>* 1.1.1.1/32 is directly connected, Loopback1, 01:51:42
B>* 2.2.2.2/32 [20/0] via 10.1.1.4, Ethernet60, weight 1, 00:09:12
C>* 10.0.0.24/31 is directly connected, Ethernet12, 02:15:56
C>* 10.0.0.48/31 is directly connected, Ethernet24, 02:15:55
C>* 10.1.0.1/32 is directly connected, Loopback0, 02:15:55
C>* 10.1.1.0/24 is directly connected, Ethernet60, 01:55:54
C>* 172.26.1.0/24 is directly connected, eth0, 02:15:59
R2
sonic.PALCNETWORKS.COM# show ip route
Codes: K - kernel route, C - connected, S - static, R - RIP,
O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
T - Table, v - VNC, V - VNC-Direct, A - Babel, F - PBR,
f - OpenFabric,
> - selected route, * - FIB route, q - queued, r - rejected, b - backup
t - trapped, o - offload failure
K>* 0.0.0.0/0 [0/0] via 172.26.1.1, eth0, 03:02:31
B>* 1.1.1.1/32 [20/0] via 10.1.1.2, Ethernet60, weight 1, 00:12:31
C>* 2.2.2.2/32 is directly connected, Loopback1, 01:52:37
C>* 10.0.0.4/31 is directly connected, Ethernet2, 05:31:45
C>* 10.0.0.8/31 is directly connected, Ethernet4, 00:16:03
C>* 10.0.0.24/31 is directly connected, Ethernet12, 02:19:24
C>* 10.0.0.48/31 is directly connected, Ethernet24, 02:19:23
C>* 10.1.0.1/32 is directly connected, Loopback0, 05:34:48
C>* 10.1.1.0/24 is directly connected, Ethernet60, 01:52:50
C>* 172.26.1.0/24 is directly connected, eth0, 03:02:31
Verify the contents of BGP routing table
R1
sonic.PALCNETWORKS.COM# show ip bgp
BGP table version is 3, local router ID is 1.1.1.1, vrf id 0
Default local pref 100, local AS 100
Status codes: s suppressed, d damped, h history, * valid, > best, = multipath,
i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
Network Next Hop Metric LocPrf Weight Path
*> 1.1.1.1/32 0.0.0.0 0 32768 i
*>i2.2.2.2/32 10.1.1.4 0 100 0 200 i
* i10.1.1.0/24 10.1.1.4 0 100 0 200 i
*> 0.0.0.0 0 32768 i
Displayed 3 routes and 4 total paths
R2
sonic.PALCNETWORKS.COM# show ip bgp
BGP table version is 4, local router ID is 2.2.2.2, vrf id 0
Default local pref 100, local AS 100
Status codes: s suppressed, d damped, h history, * valid, > best, = multipath,
i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
Network Next Hop Metric LocPrf Weight Path
*>i1.1.1.1/32 10.1.1.2 0 100 0 100 i
*> 2.2.2.2/32 0.0.0.0 0 32768 i
*> 10.1.1.0/24 0.0.0.0 0 32768 i
* i 10.1.1.2 0 100 0 100 i
Displayed 3 routes and 4 total paths
Check reachability of remote network
R1
sonic.PALCNETWORKS.COM# ping 2.2.2.2
PING 2.2.2.2 (2.2.2.2) 56(84) bytes of data.
64 bytes from 2.2.2.2: icmp_seq=1 ttl=64 time=0.996 ms
64 bytes from 2.2.2.2: icmp_seq=2 ttl=64 time=0.328 ms
64 bytes from 2.2.2.2: icmp_seq=3 ttl=64 time=0.330 ms
^C
--- 2.2.2.2 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2005ms
rtt min/avg/max/mdev = 0.328/0.551/0.996/0.314 ms
R2
sonic.PALCNETWORKS.COM# ping 1.1.1.1
PING 1.1.1.1 (1.1.1.1) 56(84) bytes of data.
64 bytes from 1.1.1.1: icmp_seq=1 ttl=64 time=0.289 ms
64 bytes from 1.1.1.1: icmp_seq=2 ttl=64 time=0.315 ms
64 bytes from 1.1.1.1: icmp_seq=3 ttl=64 time=0.344 ms
^C
--- 1.1.1.1 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2043ms
rtt min/avg/max/mdev = 0.289/0.316/0.344/0.022 ms
Establish iBGP with peer group
Peer groups can be used to assign common policies and attributes such as an AS number or source-interface for multiple neighbors. A peer group is relevant only to the router on which it is active and is not communicated to router peers.
Topology:
Basic Configuration Steps
Note: Commands are to be executed in sudo and vtysh mode
Step 1: Configure ip address for interfaces and loopbacks
R1
root@sonic:/home/admin#config interface ip add Ethernet60 10.1.1.2/24
root@sonic:/home/admin#config interface ip add Loopback1 1.1.1.1/32
R2
root@sonic:/home/admin#config interface ip add Ethernet60 10.1.1.4/24
root@sonic:/home/admin#config interface ip add Ethernet6 20.1.1.1/24
root@sonic:/home/admin#config interface ip add Loopback1 2.2.2.2/32
R3
root@sonic:/home/admin#config interface ip add Ethernet6 20.1.1.2/24
root@sonic:/home/admin#config interface ip add Loopback1 3.3.3.3/32
Step 2: Enter vtysh shell
root@sonic:/home/admin# vtysh
Hello, this is FRRouting (version 8.2.2).
Copyright 1996-2005 Kunihiro Ishiguro, et al.
sonic.PALCNETWORKS.COM#
Step 3: configure BGP network and neighbor session
R1
sonic.PALCNETWORKS.COM# configure terminal
sonic.PALCNETWORKS.COM(config)# router bgp 100
sonic.PALCNETWORKS.COM(config-router)# no bgp ebgp-requires-policy
sonic.PALCNETWORKS.COM(config-router)# neighbor 10.1.1.4 remote-as 100
sonic.PALCNETWORKS.COM(config-router)# network 10.1.1.0/24
R3
sonic.PALCNETWORKS.COM#configure terminal
sonic.PALCNETWORKS.COM(config)# router bgp 100
sonic.PALCNETWORKS.COM(config-router)# no bgp ebgp-requires-policy
sonic.PALCNETWORKS.COM(config-router)# neighbor 20.1.1.1 remote-as 100
sonic.PALCNETWORKS.COM(config-router)# network 20.1.1.0/24
Step 4: configure BGP peer group on R2
R2
sonic.PALCNETWORKS.COM#configure terminal
sonic.PALCNETWORKS.COM(config)# router bgp 100
sonic.PALCNETWORKS.COM(config-router)# no bgp ebgp-requires-policy
sonic.PALCNETWORKS.COM(config-router)# neighbor leaf peer-group
sonic.PALCNETWORKS.COM(config-router)# neighbor leaf remote-as 100
sonic.PALCNETWORKS.COM(config-router)# neighbor 10.1.1.2 peer-group leaf
sonic.PALCNETWORKS.COM(config-router)# neighbor 20.1.1.2 peer-group leaf
sonic.PALCNETWORKS.COM(config-router)# network 10.1.1.0/24
sonic.PALCNETWORKS.COM(config-router)# network 20.1.1.0/24
Step 5: Checking the BGP neighbors
R1
sonic.PALCNETWORKS.COM# show bgp summary
IPv4 Unicast Summary (VRF default):
BGP router identifier 172.26.1.59, local AS number 100 vrf-id 0
BGP table version 2
RIB entries 3, using 552 bytes of memory
Peers 1, using 723 KiB of memory
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt Desc
10.1.1.4 4 100 7 6 0 0 0 00:02:38 2 1 N/A
Total number of neighbors 1
sonic.PALCNETWORKS.COM# show ip bgp neighbors
BGP neighbor is 10.1.1.4, remote AS 100, local AS 100, internal link
Hostname: sonic
BGP version 4, remote router ID 172.26.1.61, local router ID 172.26.1.59
BGP state = Established, up for 00:03:45
Last read 00:00:45, Last write 00:00:45
Hold time is 180, keepalive interval is 60 seconds
Neighbor capabilities:
4 Byte AS: advertised and received
Extended Message: advertised and received
AddPath:
IPv4 Unicast: RX advertised and received
Long-lived Graceful Restart: advertised and received
Address families by peer:
Route refresh: advertised and received(old & new)
Enhanced Route Refresh: advertised and received
Address Family IPv4 Unicast: advertised and received
Hostname Capability: advertised (name: sonic,domain name: n/a) received (name: sonic,domain name: n/a)
Graceful Restart Capability: advertised and received
Remote Restart timer is 120 seconds
Address families by peer:
none
Graceful restart information:
End-of-RIB send: IPv4 Unicast
End-of-RIB received: IPv4 Unicast
Local GR Mode: Helper*
Remote GR Mode: Helper
R bit: True
Timers:
Configured Restart Time(sec): 120
Received Restart Time(sec): 120
IPv4 Unicast:
F bit: False
End-of-RIB sent: Yes
End-of-RIB sent after update: Yes
End-of-RIB received: Yes
Timers:
Configured Stale Path Time(sec): 360
Message statistics:
Inq depth is 0
Outq depth is 0
Sent Rcvd
Opens: 1 1
Notifications: 0 0
Updates: 2 3
Keepalives: 4 4
Route Refresh: 0 0
Capability: 0 0
Total: 7 8
Minimum time between advertisement runs is 0 seconds
For address family: IPv4 Unicast
Update group 2, subgroup 2
Packet Queue length 0
Community attribute sent to this neighbor(all)
2 accepted prefixes
Connections established 1; dropped 0
Last reset 00:04:39, No AFI/SAFI activated for peer
Local host: 10.1.1.2, Local port: 179
Foreign host: 10.1.1.4, Foreign port: 48660
Nexthop: 10.1.1.2
Nexthop global: fe80::1644:8fff:febc:a3c8
Nexthop local: fe80::1644:8fff:febc:a3c8
BGP connection: shared network
BGP Connect Retry Timer in Seconds: 120
Estimated round trip time: 4 ms
Read thread: on Write thread: on FD used: 28
R2
sonic.PALCNETWORKS.COM# show bgp summary
IPv4 Unicast Summary (VRF default):
BGP router identifier 172.26.1.61, local AS number 100 vrf-id 0
BGP table version 3
RIB entries 3, using 552 bytes of memory
Peers 2, using 1447 KiB of memory
Peer groups 1, using 64 bytes of memory
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt Desc
10.1.1.2 4 100 6 7 0 0 0 00:02:07 1 2 N/A
20.1.1.2 4 100 4 4 0 0 0 00:00:38 1 2 N/A
Total number of neighbors 2
sonic.PALCNETWORKS.COM# show ip bgp neighbors
BGP neighbor is 10.1.1.2, remote AS 100, local AS 100, internal link
Hostname: sonic
Member of peer-group leaf for session parameters
BGP version 4, remote router ID 172.26.1.59, local router ID 172.26.1.61
BGP state = Established, up for 00:05:37
Last read 00:00:37, Last write 00:00:37
Hold time is 180, keepalive interval is 60 seconds
Neighbor capabilities:
4 Byte AS: advertised and received
Extended Message: advertised and received
AddPath:
IPv4 Unicast: RX advertised and received
Long-lived Graceful Restart: advertised and received
Address families by peer:
Route refresh: advertised and received(old & new)
Enhanced Route Refresh: advertised and received
Address Family IPv4 Unicast: advertised and received
Hostname Capability: advertised (name: sonic,domain name: n/a) received (name: sonic,domain name: n/a)
Graceful Restart Capability: advertised and received
Remote Restart timer is 120 seconds
Address families by peer:
none
Graceful restart information:
End-of-RIB send: IPv4 Unicast
End-of-RIB received: IPv4 Unicast
Local GR Mode: Helper*
Remote GR Mode: Helper
R bit: True
Timers:
Configured Restart Time(sec): 120
Received Restart Time(sec): 120
IPv4 Unicast:
F bit: False
End-of-RIB sent: Yes
End-of-RIB sent after update: No
End-of-RIB received: Yes
Timers:
Configured Stale Path Time(sec): 360
Message statistics:
Inq depth is 0
Outq depth is 0
Sent Rcvd
Opens: 1 1
Notifications: 0 0
Updates: 3 2
Keepalives: 6 6
Route Refresh: 0 0
Capability: 0 0
Total: 10 9
Minimum time between advertisement runs is 0 seconds
For address family: IPv4 Unicast
leaf peer-group member
Update group 2, subgroup 3
Packet Queue length 0
Community attribute sent to this neighbor(all)
1 accepted prefixes
Connections established 1; dropped 0
Last reset 00:05:38, Waiting for peer OPEN
Local host: 10.1.1.4, Local port: 48660
Foreign host: 10.1.1.2, Foreign port: 179
Nexthop: 10.1.1.4
Nexthop global: fe80::1644:8fff:febc:a2c8
Nexthop local: fe80::1644:8fff:febc:a2c8
BGP connection: shared network
BGP Connect Retry Timer in Seconds: 120
Estimated round trip time: 5 ms
Read thread: on Write thread: on FD used: 27
BGP neighbor is 20.1.1.2, remote AS 100, local AS 100, internal link
Hostname: sonic
Member of peer-group leaf for session parameters
BGP version 4, remote router ID 192.168.10.2, local router ID 172.26.1.61
BGP state = Established, up for 00:04:08
Last read 00:00:09, Last write 00:00:08
Hold time is 180, keepalive interval is 60 seconds
Neighbor capabilities:
4 Byte AS: advertised and received
Extended Message: advertised and received
AddPath:
IPv4 Unicast: RX advertised and received
Long-lived Graceful Restart: advertised and received
Address families by peer:
Route refresh: advertised and received(old & new)
Enhanced Route Refresh: advertised and received
Address Family IPv4 Unicast: advertised and received
Hostname Capability: advertised (name: sonic,domain name: n/a) received (name: sonic,domain name: n/a)
Graceful Restart Capability: advertised and received
Remote Restart timer is 120 seconds
Address families by peer:
none
Graceful restart information:
End-of-RIB send: IPv4 Unicast
End-of-RIB received: IPv4 Unicast
Local GR Mode: Helper*
Remote GR Mode: Helper
R bit: True
Timers:
Configured Restart Time(sec): 120
Received Restart Time(sec): 120
IPv4 Unicast:
F bit: False
End-of-RIB sent: Yes
End-of-RIB sent after update: Yes
End-of-RIB received: Yes
Timers:
Configured Stale Path Time(sec): 360
Message statistics:
Inq depth is 0
Outq depth is 0
Sent Rcvd
Opens: 1 1
Notifications: 0 0
Updates: 2 2
Keepalives: 5 5
Route Refresh: 0 0
Capability: 0 0
Total: 8 8
Minimum time between advertisement runs is 0 seconds
For address family: IPv4 Unicast
leaf peer-group member
Update group 2, subgroup 3
Packet Queue length 0
Community attribute sent to this neighbor(all)
1 accepted prefixes
Connections established 1; dropped 0
Last reset 00:05:31, No AFI/SAFI activated for peer
Local host: 20.1.1.1, Local port: 179
Foreign host: 20.1.1.2, Foreign port: 36264
Nexthop: 20.1.1.1
Nexthop global: fe80::1644:8fff:febc:a2c8
Nexthop local: fe80::1644:8fff:febc:a2c8
BGP connection: shared network
BGP Connect Retry Timer in Seconds: 120
Estimated round trip time: 3 ms
Read thread: on Write thread: on FD used: 28
R3
sonic.PALCNETWORKS.COM# show bgp summary
IPv4 Unicast Summary (VRF default):
BGP router identifier 192.168.10.2, local AS number 100 vrf-id 0
BGP table version 3
RIB entries 3, using 552 bytes of memory
Peers 1, using 723 KiB of memory
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt Desc
20.1.1.1 4 100 4 4 0 0 0 00:00:08 2 1 N/A
Total number of neighbors 1
sonic.PALCNETWORKS.COM# show ip bgp neighbors
BGP neighbor is 20.1.1.1, remote AS 100, local AS 100, internal link
Hostname: sonic
BGP version 4, remote router ID 172.26.1.61, local router ID 192.168.10.2
BGP state = Established, up for 00:01:58
Last read 00:00:58, Last write 00:00:58
Hold time is 180, keepalive interval is 60 seconds
Neighbor capabilities:
4 Byte AS: advertised and received
Extended Message: advertised and received
AddPath:
IPv4 Unicast: RX advertised and received
Long-lived Graceful Restart: advertised and received
Address families by peer:
Route refresh: advertised and received(old & new)
Enhanced Route Refresh: advertised and received
Address Family IPv4 Unicast: advertised and received
Hostname Capability: advertised (name: sonic,domain name: n/a) received (name: sonic,domain name: n/a)
Graceful Restart Capability: advertised and received
Remote Restart timer is 120 seconds
Address families by peer:
none
Graceful restart information:
End-of-RIB send: IPv4 Unicast
End-of-RIB received: IPv4 Unicast
Local GR Mode: Helper*
Remote GR Mode: Helper
R bit: False
Timers:
Configured Restart Time(sec): 120
Received Restart Time(sec): 120
IPv4 Unicast:
F bit: False
End-of-RIB sent: Yes
End-of-RIB sent after update: No
End-of-RIB received: Yes
Timers:
Configured Stale Path Time(sec): 360
Message statistics:
Inq depth is 0
Outq depth is 0
Sent Rcvd
Opens: 1 1
Notifications: 0 0
Updates: 2 2
Keepalives: 2 2
Route Refresh: 0 0
Capability: 0 0
Total: 5 5
Minimum time between advertisement runs is 0 seconds
For address family: IPv4 Unicast
Update group 2, subgroup 2
Packet Queue length 0
Community attribute sent to this neighbor(all)
2 accepted prefixes
Connections established 1; dropped 0
Last reset 00:01:59, Waiting for peer OPEN
Local host: 20.1.1.2, Local port: 36264
Foreign host: 20.1.1.1, Foreign port: 179
Nexthop: 20.1.1.2
Nexthop global: fe80::6a21:5fff:fe9c:fc7b
Nexthop local: fe80::6a21:5fff:fe9c:fc7b
BGP connection: shared network
BGP Connect Retry Timer in Seconds: 120
Estimated round trip time: 4 ms
Read thread: on Write thread: on FD used: 27
Result:
Verify the BGP routes in routing table
R1
sonic.PALCNETWORKS.COM# show ip route
Codes: K - kernel route, C - connected, S - static, R - RIP,
O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
T - Table, v - VNC, V - VNC-Direct, A - Babel, F - PBR,
f - OpenFabric,
> - selected route, * - FIB route, q - queued, r - rejected, b - backup
t - trapped, o - offload failure
K>* 0.0.0.0/0 [0/0] via 172.26.1.1, eth0, 00:39:31
C>* 1.1.1.1/32 is directly connected, Loopback1, 00:39:28
C>* 10.1.0.1/32 is directly connected, Loopback0, 00:39:28
C>* 10.1.1.0/24 is directly connected, Ethernet60, 00:39:19
B>* 20.1.1.0/24 [200/0] via 10.1.1.4, Ethernet60, weight 1, 00:01:36
C>* 100.1.1.0/24 is directly connected, Ethernet48, 00:39:19
C>* 172.26.1.0/24 is directly connected, eth0, 00:39:31
sonic.PALCNETWORKS.COM(config-router)# do sh ip bgp
BGP table version is 2, local router ID is 172.26.1.59, vrf id 0
Default local pref 100, local AS 100
Status codes: s suppressed, d damped, h history, * valid, > best, = multipath,
i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
Network Next Hop Metric LocPrf Weight Path
* i10.1.1.0/24 10.1.1.4 0 100 0 i
*> 0.0.0.0 0 32768 i
*>i20.1.1.0/24 10.1.1.4 0 100 0 i
Displayed 2 routes and 3 total paths
R2
sonic.PALCNETWORKS.COM(config-router)# do sh ip bgp
BGP table version is 3, local router ID is 172.26.1.61, vrf id 0
Default local pref 100, local AS 100
Status codes: s suppressed, d damped, h history, * valid, > best, = multipath,
i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
Network Next Hop Metric LocPrf Weight Path
*> 10.1.1.0/24 0.0.0.0 0 32768 i
* i 10.1.1.2 0 100 0 i
* i20.1.1.0/24 20.1.1.2 0 100 0 i
*> 0.0.0.0 0 32768 i
Displayed 2 routes and 4 total paths
sonic.PALCNETWORKS.COM(config-router)# do sh ip route
Codes: K - kernel route, C - connected, S - static, R - RIP,
O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
T - Table, v - VNC, V - VNC-Direct, A - Babel, F - PBR,
f - OpenFabric,
> - selected route, * - FIB route, q - queued, r - rejected, b - backup
t - trapped, o - offload failure
K>* 0.0.0.0/0 [0/0] via 172.26.1.1, eth0, 00:39:00
C>* 2.2.2.2/32 is directly connected, Loopback1, 00:31:48
C>* 10.1.0.1/32 is directly connected, Loopback0, 00:38:56
C>* 10.1.1.0/24 is directly connected, Ethernet60, 00:32:39
C>* 20.1.1.0/24 is directly connected, Ethernet6, 00:32:26
C>* 172.26.1.0/24 is directly connected, eth0, 00:39:00
R3
sonic.PALCNETWORKS.COM(config-router)# do sh ip bgp
BGP table version is 3, local router ID is 192.168.10.2, vrf id 0
Default local pref 100, local AS 100
Status codes: s suppressed, d damped, h history, * valid, > best, = multipath,
i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
Network Next Hop Metric LocPrf Weight Path
*>i10.1.1.0/24 20.1.1.1 0 100 0 i
*> 20.1.1.0/24 0.0.0.0 0 32768 i
* i 20.1.1.1 0 100 0 i
Displayed 2 routes and 3 total paths
sonic.PALCNETWORKS.COM(config-router)# do sh ip route
Codes: K - kernel route, C - connected, S - static, R - RIP,
O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
T - Table, v - VNC, V - VNC-Direct, A - Babel, F - PBR,
f - OpenFabric,
> - selected route, * - FIB route, q - queued, r - rejected, b - backup
t - trapped, o - offload failure
C>* 3.3.3.3/32 is directly connected, Loopback1, 00:30:16
C>* 10.1.0.1/32 is directly connected, Loopback0, 00:38:11
B>* 10.1.1.0/24 [200/0] via 20.1.1.1, Ethernet6, weight 1, 00:00:24
C>* 20.1.1.0/24 is directly connected, Ethernet6, 00:29:50
C>* 192.168.10.0/24 is directly connected, Ethernet50, 00:37:56
Verify the reachability of remote network
R1
sonic.PALCNETWORKS.COM# ping 20.1.1.2
PING 20.1.1.2 (20.1.1.2) 56(84) bytes of data.
64 bytes from 20.1.1.2: icmp_seq=1 ttl=63 time=0.254 ms
64 bytes from 20.1.1.2: icmp_seq=2 ttl=63 time=0.272 ms
64 bytes from 20.1.1.2: icmp_seq=3 ttl=63 time=0.262 ms
^C
--- 20.1.1.2 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2027ms
rtt min/avg/max/mdev = 0.254/0.262/0.272/0.007 ms
R3
sonic.PALCNETWORKS.COM# ping 10.1.1.2
PING 10.1.1.2 (10.1.1.2) 56(84) bytes of data.
64 bytes from 10.1.1.2: icmp_seq=1 ttl=63 time=0.334 ms
64 bytes from 10.1.1.2: icmp_seq=2 ttl=63 time=0.327 ms
64 bytes from 10.1.1.2: icmp_seq=3 ttl=63 time=0.321 ms
^C
--- 10.1.1.2 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2029ms
rtt min/avg/max/mdev = 0.321/0.327/0.334/0.005 ms
Establish eBGP with peer group
Topology:
Basic Configuration Steps
Note: Commands are to be executed in sudo and vtysh mode
Step 1: Configure ip address for interfaces and loopbacks
R1
root@sonic:/home/admin#config interface ip add Ethernet60 10.1.1.2/24
root@sonic:/home/admin#config interface ip add Loopback1 1.1.1.1/32
R2
root@sonic:/home/admin#config interface ip add Ethernet60 10.1.1.4/24
root@sonic:/home/admin#config interface ip add Ethernet6 20.1.1.1/24
root@sonic:/home/admin#config interface ip add Loopback1 2.2.2.2/32
R3
root@sonic:/home/admin#config interface ip add Ethernet6 20.1.1.2/24
root@sonic:/home/admin#config interface ip add Loopback1 3.3.3.3/32
Step 2: Enter vtysh shell
root@sonic:/home/admin# vtysh
Hello, this is FRRouting (version 8.2.2).
Copyright 1996-2005 Kunihiro Ishiguro, et al.
sonic.PALCNETWORKS.COM#
Step 3: configure BGP network and neighbor session
R1
sonic.PALCNETWORKS.COM# conf
sonic.PALCNETWORKS.COM(config)# router bgp 100
sonic.PALCNETWORKS.COM(config-router)# no bgp ebgp-requires-policy
sonic.PALCNETWORKS.COM(config-router)# neighbor 10.1.1.4 remote-as 200
sonic.PALCNETWORKS.COM(config-router)# network 10.1.1.0/24
R3
sonic.PALCNETWORKS.COM# conf
sonic.PALCNETWORKS.COM(config)# router bgp 300
sonic.PALCNETWORKS.COM(config-router)# no bgp ebgp-requires-policy
sonic.PALCNETWORKS.COM(config-router)# neighbor 20.1.1.1 remote-as 200
sonic.PALCNETWORKS.COM(config-router)# network 20.1.1.0/24
Step 4: configure BGP peer group on R2
R2
sonic.PALCNETWORKS.COM(config)# router bgp 200
sonic.PALCNETWORKS.COM(config-router)# no bgp ebgp-requires-policy
sonic.PALCNETWORKS.COM(config-router)# neighbor LEAF peer-group
sonic.PALCNETWORKS.COM(config-router)# neighbor LEAF remote-as external
sonic.PALCNETWORKS.COM(config-router)# neighbor 10.1.1.2 peer-group LEAF
sonic.PALCNETWORKS.COM(config-router)# neighbor 20.1.1.2 peer-group LEAF
sonic.PALCNETWORKS.COM(config-router)#
sonic.PALCNETWORKS.COM(config-router)# network 10.1.1.0/24
sonic.PALCNETWORKS.COM(config-router)# network 20.1.1.0/24
Step 5: Checking the BGP neighbors
R1
sonic.PALCNETWORKS.COM(config-router)# do sh bgp summary
IPv4 Unicast Summary (VRF default):
BGP router identifier 172.26.1.59, local AS number 100 vrf-id 0
BGP table version 2
RIB entries 3, using 552 bytes of memory
Peers 1, using 723 KiB of memory
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt Desc
10.1.1.4 4 200 10 11 0 0 0 00:04:10 2 2 N/A
Total number of neighbors 1
sonic.PALCNETWORKS.COM# sh ip bgp neighbors
BGP neighbor is 10.1.1.4, remote AS 200, local AS 100, external link
Hostname: sonic
BGP version 4, remote router ID 172.26.1.61, local router ID 172.26.1.59
BGP state = Established, up for 00:06:22
Last read 00:00:22, Last write 00:00:22
Hold time is 180, keepalive interval is 60 seconds
Neighbor capabilities:
4 Byte AS: advertised and received
Extended Message: advertised and received
AddPath:
IPv4 Unicast: RX advertised and received
Long-lived Graceful Restart: advertised and received
Address families by peer:
Route refresh: advertised and received(old & new)
Enhanced Route Refresh: advertised and received
Address Family IPv4 Unicast: advertised and received
Hostname Capability: advertised (name: sonic,domain name: n/a) received (name: sonic,domain name: n/a)
Graceful Restart Capability: advertised and received
Remote Restart timer is 120 seconds
Address families by peer:
none
Graceful restart information:
End-of-RIB send: IPv4 Unicast
End-of-RIB received: IPv4 Unicast
Local GR Mode: Helper*
Remote GR Mode: Helper
R bit: True
Timers:
Configured Restart Time(sec): 120
Received Restart Time(sec): 120
IPv4 Unicast:
F bit: False
End-of-RIB sent: Yes
End-of-RIB sent after update: No
End-of-RIB received: Yes
Timers:
Configured Stale Path Time(sec): 360
Message statistics:
Inq depth is 0
Outq depth is 0
Sent Rcvd
Opens: 3 1
Notifications: 0 0
Updates: 3 4
Keepalives: 7 7
Route Refresh: 0 0
Capability: 0 0
Total: 13 12
Minimum time between advertisement runs is 0 seconds
For address family: IPv4 Unicast
Update group 1, subgroup 1
Packet Queue length 0
Community attribute sent to this neighbor(all)
2 accepted prefixes
Connections established 1; dropped 0
Last reset 00:08:47, No AFI/SAFI activated for peer
Local host: 10.1.1.2, Local port: 179
Foreign host: 10.1.1.4, Foreign port: 52832
Nexthop: 10.1.1.2
Nexthop global: fe80::1644:8fff:febc:a3c8
Nexthop local: fe80::1644:8fff:febc:a3c8
BGP connection: shared network
BGP Connect Retry Timer in Seconds: 120
Estimated round trip time: 2 ms
Read thread: on Write thread: on FD used: 28
R2
sonic.PALCNETWORKS.COM(config-router)# do sh bgp summary
IPv4 Unicast Summary (VRF default):
BGP router identifier 172.26.1.61, local AS number 200 vrf-id 0
BGP table version 3
RIB entries 3, using 552 bytes of memory
Peers 2, using 1447 KiB of memory
Peer groups 1, using 64 bytes of memory
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt Desc
10.1.1.2 4 100 8 9 0 0 0 00:03:37 1 2 N/A
20.1.1.2 4 300 5 5 0 0 0 00:00:33 1 2 N/A
Total number of neighbors 2
sonic.PALCNETWORKS.COM(config-router)# do sh ip bgp neighbors
BGP neighbor is 10.1.1.2, remote AS 100, local AS 200, external link
Hostname: sonic
Member of peer-group LEAF for session parameters
BGP version 4, remote router ID 172.26.1.59, local router ID 172.26.1.61
BGP state = Established, up for 00:05:56
Last read 00:00:56, Last write 00:00:56
Hold time is 180, keepalive interval is 60 seconds
Neighbor capabilities:
4 Byte AS: advertised and received
Extended Message: advertised and received
AddPath:
IPv4 Unicast: RX advertised and received
Long-lived Graceful Restart: advertised and received
Address families by peer:
Route refresh: advertised and received(old & new)
Enhanced Route Refresh: advertised and received
Address Family IPv4 Unicast: advertised and received
Hostname Capability: advertised (name: sonic,domain name: n/a) received (name: sonic,domain name: n/a)
Graceful Restart Capability: advertised and received
Remote Restart timer is 120 seconds
Address families by peer:
none
Graceful restart information:
End-of-RIB send: IPv4 Unicast
End-of-RIB received: IPv4 Unicast
Local GR Mode: Helper*
Remote GR Mode: Helper
R bit: False
Timers:
Configured Restart Time(sec): 120
Received Restart Time(sec): 120
IPv4 Unicast:
F bit: False
End-of-RIB sent: Yes
End-of-RIB sent after update: No
End-of-RIB received: Yes
Timers:
Configured Stale Path Time(sec): 360
Message statistics:
Inq depth is 0
Outq depth is 0
Sent Rcvd
Opens: 1 1
Notifications: 0 0
Updates: 4 3
Keepalives: 6 6
Route Refresh: 0 0
Capability: 0 0
Total: 11 10
Minimum time between advertisement runs is 0 seconds
For address family: IPv4 Unicast
LEAF peer-group member
Update group 1, subgroup 1
Packet Queue length 0
Community attribute sent to this neighbor(all)
1 accepted prefixes
Connections established 1; dropped 0
Last reset 00:05:57, Waiting for peer OPEN
Local host: 10.1.1.4, Local port: 52832
Foreign host: 10.1.1.2, Foreign port: 179
Nexthop: 10.1.1.4
Nexthop global: fe80::1644:8fff:febc:a2c8
Nexthop local: fe80::1644:8fff:febc:a2c8
BGP connection: shared network
BGP Connect Retry Timer in Seconds: 120
Estimated round trip time: 3 ms
Read thread: on Write thread: on FD used: 27
BGP neighbor is 20.1.1.2, remote AS 300, local AS 200, external link
Hostname: sonic
Member of peer-group LEAF for session parameters
BGP version 4, remote router ID 192.168.10.2, local router ID 172.26.1.61
BGP state = Established, up for 00:02:52
Last read 00:00:52, Last write 00:00:52
Hold time is 180, keepalive interval is 60 seconds
Neighbor capabilities:
4 Byte AS: advertised and received
Extended Message: advertised and received
AddPath:
IPv4 Unicast: RX advertised and received
Long-lived Graceful Restart: advertised and received
Address families by peer:
Route refresh: advertised and received(old & new)
Enhanced Route Refresh: advertised and received
Address Family IPv4 Unicast: advertised and received
Hostname Capability: advertised (name: sonic,domain name: n/a) received (name: sonic,domain name: n/a)
Graceful Restart Capability: advertised and received
Remote Restart timer is 120 seconds
Address families by peer:
none
Graceful restart information:
End-of-RIB send: IPv4 Unicast
End-of-RIB received: IPv4 Unicast
Local GR Mode: Helper*
Remote GR Mode: Helper
R bit: True
Timers:
Configured Restart Time(sec): 120
Received Restart Time(sec): 120
IPv4 Unicast:
F bit: False
End-of-RIB sent: Yes
End-of-RIB sent after update: Yes
End-of-RIB received: Yes
Timers:
Configured Stale Path Time(sec): 360
Message statistics:
Inq depth is 0
Outq depth is 0
Sent Rcvd
Opens: 2 1
Notifications: 0 0
Updates: 2 3
Keepalives: 3 3
Route Refresh: 0 0
Capability: 0 0
Total: 7 7
Minimum time between advertisement runs is 0 seconds
For address family: IPv4 Unicast
LEAF peer-group member
Update group 1, subgroup 1
Packet Queue length 0
Community attribute sent to this neighbor(all)
1 accepted prefixes
Connections established 1; dropped 0
Last reset 00:05:35, No AFI/SAFI activated for peer
Local host: 20.1.1.1, Local port: 179
Foreign host: 20.1.1.2, Foreign port: 39192
Nexthop: 20.1.1.1
Nexthop global: fe80::1644:8fff:febc:a2c8
Nexthop local: fe80::1644:8fff:febc:a2c8
BGP connection: shared network
BGP Connect Retry Timer in Seconds: 120
Estimated round trip time: 4 ms
Read thread: on Write thread: on FD used: 28
R3
sonic.PALCNETWORKS.COM(config-router)# do sh bgp summary
IPv4 Unicast Summary (VRF default):
BGP router identifier 192.168.10.2, local AS number 300 vrf-id 0
BGP table version 3
RIB entries 3, using 552 bytes of memory
Peers 1, using 723 KiB of memory
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt Desc
20.1.1.1 4 200 4 5 0 0 0 00:00:09 2 2 N/A
Total number of neighbors 1
sonic.PALCNETWORKS.COM# show ip bgp neighbors
BGP neighbor is 20.1.1.1, remote AS 200, local AS 300, external link
Hostname: sonic
BGP version 4, remote router ID 172.26.1.61, local router ID 192.168.10.2
BGP state = Established, up for 00:02:41
Last read 00:00:41, Last write 00:00:41
Hold time is 180, keepalive interval is 60 seconds
Neighbor capabilities:
4 Byte AS: advertised and received
Extended Message: advertised and received
AddPath:
IPv4 Unicast: RX advertised and received
Long-lived Graceful Restart: advertised and received
Address families by peer:
Route refresh: advertised and received(old & new)
Enhanced Route Refresh: advertised and received
Address Family IPv4 Unicast: advertised and received
Hostname Capability: advertised (name: sonic,domain name: n/a) received (name: sonic,domain name: n/a)
Graceful Restart Capability: advertised and received
Remote Restart timer is 120 seconds
Address families by peer:
none
Graceful restart information:
End-of-RIB send: IPv4 Unicast
End-of-RIB received: IPv4 Unicast
Local GR Mode: Helper*
Remote GR Mode: Helper
R bit: False
Timers:
Configured Restart Time(sec): 120
Received Restart Time(sec): 120
IPv4 Unicast:
F bit: False
End-of-RIB sent: Yes
End-of-RIB sent after update: No
End-of-RIB received: Yes
Timers:
Configured Stale Path Time(sec): 360
Message statistics:
Inq depth is 0
Outq depth is 0
Sent Rcvd
Opens: 1 1
Notifications: 0 0
Updates: 3 2
Keepalives: 3 3
Route Refresh: 0 0
Capability: 0 0
Total: 7 6
Minimum time between advertisement runs is 0 seconds
For address family: IPv4 Unicast
Update group 1, subgroup 1
Packet Queue length 0
Community attribute sent to this neighbor(all)
2 accepted prefixes
Connections established 1; dropped 0
Last reset 00:02:42, Waiting for peer OPEN
Local host: 20.1.1.2, Local port: 39192
Foreign host: 20.1.1.1, Foreign port: 179
Nexthop: 20.1.1.2
Nexthop global: fe80::6a21:5fff:fe9c:fc7b
Nexthop local: fe80::6a21:5fff:fe9c:fc7b
BGP connection: shared network
BGP Connect Retry Timer in Seconds: 120
Estimated round trip time: 4 ms
Read thread: on Write thread: on FD used: 27
Result:
Verify the BGP routes in routing table
R1
sonic.PALCNETWORKS.COM(config-router)# do sh ip bgp
BGP table version is 2, local router ID is 172.26.1.59, vrf id 0
Default local pref 100, local AS 100
Status codes: s suppressed, d damped, h history, * valid, > best, = multipath,
i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
Network Next Hop Metric LocPrf Weight Path
* 10.1.1.0/24 10.1.1.4 0 0 200 i
*> 0.0.0.0 0 32768 i
*> 20.1.1.0/24 10.1.1.4 0 0 200 i
Displayed 2 routes and 3 total paths
sonic.PALCNETWORKS.COM(config-router)# do sh ip route
Codes: K - kernel route, C - connected, S - static, R - RIP,
O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
T - Table, v - VNC, V - VNC-Direct, A - Babel, F - PBR,
f - OpenFabric,
> - selected route, * - FIB route, q - queued, r - rejected, b - backup
t - trapped, o - offload failure
K>* 0.0.0.0/0 [0/0] via 172.26.1.1, eth0, 00:24:34
C>* 1.1.1.1/32 is directly connected, Loopback1, 00:24:31
C>* 10.1.0.1/32 is directly connected, Loopback0, 00:24:31
C>* 10.1.1.0/24 is directly connected, Ethernet60, 00:24:22
B>* 20.1.1.0/24 [20/0] via 10.1.1.4, Ethernet60, weight 1, 00:03:43
C>* 100.1.1.0/24 is directly connected, Ethernet48, 00:24:22
C>* 172.26.1.0/24 is directly connected, eth0, 00:24:34
R2
sonic.PALCNETWORKS.COM(config-router)# do sh ip bgp
BGP table version is 3, local router ID is 172.26.1.61, vrf id 0
Default local pref 100, local AS 200
Status codes: s suppressed, d damped, h history, * valid, > best, = multipath,
i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
Network Next Hop Metric LocPrf Weight Path
*> 10.1.1.0/24 0.0.0.0 0 32768 i
* 10.1.1.2 0 0 100 i
* 20.1.1.0/24 20.1.1.2 0 0 300 i
*> 0.0.0.0 0 32768 i
Displayed 2 routes and 4 total paths
sonic.PALCNETWORKS.COM(config-router)# do sh ip route
Codes: K - kernel route, C - connected, S - static, R - RIP,
O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
T - Table, v - VNC, V - VNC-Direct, A - Babel, F - PBR,
f - OpenFabric,
> - selected route, * - FIB route, q - queued, r - rejected, b - backup
t - trapped, o - offload failure
K>* 0.0.0.0/0 [0/0] via 172.26.1.1, eth0, 00:24:00
C>* 2.2.2.2/32 is directly connected, Loopback1, 00:16:48
C>* 10.1.0.1/32 is directly connected, Loopback0, 00:23:56
C>* 10.1.1.0/24 is directly connected, Ethernet60, 00:17:39
C>* 20.1.1.0/24 is directly connected, Ethernet6, 00:17:26
C>* 172.26.1.0/24 is directly connected, eth0, 00:24:00
R3
sonic.PALCNETWORKS.COM(config-router)# do sh ip bgp
BGP table version is 3, local router ID is 192.168.10.2, vrf id 0
Default local pref 100, local AS 300
Status codes: s suppressed, d damped, h history, * valid, > best, = multipath,
i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
Network Next Hop Metric LocPrf Weight Path
*> 10.1.1.0/24 20.1.1.1 0 0 200 i
*> 20.1.1.0/24 0.0.0.0 0 32768 i
* 20.1.1.1 0 0 200 i
Displayed 2 routes and 3 total paths
sonic.PALCNETWORKS.COM(config-router)# do sh ip route
Codes: K - kernel route, C - connected, S - static, R - RIP,
O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
T - Table, v - VNC, V - VNC-Direct, A - Babel, F - PBR,
f - OpenFabric,
> - selected route, * - FIB route, q - queued, r - rejected, b - backup
t - trapped, o - offload failure
C>* 3.3.3.3/32 is directly connected, Loopback1, 00:16:24
C>* 10.1.0.1/32 is directly connected, Loopback0, 00:24:19
B>* 10.1.1.0/24 [20/0] via 20.1.1.1, Ethernet6, weight 1, 00:01:28
C>* 20.1.1.0/24 is directly connected, Ethernet6, 00:15:58
C>* 192.168.10.0/24 is directly connected, Ethernet50, 00:24:04
Verify the reachability of remote network
R1
sonic.PALCNETWORKS.COM# ping 20.1.1.2
PING 20.1.1.2 (20.1.1.2) 56(84) bytes of data.
64 bytes from 20.1.1.2: icmp_seq=1 ttl=63 time=0.262 ms
64 bytes from 20.1.1.2: icmp_seq=2 ttl=63 time=0.259 ms
64 bytes from 20.1.1.2: icmp_seq=3 ttl=63 time=0.286 ms
64 bytes from 20.1.1.2: icmp_seq=4 ttl=63 time=0.313 ms
^C
--- 20.1.1.2 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3073ms
rtt min/avg/max/mdev = 0.259/0.280/0.313/0.021 ms
R3
sonic.PALCNETWORKS.COM# ping 10.1.1.2
PING 10.1.1.2 (10.1.1.2) 56(84) bytes of data.
64 bytes from 10.1.1.2: icmp_seq=1 ttl=63 time=0.328 ms
64 bytes from 10.1.1.2: icmp_seq=2 ttl=63 time=0.311 ms
64 bytes from 10.1.1.2: icmp_seq=3 ttl=63 time=0.248 ms
64 bytes from 10.1.1.2: icmp_seq=4 ttl=63 time=0.285 ms
^C
--- 10.1.1.2 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3055ms
rtt min/avg/max/mdev = 0.248/0.293/0.328/0.030 ms
Establish iBGP with route-reflector
Due to the BGP split-horizon rule (within iBGP), all iBGP peers within an AS must be fully meshed. One solution to reducing the number of BGP peerings within an AS is route reflection. Rather than each BGP system having to peer with every other BGP system with the AS, each BGP speaker instead peers with a router reflector. Routing advertisements sent to the route reflector are then reflected out to all of the other BGP speakers.
Topology:
Procedure:
Note: Commands are to be executed in sudo and vtysh mode
Step 1: Configure ip address for interfaces and loopbacks
R1
root@sonic:/home/admin#config interface ip add Ethernet60 10.1.1.1/24
root@sonic:/home/admin#config interface ip add Loopback1 1.1.1.1/32
R2
root@sonic:/home/admin#config interface ip add Ethernet60 10.1.1.2/24
root@sonic:/home/admin#config interface ip add Ethernet6 20.1.1.1/24
root@sonic:/home/admin#config interface ip add Loopback1 2.2.2.2/32
R3
root@sonic:/home/admin#config interface ip add Ethernet6 20.1.1.2/24
root@sonic:/home/admin#config interface ip add Loopback1 3.3.3.3/32
Step 2: Enter vtysh shell
root@sonic:/home/admin# vtysh
Hello, this is FRRouting (version 8.2.2).
Copyright 1996-2005 Kunihiro Ishiguro, et al.
sonic.PALCNETWORKS.COM#
Step 3: Configure BGP neighbor session
R1
sonic.PALCNETWORKS.COM#configure terminal
sonic.PALCNETWORKS.COM(config)# router bgp 100
sonic.PALCNETWORKS.COM(config-router)# bgp router-id 1.1.1.1
sonic.PALCNETWORKS.COM(config-router)# no bgp ebgp-requires-policy
sonic.PALCNETWORKS.COM(config-router)# neighbor 10.1.1.2 remote-as 100
sonic.PALCNETWORKS.COM(config-router)# network 10.1.1.0/24
sonic.PALCNETWORKS.COM(config-router)# network 1.1.1.1/32
R2
sonic.PALCNETWORKS.COM#configure terminal
sonic.PALCNETWORKS.COM(config)# router bgp 100
sonic.PALCNETWORKS.COM(config-router)# bgp router-id 2.2.2.2
sonic.PALCNETWORKS.COM(config-router)# no bgp ebgp-requires-policy
sonic.PALCNETWORKS.COM(config-router)# neighbor 10.1.1.1 remote-as 100
sonic.PALCNETWORKS.COM(config-router)# neighbor 20.1.1.2 remote-as 100
sonic.PALCNETWORKS.COM(config-router)# address-family ipv4 unicast
sonic.PALCNETWORKS.COM(config-router-af)# neighbor 10.1.1.1 route-reflector-client
sonic.PALCNETWORKS.COM(config-router-af)# neighbor 20.1.1.2 route-reflector-client
sonic.PALCNETWORKS.COM(config-router-af)# network 2.2.2.2/32
sonic.PALCNETWORKS.COM(config-router-af)# network 10.1.1.0/24
sonic.PALCNETWORKS.COM(config-router-af)# network 20.1.1.0/24
R3
sonic.PALCNETWORKS.COM#configure terminal
sonic.PALCNETWORKS.COM(config)# router bgp 100
sonic.PALCNETWORKS.COM(config-router)# bgp router-id 3.3.3.3
sonic.PALCNETWORKS.COM(config-router)# no bgp ebgp-requires-policy
sonic.PALCNETWORKS.COM(config-router)# neighbor 20.1.1.1 remote-as 100
sonic.PALCNETWORKS.COM(config-router)# network 3.3.3.3/32
sonic.PALCNETWORKS.COM(config-router)# network 20.1.1.0/24
Step 4: Checking the BGP neighbors
R1
sonic.PALCNETWORKS.COM(config-router)# do sh bgp summary
IPv4 Unicast Summary (VRF default):
BGP router identifier 1.1.1.1, local AS number 100 vrf-id 0
BGP table version 5
RIB entries 9, using 1656 bytes of memory
Peers 1, using 723 KiB of memory
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt Desc
10.1.1.2 4 100 14 9 0 0 0 00:01:41 4 2 N/A
Total number of neighbors 1
R2
sonic.PALCNETWORKS.COM(config-router-af)# do sh bgp summary
IPv4 Unicast Summary (VRF default):
BGP router identifier 2.2.2.2, local AS number 100 vrf-id 0
BGP table version 10
RIB entries 9, using 1656 bytes of memory
Peers 2, using 1447 KiB of memory
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt Desc
10.1.1.1 4 100 10 15 0 0 0 00:02:18 2 5 N/A
20.1.1.2 4 100 6 7 0 0 0 00:01:29 2 5 N/A
Total number of neighbors 2
R3
sonic.PALCNETWORKS.COM(config-router)# do sh bgp summary
IPv4 Unicast Summary (VRF default):
BGP router identifier 3.3.3.3, local AS number 100 vrf-id 0
BGP table version 6
RIB entries 9, using 1656 bytes of memory
Peers 1, using 723 KiB of memory
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt Desc
20.1.1.1 4 100 6 5 0 0 0 00:00:15 4 2 N/A
Total number of neighbors 1
Result:
Verify the BGP routes in routing table
R1
“Show ip route” in R1 shows the 3.3.3.3 ip of R3 is present in the routing table
sonic.PALCNETWORKS.COM)# show ip route bgp
Codes: K - kernel route, C - connected, S - static, R - RIP,
O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
T - Table, v - VNC, V - VNC-Direct, A - Babel, F - PBR,
f - OpenFabric,
> - selected route, * - FIB route, q - queued, r - rejected, b - backup
t - trapped, o - offload failure
B>* 2.2.2.2/32 [200/0] via 10.1.1.2, Ethernet60, weight 1, 00:01:45
B> 3.3.3.3/32 [200/0] via 20.1.1.2 (recursive), weight 1, 00:01:00
* via 10.1.1.2, Ethernet60, weight 1, 00:01:00
B>* 20.1.1.0/24 [200/0] via 10.1.1.2, Ethernet60, weight 1, 00:01:33
sonic.PALCNETWORKS.COM(config-router)# do sh ip bgp
BGP table version is 5, local router ID is 1.1.1.1, vrf id 0
Default local pref 100, local AS 100
Status codes: s suppressed, d damped, h history, * valid, > best, = multipath,
i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
Network Next Hop Metric LocPrf Weight Path
*> 1.1.1.1/32 0.0.0.0 0 32768 i
*>i2.2.2.2/32 10.1.1.2 0 100 0 i
*>i3.3.3.3/32 20.1.1.2 0 100 0 i
* i10.1.1.0/24 10.1.1.2 0 100 0 i
*> 0.0.0.0 0 32768 i
*>i20.1.1.0/24 10.1.1.2 0 100 0 i
Displayed 5 routes and 6 total paths
R3
“Show ip route” in R3 shows the 1.1.1.1 ip of R1 is present in the routing table
sonic.PALCNETWORKS.COM(config-router)# do sh ip bgp
BGP table version is 6, local router ID is 3.3.3.3, vrf id 0
Default local pref 100, local AS 100
Status codes: s suppressed, d damped, h history, * valid, > best, = multipath,
i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
Network Next Hop Metric LocPrf Weight Path
*>i1.1.1.1/32 10.1.1.1 0 100 0 i
*>i2.2.2.2/32 20.1.1.1 0 100 0 i
*> 3.3.3.3/32 0.0.0.0 0 32768 i
*>i10.1.1.0/24 20.1.1.1 0 100 0 i
*> 20.1.1.0/24 0.0.0.0 0 32768 i
* i 20.1.1.1 0 100 0 i
Displayed 5 routes and 6 total paths
sonic.PALCNETWORKS.COM(config-router)# do sh ip route bgp
Codes: K - kernel route, C - connected, S - static, R - RIP,
O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
T - Table, v - VNC, V - VNC-Direct, A - Babel, F - PBR,
f - OpenFabric,
> - selected route, * - FIB route, q - queued, r - rejected, b - backup
t - trapped, o - offload failure
B> 1.1.1.1/32 [200/0] via 10.1.1.1 (recursive), weight 1, 00:00:30
* via 20.1.1.1, Ethernet6, weight 1, 00:00:30
B>* 2.2.2.2/32 [200/0] via 20.1.1.1, Ethernet6, weight 1, 00:00:30
B>* 10.1.1.0/24 [200/0] via 20.1.1.1, Ethernet6, weight 1, 00:00:30
Establish eBGP with access-list
Procedure:
Note: Commands are to be executed in sudo and vtysh mode
Step 1: Configure ip address for interfaces and loopbacks
R1
root@sonic:/home/admin#config interface ip add Ethernet60 10.1.1.1/24
root@sonic:/home/admin#config interface ip add Loopback0 1.1.1.1/32
root@sonic:/home/admin#config interface ip add Ethernet4 30.1.1.1/24
R2
root@sonic:/home/admin#config interface ip add Ethernet60 10.1.1.2/24
root@sonic:/home/admin#config interface ip add Ethernet6 20.1.1.1/24
root@sonic:/home/admin#config interface ip add Loopback0 2.2.2.2/32
R3
root@sonic:/home/admin#config interface ip add Ethernet6 20.1.1.2/24
root@sonic:/home/admin#config interface ip add Loopback0 3.3.3.3/32
root@sonic:/home/admin#config interface ip add Ethernet4 30.1.1.2/24
Step 2: Enter vtysh shell
root@sonic:/home/admin# vtysh
Hello, this is FRRouting (version 8.2.2).
Copyright 1996-2005 Kunihiro Ishiguro, et al.
sonic.PALCNETWORKS.COM#
Step 3: Configure BGP neighbor session
R1
sonic.PALCNETWORKS.COM#config
sonic.PALCNETWORKS.COM(config)# router bgp 100
sonic.PALCNETWORKS.COM(config-router)#bgp router-id 1.1.1.1
sonic.PALCNETWORKS.COM(config-router)# no bgp ebgp-requires-policy
sonic.PALCNETWORKS.COM(config-router)# neighbor 10.1.1.2 remote-as 200
sonic.PALCNETWORKS.COM(config-router)# neighbor 30.1.1.2 remote-as 300
sonic.PALCNETWORKS.COM(config-router)# network 10.1.1.0/24
sonic.PALCNETWORKS.COM(config-router)# network 30.1.1.0/24
sonic.PALCNETWORKS.COM(config-router)# network 1.1.1.1/32
R2
sonic.PALCNETWORKS.COM#config
sonic.PALCNETWORKS.COM(config)# router bgp 200
sonic.PALCNETWORKS.COM(config-router)#bgp router-id 2.2.2.2
sonic.PALCNETWORKS.COM(config-router)# no bgp ebgp-requires-policy
sonic.PALCNETWORKS.COM(config-router)# neighbor 10.1.1.1 remote-as 100
sonic.PALCNETWORKS.COM(config-router)# neighbor 20.1.1.2 remote-as 300
sonic.PALCNETWORKS.COM(config-router)# network 10.1.1.0/24
sonic.PALCNETWORKS.COM(config-router)# network 20.1.1.0/24
sonic.PALCNETWORKS.COM(config-router)# network 2.2.2.2/32
R3
sonic.PALCNETWORKS.COM#config
sonic.PALCNETWORKS.COM(config)# router bgp 300
sonic.PALCNETWORKS.COM(config-router)#bgp router-id 3.3.3.3
sonic.PALCNETWORKS.COM(config-router)# neighbor 20.1.1.1 remote-as 200
sonic.PALCNETWORKS.COM(config-router)# no bgp ebgp-requires-policy
sonic.PALCNETWORKS.COM(config-router)# neighbor 30.1.1.1 remote-as 100
sonic.PALCNETWORKS.COM(config-router)# network 30.1.1.0/24
sonic.PALCNETWORKS.COM(config-router)# network 20.1.1.0/24
sonic.PALCNETWORKS.COM(config-router)# network 3.3.3.3/32
Step 4: Checking the BGP neighbors
R1
sonic.PALCNETWORKS.COM(config)# do sh bgp summary
IPv4 Unicast Summary (VRF default):
BGP router identifier 1.1.1.1, local AS number 100 vrf-id 0
BGP table version 16
RIB entries 11, using 2024 bytes of memory
Peers 2, using 1447 KiB of memory
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt Desc
10.1.1.2 4 200 85 89 0 0 0 00:03:30 4 6 N/A
30.1.1.2 4 300 18 17 0 0 0 00:02:31 4 6 N/A
Total number of neighbors 2
R2
sonic.PALCNETWORKS.COM# sh bgp summary
IPv4 Unicast Summary (VRF default):
BGP router identifier 2.2.2.2, local AS number 200 vrf-id 0
BGP table version 14
RIB entries 11, using 2024 bytes of memory
Peers 2, using 1447 KiB of memory
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt Desc
10.1.1.1 4 100 101 94 0 0 0 00:08:35 4 6 N/A
20.1.1.2 4 300 91 90 0 0 0 00:07:36 5 6 N/A
Total number of neighbors 2
R3
sonic.PALCNETWORKS.COM(config-router)# do sh bgp summary
IPv4 Unicast Summary (VRF default):
BGP router identifier 3.3.3.3, local AS number 300 vrf-id 0
BGP table version 17
RIB entries 5, using 920 bytes of memory
Peers 2, using 1447 KiB of memory
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt Desc
20.1.1.1 4 200 74 79 0 0 0 00:00:00 0 0 N/A
30.1.1.1 4 100 9 12 0 0 0 00:00:00 0 0 N/A
Total number of neighbors 2
Step 5: Add access-list on R1 to block the 2.2.2.2 route coming from R2 and R3
R1
sonic.PALCNETWORKS.COM(config)# access-list 20 deny 2.2.2.2/32
sonic.PALCNETWORKS.COM(config)# access-list 20 permit any
Step 6: configure access-list in BGP
R1
sonic.PALCNETWORKS.COM(config)# router bgp 100
sonic.PALCNETWORKS.COM(config-router-af)# neighbor 10.1.1.2 distribute-list 20 in
sonic.PALCNETWORKS.COM(config-router-af)# neighbor 30.1.1.2 distribute-list 20 in
sonic.PALCNETWORKS.COM(config-router-af)#do clear ip bgp * soft
Note: clear ip bgp * soft is performs soft reset of bgp neighbors relationship in both direction i.e, in and out.
Result:
Verify the BGP routes in routing table before BGP filtering
R1
sonic.PALCNETWORKS.COM(config-router)# do sh ip bgp
BGP table version is 16, local router ID is 1.1.1.1, vrf id 0
Default local pref 100, local AS 100
Status codes: s suppressed, d damped, h history, * valid, > best, = multipath,
i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
Network Next Hop Metric LocPrf Weight Path
*> 1.1.1.1/32 0.0.0.0 0 32768 i
* 2.2.2.2/32 30.1.1.2 0 300 200 i
*> 10.1.1.2 0 0 200 i
* 3.3.3.3/32 10.1.1.2 0 200 300 i
*> 30.1.1.2 0 0 300 i
* 10.1.1.0/24 10.1.1.2 0 0 200 i
*> 0.0.0.0 0 32768 i
* 20.1.1.0/24 30.1.1.2 0 0 300 i
*> 10.1.1.2 0 0 200 i
* 30.1.1.0/24 30.1.1.2 0 0 300 i
*> 0.0.0.0 0 32768 i
Displayed 6 routes and 11 total paths
Verify the BGP routes in routing after BGP filtering
R1
sonic.PALCNETWORKS.COM(config-router-af)# do sh ip bgp
BGP table version is 18, local router ID is 1.1.1.1, vrf id 0
Default local pref 100, local AS 100
Status codes: s suppressed, d damped, h history, * valid, > best, = multipath,
i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
Network Next Hop Metric LocPrf Weight Path
*> 1.1.1.1/32 0.0.0.0 0 32768 i
* 3.3.3.3/32 10.1.1.2 0 200 300 i
*> 30.1.1.2 0 0 300 i
* 10.1.1.0/24 10.1.1.2 0 0 200 i
*> 0.0.0.0 0 32768 i
* 20.1.1.0/24 30.1.1.2 0 0 300 i
*> 10.1.1.2 0 0 200 i
* 30.1.1.0/24 30.1.1.2 0 0 300 i
*> 0.0.0.0 0 32768 i
Displayed 5 routes and 9 total paths
BGP summarization
BGP route summarization on EBGP routers for nontransitive ASs reduce route computation on routers in the core of the nontransitive AS.
Topology:
Procedure:
Note: Commands are to be executed in sudo and vtysh mode
Step 1: Configure ip address for interfaces and loopbacks
Step 2: Enter vtysh mode
Step 3: Configure BGP neighbor
R1
sonic.PALCNETWORKS.COM#configure terminal
sonic.PALCNETWORKS.COM(config)# router bgp 100
sonic.PALCNETWORKS.COM(config-router)# bgp router-id 1.1.1.1
sonic.PALCNETWORKS.COM(config-router)# no bgp ebgp-requires-policy
sonic.PALCNETWORKS.COM(config-router)# neighbor 10.1.1.2 remote-as 200
sonic.PALCNETWORKS.COM(config-router)# neighbor 30.1.1.2 remote-as 300
sonic.PALCNETWORKS.COM(config-router)# network 1.1.1.1/32
sonic.PALCNETWORKS.COM(config-router)# network 1.1.2.1/32
sonic.PALCNETWORKS.COM(config-router)# network 1.1.3.1/32
sonic.PALCNETWORKS.COM(config-router)# network 1.1.4.1/32
sonic.PALCNETWORKS.COM(config-router)# network 10.1.1.0/24
sonic.PALCNETWORKS.COM(config-router)# network 30.1.1.0/24
R2
sonic.PALCNETWORKS.COM# conf
sonic.PALCNETWORKS.COM(config)# router bgp 200
sonic.PALCNETWORKS.COM(config-router)# bgp router-id 2.2.2.2
sonic.PALCNETWORKS.COM(config-router)# no bgp ebgp-requires-policy
sonic.PALCNETWORKS.COM(config-router)# neighbor 10.1.1.1 remote-as 100
sonic.PALCNETWORKS.COM(config-router)# neighbor 20.1.1.2 remote-as 300
sonic.PALCNETWORKS.COM(config-router)# network 2.2.2.2/32
sonic.PALCNETWORKS.COM(config-router)# network 10.1.1.0/24
sonic.PALCNETWORKS.COM(config-router)# network 20.1.1.0/24
R3
sonic.PALCNETWORKS.COM# conf
sonic.PALCNETWORKS.COM(config)# router bgp 300
sonic.PALCNETWORKS.COM(config-router)# bgp router-id 3.3.3.3
sonic.PALCNETWORKS.COM(config-router)# no bgp ebgp-requires-policy
sonic.PALCNETWORKS.COM(config-router)# neighbor 30.1.1.1 remote-as 100
sonic.PALCNETWORKS.COM(config-router)# neighbor 20.1.1.1 remote-as 200
sonic.PALCNETWORKS.COM(config-router)# network 3.3.3.3/32
sonic.PALCNETWORKS.COM(config-router)# network 20.1.1.0/24
sonic.PALCNETWORKS.COM(config-router)# network 30.1.1.0/24
Step 4: Checking the BGP neighbors
R1
sonic.PALCNETWORKS.COM(config-router)# do sh bgp summary
IPv4 Unicast Summary (VRF default):
BGP router identifier 1.1.1.1, local AS number 100 vrf-id 0
BGP table version 9
RIB entries 17, using 3128 bytes of memory
Peers 2, using 1447 KiB of memory
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt Desc
10.1.1.2 4 200 9 8 0 0 0 00:01:30 4 9 N/A
30.1.1.2 4 300 9 6 0 0 0 00:00:43 4 9 N/A
Total number of neighbors 2
R2
sonic.PALCNETWORKS.COM(config-router)# do sh bgp summary
IPv4 Unicast Summary (VRF default):
BGP router identifier 2.2.2.2, local AS number 200 vrf-id 0
BGP table version 10
RIB entries 17, using 3128 bytes of memory
Peers 2, using 1447 KiB of memory
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt Desc
10.1.1.1 4 100 8 9 0 0 0 00:01:25 7 9 N/A
20.1.1.2 4 300 9 6 0 0 0 00:00:33 8 9 N/A
Total number of neighbors 2
R3
sonic.PALCNETWORKS.COM(config-router)# do sh bgp summary
IPv4 Unicast Summary (VRF default):
BGP router identifier 3.3.3.3, local AS number 300 vrf-id 0
BGP table version 13
RIB entries 17, using 3128 bytes of memory
Peers 2, using 1447 KiB of memory
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt Desc
20.1.1.1 4 200 6 9 0 0 0 00:00:27 8 9 N/A
30.1.1.1 4 100 6 9 0 0 0 00:00:32 8 9 N/A
Total number of neighbors 2
Step 5: Configure BGP summarization
R1
sonic.PALCNETWORKS.COM(config)# router bgp 100
sonic.PALCNETWORKS.COM(config-router)# aggregate-address 1.1.0.0/16 summary-only
sonic.PALCNETWORKS.COM(config-router)# do clear ip bgp * soft
Result:
Verify the BGP routes in routing table before BGP summarization
R1
sonic.PALCNETWORKS.COM(config-router)# do sh ip bgp
BGP table version is 9, local router ID is 1.1.1.1, vrf id 0
Default local pref 100, local AS 100
Status codes: s suppressed, d damped, h history, * valid, > best, = multipath,
i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
Network Next Hop Metric LocPrf Weight Path
*> 1.1.1.1/32 0.0.0.0 0 32768 i
*> 1.1.2.1/32 0.0.0.0 0 32768 i
*> 1.1.3.1/32 0.0.0.0 0 32768 i
*> 1.1.4.1/32 0.0.0.0 0 32768 i
* 2.2.2.2/32 30.1.1.2 0 300 200 i
*> 10.1.1.2 0 0 200 i
* 3.3.3.3/32 10.1.1.2 0 200 300 i
*> 30.1.1.2 0 0 300 i
* 10.1.1.0/24 10.1.1.2 0 0 200 i
*> 0.0.0.0 0 32768 i
* 20.1.1.0/24 30.1.1.2 0 0 300 i
*> 10.1.1.2 0 0 200 i
* 30.1.1.0/24 30.1.1.2 0 0 300 i
*> 0.0.0.0 0 32768 i
Displayed 9 routes and 14 total paths
R2
sonic.PALCNETWORKS.COM(config-router)# do sh ip bgp
BGP table version is 10, local router ID is 2.2.2.2, vrf id 0
Default local pref 100, local AS 200
Status codes: s suppressed, d damped, h history, * valid, > best, = multipath,
i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
Network Next Hop Metric LocPrf Weight Path
* 1.1.1.1/32 20.1.1.2 0 300 100 i
*> 10.1.1.1 0 0 100 i
* 1.1.2.1/32 20.1.1.2 0 300 100 i
*> 10.1.1.1 0 0 100 i
* 1.1.3.1/32 20.1.1.2 0 300 100 i
*> 10.1.1.1 0 0 100 i
* 1.1.4.1/32 20.1.1.2 0 300 100 i
*> 10.1.1.1 0 0 100 i
*> 2.2.2.2/32 0.0.0.0 0 32768 i
* 3.3.3.3/32 10.1.1.1 0 100 300 i
*> 20.1.1.2 0 0 300 i
* 10.1.1.0/24 20.1.1.2 0 300 100 i
*> 0.0.0.0 0 32768 i
* 10.1.1.1 0 0 100 i
* 20.1.1.0/24 20.1.1.2 0 0 300 i
*> 0.0.0.0 0 32768 i
* 30.1.1.0/24 20.1.1.2 0 0 300 i
*> 10.1.1.1 0 0 100 i
Displayed 9 routes and 18 total paths
R3
sonic.PALCNETWORKS.COM(config-router)# do sh ip bgp
BGP table version is 13, local router ID is 3.3.3.3, vrf id 0
Default local pref 100, local AS 300
Status codes: s suppressed, d damped, h history, * valid, > best, = multipath,
i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
Network Next Hop Metric LocPrf Weight Path
* 1.1.1.1/32 20.1.1.1 0 200 100 i
*> 30.1.1.1 0 0 100 i
* 1.1.2.1/32 20.1.1.1 0 200 100 i
*> 30.1.1.1 0 0 100 i
* 1.1.3.1/32 20.1.1.1 0 200 100 i
*> 30.1.1.1 0 0 100 i
* 1.1.4.1/32 20.1.1.1 0 200 100 i
*> 30.1.1.1 0 0 100 i
*> 2.2.2.2/32 20.1.1.1 0 0 200 i
* 30.1.1.1 0 100 200 i
*> 3.3.3.3/32 0.0.0.0 0 32768 i
* 10.1.1.0/24 20.1.1.1 0 0 200 i
*> 30.1.1.1 0 0 100 i
*> 20.1.1.0/24 0.0.0.0 0 32768 i
* 20.1.1.1 0 0 200 i
* 30.1.1.1 0 100 200 i
*> 30.1.1.0/24 0.0.0.0 0 32768 i
* 20.1.1.1 0 200 100 i
* 30.1.1.1 0 0 100 i
Displayed 9 routes and 19 total paths
Verify the BGP summarized routing table
R1
sonic.PALCNETWORKS.COM(config-router)# do sh ip bgp
BGP table version is 18, local router ID is 1.1.1.1, vrf id 0
Default local pref 100, local AS 100
Status codes: s suppressed, d damped, h history, * valid, > best, = multipath,
i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
Network Next Hop Metric LocPrf Weight Path
*> 1.1.0.0/16 0.0.0.0 32768 i
s> 1.1.1.1/32 0.0.0.0 0 32768 i
s> 1.1.2.1/32 0.0.0.0 0 32768 i
s> 1.1.3.1/32 0.0.0.0 0 32768 i
s> 1.1.4.1/32 0.0.0.0 0 32768 i
* 2.2.2.2/32 30.1.1.2 0 300 200 i
*> 10.1.1.2 0 0 200 i
* 3.3.3.3/32 10.1.1.2 0 200 300 i
*> 30.1.1.2 0 0 300 i
* 10.1.1.0/24 10.1.1.2 0 0 200 i
*> 0.0.0.0 0 32768 i
* 20.1.1.0/24 30.1.1.2 0 0 300 i
*> 10.1.1.2 0 0 200 i
* 30.1.1.0/24 30.1.1.2 0 0 300 i
*> 0.0.0.0 0 32768 i
Displayed 10 routes and 15 total paths
R2
sonic.PALCNETWORKS.COM(config-router)# do sh ip bgp
BGP table version is 25, local router ID is 2.2.2.2, vrf id 0
Default local pref 100, local AS 200
Status codes: s suppressed, d damped, h history, * valid, > best, = multipath,
i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
Network Next Hop Metric LocPrf Weight Path
* 1.1.0.0/16 20.1.1.2 0 300 100 i
*> 10.1.1.1 0 100 i
*> 2.2.2.2/32 0.0.0.0 0 32768 i
* 3.3.3.3/32 10.1.1.1 0 100 300 i
*> 20.1.1.2 0 0 300 i
* 10.1.1.0/24 20.1.1.2 0 300 100 i
*> 0.0.0.0 0 32768 i
* 10.1.1.1 0 0 100 i
* 20.1.1.0/24 20.1.1.2 0 0 300 i
*> 0.0.0.0 0 32768 i
* 30.1.1.0/24 20.1.1.2 0 0 300 i
*> 10.1.1.1 0 0 100 i
Displayed 6 routes and 12 total paths
R3
sonic.PALCNETWORKS.COM(config-router)# do sh ip bgp
BGP table version is 28, local router ID is 3.3.3.3, vrf id 0
Default local pref 100, local AS 300
Status codes: s suppressed, d damped, h history, * valid, > best, = multipath,
i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
Network Next Hop Metric LocPrf Weight Path
* 1.1.0.0/16 20.1.1.1 0 200 100 i
*> 30.1.1.1 0 100 i
*> 2.2.2.2/32 20.1.1.1 0 0 200 i
* 30.1.1.1 0 100 200 i
*> 3.3.3.3/32 0.0.0.0 0 32768 i
* 10.1.1.0/24 20.1.1.1 0 0 200 i
*> 30.1.1.1 0 0 100 i
*> 20.1.1.0/24 0.0.0.0 0 32768 i
* 20.1.1.1 0 0 200 i
* 30.1.1.1 0 100 200 i
*> 30.1.1.0/24 0.0.0.0 0 32768 i
* 20.1.1.1 0 200 100 i
* 30.1.1.1 0 0 100 i
Displayed 6 routes and 13 total paths
EBGP Attributes
BGP (Border Gateway Protocol) routers usually receive multiple paths to the same destination. BGP need to select the best path to each destination based on a list of attributes.
Weight
BGP firstly check the Weight Attribute (priority 1) value and prefer the Highest Weight Attribute value. Then BGP Best Path selection continues with Local Preference and so on. This is a value that is local to the router. The default value is 0 for all routes that are not originated by the local router.
Prefix lists provide mechanisms to match two components of an IP route: The route prefix (the subnet number) and the prefix length (the subnet mask)
A route-map allows you to check for certain match conditions and (optionally) set a value. Route map entries are read in order. You can identify the order using the sequence number argument, or it uses the order in which route map entries are added.
Procedure:
Note: Commands are to be executed in sudo and vtysh mode
Step 1: Configure ip address for interfaces and loopbacks
Step 2: Enter vtysh mode
Step 3: Configure BGP neighbor
R1
sonic.PALCNETWORKS.COM#configure terminal
sonic.PALCNETWORKS.COM(config)# router bgp 100
sonic.PALCNETWORKS.COM(config-router)# bgp router-id 1.1.1.1
sonic.PALCNETWORKS.COM(config-router)# no bgp ebgp-requires-policy
sonic.PALCNETWORKS.COM(config-router)# neighbor 10.1.1.2 remote-as 200
sonic.PALCNETWORKS.COM(config-router)# neighbor 30.1.1.2 remote-as 300
sonic.PALCNETWORKS.COM(config-router)# network 1.1.1.1/32
sonic.PALCNETWORKS.COM(config-router)# network 1.1.2.1/32
sonic.PALCNETWORKS.COM(config-router)# network 1.1.3.1/32
sonic.PALCNETWORKS.COM(config-router)# network 10.1.1.0/24
sonic.PALCNETWORKS.COM(config-router)# network 30.1.1.0/24
R2
sonic.PALCNETWORKS.COM# conf
sonic.PALCNETWORKS.COM(config)# router bgp 200
sonic.PALCNETWORKS.COM(config-router)# bgp router-id 2.2.2.2
sonic.PALCNETWORKS.COM(config-router)# no bgp ebgp-requires-policy
sonic.PALCNETWORKS.COM(config-router)# neighbor 10.1.1.1 remote-as 100
sonic.PALCNETWORKS.COM(config-router)# neighbor 20.1.1.2 remote-as 300
sonic.PALCNETWORKS.COM(config-router)# network 2.2.2.2/32
sonic.PALCNETWORKS.COM(config-router)# network 10.1.1.0/24
sonic.PALCNETWORKS.COM(config-router)# network 20.1.1.0/24
R3
sonic.PALCNETWORKS.COM# conf
sonic.PALCNETWORKS.COM(config)# router bgp 300
sonic.PALCNETWORKS.COM(config-router)# bgp router-id 3.3.3.3
sonic.PALCNETWORKS.COM(config-router)# no bgp ebgp-requires-policy
sonic.PALCNETWORKS.COM(config-router)# neighbor 30.1.1.1 remote-as 100
sonic.PALCNETWORKS.COM(config-router)# neighbor 20.1.1.1 remote-as 200
sonic.PALCNETWORKS.COM(config-router)# network 3.3.3.3/32
sonic.PALCNETWORKS.COM(config-router)# network 20.1.1.0/24
sonic.PALCNETWORKS.COM(config-router)# network 30.1.1.0/24
Step 4: Checking the BGP neighbors
R1
sonic.PALCNETWORKS.COM(config-router)# do sh bgp summary
IPv4 Unicast Summary (VRF default):
BGP router identifier 1.1.1.1, local AS number 100 vrf-id 0
BGP table version 9
RIB entries 17, using 3128 bytes of memory
Peers 2, using 1447 KiB of memory
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt Desc
10.1.1.2 4 200 9 8 0 0 0 00:01:30 4 9 N/A
30.1.1.2 4 300 9 6 0 0 0 00:00:43 4 9 N/A
Total number of neighbors 2
R2
sonic.PALCNETWORKS.COM(config-router)# do sh bgp summary
IPv4 Unicast Summary (VRF default):
BGP router identifier 2.2.2.2, local AS number 200 vrf-id 0
BGP table version 10
RIB entries 17, using 3128 bytes of memory
Peers 2, using 1447 KiB of memory
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt Desc
10.1.1.1 4 100 8 9 0 0 0 00:01:25 7 9 N/A
20.1.1.2 4 300 9 6 0 0 0 00:00:33 8 9 N/A
Total number of neighbors 2
R3
sonic.PALCNETWORKS.COM(config-router)# do sh bgp summary
IPv4 Unicast Summary (VRF default):
BGP router identifier 3.3.3.3, local AS number 300 vrf-id 0
BGP table version 13
RIB entries 17, using 3128 bytes of memory
Peers 2, using 1447 KiB of memory
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt Desc
20.1.1.1 4 200 6 9 0 0 0 00:00:27 8 9 N/A
30.1.1.1 4 100 6 9 0 0 0 00:00:32 8 9 N/A
Total number of neighbors 2
Step 5: Apply weight on R3 to choose best path for 1.1.2.1 and 1.1.3.1 routes via R1-R2-R3
R3
sonic.PALCNETWORKS.COM# conf
sonic.PALCNETWORKS.COM(config)# ip prefix-list 12 seq 5 permit 1.1.2.1/32
sonic.PALCNETWORKS.COM(config)# ip prefix-list 12 seq 10 permit 1.1.3.1/32
sonic.PALCNETWORKS.COM(config)# route-map bgp permit 10
sonic.PALCNETWORKS.COM(config-route-map)# match ip address prefix-list 12
sonic.PALCNETWORKS.COM(config-route-map)# set weight 4000
sonic.PALCNETWORKS.COM(config-route-map)# exit
sonic.PALCNETWORKS.COM(config)# route-map bgp permit 20
sonic.PALCNETWORKS.COM(config-route-map)# exit
Step 6: Configure route-map in BGP
R3
sonic.PALCNETWORKS.COM# conf
sonic.PALCNETWORKS.COM(config)# router bgp 300
sonic.PALCNETWORKS.COM(config-router)# address-family ipv4 unicast
sonic.PALCNETWORKS.COM(config-router-af)# neighbor 20.1.1.1 route-map bgp in
sonic.PALCNETWORKS.COM(config-router-af)# exit-address-family
sonic.PALCNETWORKS.COM(config-router)# do clear ip bgp * soft
Result:
Verify the BGP routing table
R3
Before adding weight:
sonic.PALCNETWORKS.COM(config)# do sh ip route
Codes: K - kernel route, C - connected, S - static, R - RIP,
O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
T - Table, v - VNC, V - VNC-Direct, A - Babel, F - PBR,
f - OpenFabric,
> - selected route, * - FIB route, q - queued, r - rejected, b - backup
t - trapped, o - offload failure
K>* 0.0.0.0/0 [0/0] via 172.26.1.1, eth0, 03:55:19
B>* 1.1.1.1/32 [20/0] via 30.1.1.1, Ethernet4, weight 1, 00:07:41
B>* 1.1.2.1/32 [20/0] via 30.1.1.1, Ethernet4, weight 1, 00:00:19
B>* 1.1.3.1/32 [20/0] via 30.1.1.1, Ethernet4, weight 1, 00:00:19
B>* 2.2.2.2/32 [20/0] via 20.1.1.1, Ethernet6, weight 1, 00:07:42
C>* 3.3.3.3/32 is directly connected, Loopback0, 02:10:32
C>* 10.0.0.96/31 is directly connected, Ethernet48, 01:25:13
C>* 10.0.0.98/31 is directly connected, Ethernet49, 01:25:13
C>* 10.0.0.100/31 is directly connected, Ethernet50, 01:25:13
C>* 10.0.0.102/31 is directly connected, Ethernet51, 01:25:13
B>* 10.1.1.0/24 [20/0] via 20.1.1.1, Ethernet6, weight 1, 00:07:42
C>* 20.1.1.0/24 is directly connected, Ethernet6, 02:10:46
C>* 30.1.1.0/24 is directly connected, Ethernet4, 01:02:58
C>* 172.26.1.0/24 is directly connected, eth0, 03:55:19
After adding weight:
sonic.PALCNETWORKS.COM(config)# do sh ip route
Codes: K - kernel route, C - connected, S - static, R - RIP,
O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
T - Table, v - VNC, V - VNC-Direct, A - Babel, F - PBR,
f - OpenFabric,
> - selected route, * - FIB route, q - queued, r - rejected, b - backup
t - trapped, o - offload failure
K>* 0.0.0.0/0 [0/0] via 172.26.1.1, eth0, 03:51:37
B>* 1.1.1.1/32 [20/0] via 30.1.1.1, Ethernet4, weight 1, 00:03:59
B>* 1.1.2.1/32 [20/0] via 20.1.1.1, Ethernet6, weight 1, 00:04:00
B>* 1.1.3.1/32 [20/0] via 20.1.1.1, Ethernet6, weight 1, 00:04:00
B>* 2.2.2.2/32 [20/0] via 20.1.1.1, Ethernet6, weight 1, 00:04:00
C>* 3.3.3.3/32 is directly connected, Loopback0, 02:06:50
C>* 10.0.0.96/31 is directly connected, Ethernet48, 01:21:31
C>* 10.0.0.98/31 is directly connected, Ethernet49, 01:21:31
C>* 10.0.0.100/31 is directly connected, Ethernet50, 01:21:31
C>* 10.0.0.102/31 is directly connected, Ethernet51, 01:21:31
B>* 10.1.1.0/24 [20/0] via 20.1.1.1, Ethernet6, weight 1, 00:04:00
C>* 20.1.1.0/24 is directly connected, Ethernet6, 02:07:04
C>* 30.1.1.0/24 is directly connected, Ethernet4, 00:59:16
C>* 172.26.1.0/24 is directly connected, eth0, 03:51:37
sonic.PALCNETWORKS.COM(config)# do sh ip bgp
BGP table version is 128, local router ID is 3.3.3.3, vrf id 0
Default local pref 100, local AS 300
Status codes: s suppressed, d damped, h history, * valid, > best, = multipath,
i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
Network Next Hop Metric LocPrf Weight Path
*> 1.1.1.1/32 30.1.1.1 0 0 100 i
* 20.1.1.1 0 200 100 i
* 1.1.2.1/32 30.1.1.1 0 0 100 i
*> 20.1.1.1 4000 200 100 i
* 1.1.3.1/32 30.1.1.1 0 0 100 i
*> 20.1.1.1 4000 200 100 i
* 2.2.2.2/32 30.1.1.1 0 100 200 i
*> 20.1.1.1 0 0 200 i
*> 3.3.3.3/32 0.0.0.0 0 32768 i
* 10.1.1.0/24 30.1.1.1 0 0 100 i
*> 20.1.1.1 0 0 200 i
* 20.1.1.0/24 30.1.1.1 0 100 200 i
* 20.1.1.1 0 0 200 i
*> 0.0.0.0 0 32768 i
* 30.1.1.0/24 30.1.1.1 0 0 100 i
* 20.1.1.1 0 200 100 i
*> 0.0.0.0 0 32768 i
Displayed 8 routes and 17 total paths
Local Preference
BGP attribute local preference is the second BGP attribute and it can be used to choose the exit path for an autonomous system. Local preference can be used to choose the outbound external BGP path. Not exchanged between external BGP routers. Local preference is a well-known and discretionary BGP attribute. Default value is 100. The path with the highest local preference is preferred.
Topology:
Procedure:
Note: Commands are to be executed in sudo and vtysh mode
Step 1: Configure ip address for interfaces and loopbacks
Step 2: Enter vtysh mode
Step 3: Configure BGP neighbor
R1
sonic.PALCNETWORKS.COM#configure terminal
sonic.PALCNETWORKS.COM(config)# router bgp 100
sonic.PALCNETWORKS.COM(config-router)# bgp router-id 1.1.1.1
sonic.PALCNETWORKS.COM(config-router)# no bgp ebgp-requires-policy
sonic.PALCNETWORKS.COM(config-router)# neighbor 10.1.1.2 remote-as 200
sonic.PALCNETWORKS.COM(config-router)# neighbor 30.1.1.2 remote-as 300
sonic.PALCNETWORKS.COM(config-router)# network 1.1.1.1/32
sonic.PALCNETWORKS.COM(config-router)# network 1.1.2.1/32
sonic.PALCNETWORKS.COM(config-router)# network 1.1.3.1/32
sonic.PALCNETWORKS.COM(config-router)# network 1.1.4.1/32
sonic.PALCNETWORKS.COM(config-router)# network 10.1.1.0/24
sonic.PALCNETWORKS.COM(config-router)# network 30.1.1.0/24
R2
sonic.PALCNETWORKS.COM# conf
sonic.PALCNETWORKS.COM(config)# router bgp 200
sonic.PALCNETWORKS.COM(config-router)# bgp router-id 2.2.2.2
sonic.PALCNETWORKS.COM(config-router)# no bgp ebgp-requires-policy
sonic.PALCNETWORKS.COM(config-router)# neighbor 10.1.1.1 remote-as 100
sonic.PALCNETWORKS.COM(config-router)# neighbor 20.1.1.2 remote-as 300
sonic.PALCNETWORKS.COM(config-router)# network 2.2.2.2/32
sonic.PALCNETWORKS.COM(config-router)# network 10.1.1.0/24
sonic.PALCNETWORKS.COM(config-router)# network 20.1.1.0/24
R3
sonic.PALCNETWORKS.COM# conf
sonic.PALCNETWORKS.COM(config)# router bgp 300
sonic.PALCNETWORKS.COM(config-router)# bgp router-id 3.3.3.3
sonic.PALCNETWORKS.COM(config-router)# no bgp ebgp-requires-policy
sonic.PALCNETWORKS.COM(config-router)# neighbor 30.1.1.1 remote-as 100
sonic.PALCNETWORKS.COM(config-router)# neighbor 20.1.1.1 remote-as 200
sonic.PALCNETWORKS.COM(config-router)# network 3.3.3.3/32
sonic.PALCNETWORKS.COM(config-router)# network 20.1.1.0/24
sonic.PALCNETWORKS.COM(config-router)# network 30.1.1.0/24
Step 4: Checking the BGP neighbors
R1
sonic.PALCNETWORKS.COM(config-router)# do sh bgp summary
IPv4 Unicast Summary (VRF default):
BGP router identifier 1.1.1.1, local AS number 100 vrf-id 0
BGP table version 9
RIB entries 17, using 3128 bytes of memory
Peers 2, using 1447 KiB of memory
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt Desc
10.1.1.2 4 200 9 8 0 0 0 00:01:30 4 9 N/A
30.1.1.2 4 300 9 6 0 0 0 00:00:43 4 9 N/A
Total number of neighbors 2
R2
sonic.PALCNETWORKS.COM(config-router)# do sh bgp summary
IPv4 Unicast Summary (VRF default):
BGP router identifier 2.2.2.2, local AS number 200 vrf-id 0
BGP table version 10
RIB entries 17, using 3128 bytes of memory
Peers 2, using 1447 KiB of memory
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt Desc
10.1.1.1 4 100 8 9 0 0 0 00:01:25 7 9 N/A
20.1.1.2 4 300 9 6 0 0 0 00:00:33 8 9 N/A
Total number of neighbors 2
R3
sonic.PALCNETWORKS.COM(config-router)# do sh bgp summary
IPv4 Unicast Summary (VRF default):
BGP router identifier 3.3.3.3, local AS number 300 vrf-id 0
BGP table version 13
RIB entries 17, using 3128 bytes of memory
Peers 2, using 1447 KiB of memory
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt Desc
20.1.1.1 4 200 6 9 0 0 0 00:00:27 8 9 N/A
30.1.1.1 4 100 6 9 0 0 0 00:00:32 8 9 N/A
Total number of neighbors 2
Step 5: Apply local preference on R3 to choose best path for 1.1.2.1 and 1.1.3.1 routes via R1-R2-R3
R3
sonic.PALCNETWORKS.COM(config-router)# exit
sonic.PALCNETWORKS.COM(config)# ip prefix-list 12 permit 1.1.2.1/32
sonic.PALCNETWORKS.COM(config)# ip prefix-list 12 permit 1.1.3.1/32
sonic.PALCNETWORKS.COM(config)# route-map bgp permit 10
sonic.PALCNETWORKS.COM(config-route-map)# match ip address prefix-list 12
sonic.PALCNETWORKS.COM(config-route-map)# set local-preference 400
sonic.PALCNETWORKS.COM(config-route-map)# exit
sonic.PALCNETWORKS.COM(config)# route-map bgp permit 20
sonic.PALCNETWORKS.COM(config-route-map)# exit
sonic.PALCNETWORKS.COM(config)#
Step 6: Configure route-map in BGP
R3
sonic.PALCNETWORKS.COM# conf
sonic.PALCNETWORKS.COM(config)# router bgp 300
sonic.PALCNETWORKS.COM(config-router)# address-family ipv4 unicast
sonic.PALCNETWORKS.COM(config-router-af)# neighbor 20.1.1.1 route-map bgp in
sonic.PALCNETWORKS.COM(config-router-af)# exit-address-family
sonic.PALCNETWORKS.COM(config-router)# do clear ip bgp * soft
Result:
Verify the BGP routing table
R3
Before adding local preference:
sonic.PALCNETWORKS.COM(config-router)# do sh ip bgp
BGP table version is 15, local router ID is 3.3.3.3, vrf id 0
Default local pref 100, local AS 300
Status codes: s suppressed, d damped, h history, * valid, > best, = multipath,
i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
Network Next Hop Metric LocPrf Weight Path
*> 1.1.1.1/32 30.1.1.1 0 0 100 i
* 20.1.1.1 0 200 100 i
*> 1.1.2.1/32 30.1.1.1 0 0 100 i
* 20.1.1.1 0 200 100 i
*> 1.1.3.1/32 30.1.1.1 0 0 100 i
* 20.1.1.1 0 200 100 i
*> 1.1.4.1/32 30.1.1.1 0 0 100 i
* 20.1.1.1 0 200 100 i
* 2.2.2.2/32 30.1.1.1 0 100 200 i
*> 20.1.1.1 0 0 200 i
*> 3.3.3.3/32 0.0.0.0 0 32768 i
* 10.1.1.0/24 30.1.1.1 0 0 100 i
0.0.0.0 0 32768 i
*> 20.1.1.1 0 0 200 i
* 20.1.1.0/24 30.1.1.1 0 100 200 i
*> 0.0.0.0 0 32768 i
* 20.1.1.1 0 0 200 i
*> 30.1.1.0/24 30.1.1.1 0 0 100 i
* 20.1.1.1 0 200 100 i
Displayed 9 routes and 19 total paths
sonic.PALCNETWORKS.COM(config-router)# do sh ip route bgp
Codes: K - kernel route, C - connected, S - static, R - RIP,
O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
T - Table, v - VNC, V - VNC-Direct, A - Babel, F - PBR,
f - OpenFabric,
> - selected route, * - FIB route, q - queued, r - rejected, b - backup
t - trapped, o - offload failure
B>* 1.1.1.1/32 [20/0] via 30.1.1.1, Ethernet4, weight 1, 00:01:33
B>* 1.1.2.1/32 [20/0] via 30.1.1.1, Ethernet4, weight 1, 00:01:33
B>* 1.1.3.1/32 [20/0] via 30.1.1.1, Ethernet4, weight 1, 00:01:33
B>* 1.1.4.1/32 [20/0] via 30.1.1.1, Ethernet4, weight 1, 00:01:33
B>* 2.2.2.2/32 [20/0] via 20.1.1.1, Ethernet6, weight 1, 00:03:03
B>* 10.1.1.0/24 [20/0] via 20.1.1.1, Ethernet6, weight 1, 00:03:03
B 30.1.1.0/24 [20/0] via 30.1.1.1 inactive, weight 1, 00:01:33
After adding local preference:
sonic.PALCNETWORKS.COM(config)# do sh ip bgp
BGP table version is 17, local router ID is 3.3.3.3, vrf id 0
Default local pref 100, local AS 300
Status codes: s suppressed, d damped, h history, * valid, > best, = multipath,
i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
Network Next Hop Metric LocPrf Weight Path
*> 1.1.1.1/32 30.1.1.1 0 0 100 i
* 20.1.1.1 0 200 100 i
* 1.1.2.1/32 30.1.1.1 0 0 100 i
*> 20.1.1.1 400 0 200 100 i
* 1.1.3.1/32 30.1.1.1 0 0 100 i
*> 20.1.1.1 400 0 200 100 i
*> 1.1.4.1/32 30.1.1.1 0 0 100 i
* 20.1.1.1 0 200 100 i
* 2.2.2.2/32 30.1.1.1 0 100 200 i
*> 20.1.1.1 0 0 200 i
*> 3.3.3.3/32 0.0.0.0 0 32768 i
* 10.1.1.0/24 30.1.1.1 0 0 100 i
0.0.0.0 0 32768 i
*> 20.1.1.1 0 0 200 i
* 20.1.1.0/24 30.1.1.1 0 100 200 i
*> 0.0.0.0 0 32768 i
* 20.1.1.1 0 0 200 i
*> 30.1.1.0/24 30.1.1.1 0 0 100 i
* 20.1.1.1 0 200 100 i
Displayed 9 routes and 19 total paths
sonic.PALCNETWORKS.COM(config)# do sh ip route bgp
Codes: K - kernel route, C - connected, S - static, R - RIP,
O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
T - Table, v - VNC, V - VNC-Direct, A - Babel, F - PBR,
f - OpenFabric,
> - selected route, * - FIB route, q - queued, r - rejected, b - backup
t - trapped, o - offload failure
B>* 1.1.1.1/32 [20/0] via 30.1.1.1, Ethernet4, weight 1, 00:05:37
B>* 1.1.2.1/32 [20/0] via 20.1.1.1, Ethernet6, weight 1, 00:00:48
B>* 1.1.3.1/32 [20/0] via 20.1.1.1, Ethernet6, weight 1, 00:00:48
B>* 1.1.4.1/32 [20/0] via 30.1.1.1, Ethernet4, weight 1, 00:05:37
B>* 2.2.2.2/32 [20/0] via 20.1.1.1, Ethernet6, weight 1, 00:07:07
B>* 10.1.1.0/24 [20/0] via 20.1.1.1, Ethernet6, weight 1, 00:07:07
B 30.1.1.0/24 [20/0] via 30.1.1.1 inactive, weight 1, 00:05:37
sonic.PALCNETWORKS.COM(config)# do sh ip bgp 1.1.2.1
BGP routing table entry for 1.1.2.1/32, version 17
Paths: (2 available, best #2, table default)
Advertised to non peer-group peers:
20.1.1.1 30.1.1.1
100
30.1.1.1 from 30.1.1.1 (1.1.1.1)
Origin IGP, metric 0, valid, external
Last update: Tue Dec 27 10:20:48 2022
200 100
20.1.1.1 from 20.1.1.1 (2.2.2.2)
Origin IGP, localpref 400, valid, external, best (Local Pref)
Last update: Tue Dec 27 10:20:48 2022
sonic.PALCNETWORKS.COM(config)# do sh ip bgp 1.1.3.1
BGP routing table entry for 1.1.3.1/32, version 16
Paths: (2 available, best #2, table default)
Advertised to non peer-group peers:
20.1.1.1 30.1.1.1
100
30.1.1.1 from 30.1.1.1 (1.1.1.1)
Origin IGP, metric 0, valid, external
Last update: Tue Dec 27 10:20:48 2022
200 100
20.1.1.1 from 20.1.1.1 (2.2.2.2)
Origin IGP, localpref 400, valid, external, best (Local Pref)
Last update: Tue Dec 27 10:20:48 2022
MED
Prefer the path with the lowest MED. The MED is exchanged between autonomous systems. MED can be used to advertise to your neighbors how they should enter your AS. MED is propagated to all routers within the neighbor AS but not passed along any other autonomous systems.
Topology:
Procedure:
Note: Commands are to be executed in sudo and vtysh mode
Step 1: Configure ip address for interfaces and loopbacks as per topology
Step 2: Enter vtysh mode
Step 3: Configure BGP neighbors
R1
sonic.PALCNETWORKS.COM(config)# router bgp 200
sonic.PALCNETWORKS.COM(config-router)# no bgp ebgp-requires-policy
sonic.PALCNETWORKS.COM(config-router)# neighbor 10.1.1.1 remote-as 200
sonic.PALCNETWORKS.COM(config-router)# neighbor 10.2.1.2 remote-as 100
sonic.PALCNETWORKS.COM(config-router)# bgp always-compare-med
sonic.PALCNETWORKS.COM(config-router)# address-family ipv4 unicast
sonic.PALCNETWORKS.COM(config-router-af)# network 192.168.1.1/32
R2
sonic.PALCNETWORKS.COM(config)# router bgp 100
sonic.PALCNETWORKS.COM(config-router)# no bgp ebgp-requires-policy
sonic.PALCNETWORKS.COM(config-router)# neighbor 10.3.1.1 remote-as 200
sonic.PALCNETWORKS.COM(config-router)# neighbor 10.2.1.1 remote-as 200
sonic.PALCNETWORKS.COM(config-router)# address-family ipv4 unicast
sonic.PALCNETWORKS.COM(config-router-af)# network 192.168.2.1/32
sonic.PALCNETWORKS.COM(config-router-af)# redistribute connected
R3
sonic.PALCNETWORKS.COM(config)# router bgp 200
sonic.PALCNETWORKS.COM(config-router)# no bgp ebgp-requires-policy
sonic.PALCNETWORKS.COM(config-router)# neighbor 10.3.1.2 remote-as 100
sonic.PALCNETWORKS.COM(config-router)# neighbor 10.4.1.1 remote-as 200
sonic.PALCNETWORKS.COM(config-router)# bgp always-compare-med
sonic.PALCNETWORKS.COM(config-router)# address-family ipv4 unicast
sonic.PALCNETWORKS.COM(config-router-af)# network 192.168.3.1/32
sonic.PALCNETWORKS.COM(config-router-af)# redistribute connected
R4
sonic.PALCNETWORKS.COM(config)# router bgp 200
sonic.PALCNETWORKS.COM(config-router)# no bgp ebgp-requires-policy
sonic.PALCNETWORKS.COM(config-router)# neighbor 10.1.1.2 remote-as 200
sonic.PALCNETWORKS.COM(config-router)# neighbor 10.4.1.2 remote-as 200
sonic.PALCNETWORKS.COM(config-router)# bgp always-compare-med
sonic.PALCNETWORKS.COM(config-router)# address-family ipv4 unicast
sonic.PALCNETWORKS.COM(config-router-af)# network 192.168.4.1/32
sonic.PALCNETWORKS.COM(config-router-af)# redistribute connected
Step 4: Checking the BGP neighbors
R1
sonic.PALCNETWORKS.COM(config)# do sh bgp summary
IPv4 Unicast Summary (VRF default):
BGP router identifier 192.168.1.1, local AS number 200 vrf-id 0
BGP table version 16
RIB entries 11, using 2024 bytes of memory
Peers 2, using 1447 KiB of memory
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt Desc
10.1.1.1 4 200 85 89 0 0 0 00:03:30 4 6 N/A
10.2.1.2 4 100 18 17 0 0 0 00:02:31 4 6 N/A
Total number of neighbors 2
R2
sonic.PALCNETWORKS.COM(config)# do sh bgp summary
IPv4 Unicast Summary (VRF default):
BGP router identifier 192.168.2.1, local AS number 100 vrf-id 0
BGP table version 14
RIB entries 11, using 2024 bytes of memory
Peers 2, using 1447 KiB of memory
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt Desc
10.3.1.1 4 200 72 75 0 0 0 01:03:22 5 6 N/A
10.2.1.1 4 200 7 8 0 0 0 00:00:18 5 6 N/A
Total number of neighbors 2
R3
sonic.PALCNETWORKS.COM# sh bgp summary
IPv4 Unicast Summary (VRF default):
BGP router identifier 192.168.3.1, local AS number 200 vrf-id 0
BGP table version 70
RIB entries 15, using 2760 bytes of memory
Peers 2, using 1447 KiB of memory
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt Desc
10.3.1.2 4 100 225 259 0 0 0 00:32:57 4 8 N/A
10.4.1.1 4 200 247 254 0 0 0 00:02:36 5 8 N/A
Total number of neighbors 2
R4
sonic.PALCNETWORKS.COM# sh bgp summary
IPv4 Unicast Summary (VRF default):
BGP router identifier 192.168.4.1, local AS number 200 vrf-id 0
BGP table version 60
RIB entries 15, using 2760 bytes of memory
Peers 2, using 1447 KiB of memory
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt Desc
10.1.1.2 4 200 251 224 0 0 0 00:33:42 6 8 N/A
10.4.1.2 4 200 293 268 0 0 0 00:03:22 4 8 N/A
Total number of neighbors 2
Step 5: Apply MED value on R2 to choose return traffic should come via lowest MED value.
R2
sonic.PALCNETWORKS.COM(config)# route-map bgp permit 10
sonic.PALCNETWORKS.COM (config)# set metric 200
sonic.PALCNETWORKS.COM (config)# exit
Step 6: Configure route-map in BGP
R2
sonic.PALCNETWORKS.COM (config)# router bgp 100
sonic.PALCNETWORKS.COM (config-router)# address-family ipv4 unicast
sonic.PALCNETWORKS.COM (config-router-af)# neighbor 10.2.1.1 route-map bgp out
sonic.PALCNETWORKS.COM(config-router-af)# do clear ip bgp * soft
Result:
Verify the BGP routes
R1
sonic.PALCNETWORKS.COM (config-router)# do show ip bgp ipv4 unicast
BGP table version is 117, local router ID is 192.168.1.1, vrf id 0
Default local pref 100, local AS 100
Status codes: s suppressed, d damped, h history, * valid, > best, = multipath,
i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
Network Next Hop Metric LocPrf Weight Path
* 10.1.0.1/32 10.2.1.1 200 0 200 i
*> 10.3.1.1 0 0 200 i
*> 10.1.1.0/24 10.2.1.1 0 0 200 i
* 10.2.1.0/24 10.2.1.1 0 0 200 ?
*> 0.0.0.0 0 32768 i
* 10.3.1.0/24 10.3.1.1 0 0 200 i
*> 0.0.0.0 0 32768 i
*> 10.4.1.0/24 10.3.1.1 0 0 200 i
* 192.168.2.1/32 10.2.1.1 200 0 200 i
*> 10.1.1.1 0 0 200 i
*> 192.168.1.1/32 0.0.0.0 0 32768 i
*> 192.168.3.1/32 10.1.1.1 0 0 200 i
* 10.2.1.2 200 0 200 i
*> 192.168.4.1/32 10.1.1.1 0 0 200 i
* 10.2.1.2 200 0 200 i
Displayed 9 routes and 15 total paths