實驗topo

實驗說明:設置RTA和RTB彼此為鄰居,測試使用network命令和redistribute命令進行路由宣告實驗
實驗配置
RTA
RTA# show running-config
Building configuration...
Current configuration:
!
frr version 7.1
frr defaults traditional
hostname 46d9117a0d94
log syslog informational
no ipv6 forwarding
hostname RTA
service integrated-vtysh-config
!
router bgp 65001
neighbor 10.1.1.2 remote-as external
!
line vty
!
end
RTA#
RTB
RTB# show running-config
Building configuration...
Current configuration:
!
frr version 7.1
frr defaults traditional
hostname 94f591948424
log syslog informational
no ipv6 forwarding
hostname RTB
service integrated-vtysh-config
!
router bgp 65002
neighbor 10.1.1.1 remote-as external
!
line vty
!
end
RTB#
查看鄰居
RTA# show bgp neighbors 10.1.1.2
BGP neighbor is 10.1.1.2, remote AS 65002, local AS 65001, external link
Hostname: 94f591948424
BGP version 4, remote router ID 172.17.0.3, local router ID 172.17.0.2
BGP state = Established, up for 00:01:19
Last read 00:00:19, Last write 00:00:19
Hold time is 180, keepalive interval is 60 seconds
可以看到鄰居已經正常建立。
使用NETWORK命令宣告路由
RTB# configure terminal
RTB(config)#
RTB(config)# interface lo
RTB(config-if)#
RTB(config-if)# ip address 6.6.6.6/24
RTB(config-if)# exit
RTB(config)# router bgp 65002
RTB(config-router)# address-family ipv4 unicast
RTB(config-router-af)# network 6.6.6.0/24
RTB# show ip bgp 6.6.6.0/24
BGP routing table entry for 6.6.6.0/24
Paths: (1 available, best #1, table default)
Advertised to non peer-group peers:
10.1.1.1
Local
0.0.0.0 from 0.0.0.0 (6.6.6.1)
Origin IGP, metric 0, weight 32768, valid, sourced, local, best
Last update: Tue Jan 14 12:36:09 2020
RTB#
RTB# 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, D - SHARP,
F - PBR, f - OpenFabric,
> - selected route, * - FIB route, q - queued route, r - rejected route
K>* 0.0.0.0/0 [0/0] via 172.17.0.1, eth0, 00:10:25
C>* 6.6.6.0/24 is directly connected, lo, 00:01:44
C>* 6.6.6.0/30 is directly connected, lo, 00:06:36
C>* 10.1.1.0/24 is directly connected, eth1, 00:10:24
C>* 172.17.0.0/16 is directly connected, eth0, 00:10:25
RTB#
從上面可以看出,在路由表中存在6.6.6.0/24的路由,所以使用network命令可以宣告6.6.6.0/24的路由,會將其發送給其它的鄰居。
RTA# show ip bgp
BGP table version is 3, local router ID is 172.17.0.2, vrf id 0
Default local pref 100, local AS 65001
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
Network Next Hop Metric LocPrf Weight Path
*> 6.6.6.0/24 10.1.1.2 0 0 65002 i
Displayed 1 routes and 1 total paths
RTA#
當路由不在路由表中時,使用network進行宣告
RTB(config-router)# address-family ipv4 unicast
RTB(config-router-af)# network 9.8.7.0/24
RTB(config-router-af)#
RTB# 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, D - SHARP,
F - PBR, f - OpenFabric,
> - selected route, * - FIB route, q - queued route, r - rejected route
K>* 0.0.0.0/0 [0/0] via 172.17.0.1, eth0, 14:53:14
C>* 10.1.1.0/24 is directly connected, eth1, 14:53:13
C>* 172.17.0.0/16 is directly connected, eth0, 14:53:14
RTB# show ip bgp
BGP table version is 9, local router ID is 6.6.6.1, vrf id 0
Default local pref 100, local AS 65002
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
Network Next Hop Metric LocPrf Weight Path
*> 9.8.7.0/24 0.0.0.0 0 32768 i
Displayed 1 routes and 1 total paths
RTB#
RTA# show ip bgp
BGP table version is 9, local router ID is 172.17.0.2, vrf id 0
Default local pref 100, local AS 65001
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
Network Next Hop Metric LocPrf Weight Path
*> 9.8.7.0/24 10.1.1.2 0 0 65002 i
Displayed 1 routes and 1 total paths
RTA# 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, D - SHARP,
F - PBR, f - OpenFabric,
> - selected route, * - FIB route, q - queued route, r - rejected route
B>* 9.8.7.0/24 [20/0] via 10.1.1.2, eth1, 00:02:44
RTA#
FRR不會檢查network發布的路由是否在路由表中,都會宣告給其它鄰居,不會安裝到路由表中。在RTA上ping9.8.7.1,能在RTB上抓到ping報文。這點與思科不一致。
RTA# ping 9.8.7.1
PING 9.8.7.1 (9.8.7.1): 56 data bytes
^C--- 9.8.7.1 ping statistics ---
3 packets transmitted, 0 packets received, 100% packet loss
RTA#
root@94f591948424:/# tcpdump -i eth1 -eennvv icmp -c 1
tcpdump: listening on eth1, link-type EN10MB (Ethernet), capture size 262144 bytes
12:50:23.578541 02:42:0a:01:01:01 > 02:42:0a:01:01:02, ethertype IPv4 (0x0800), length 98: (tos 0x0, ttl 64, id 13995, offset 0, flags [DF], proto ICMP (1), length 84)
10.1.1.1 > 9.8.7.1: ICMP echo request, id 73, seq 37, length 64
1 packet captured
1 packet received by filter
0 packets dropped by kernel
root@94f591948424:/#
使用redistribute導入路由進行宣告
重分發的意思是將路由表中的其它類型(除了自己)的路由導入到BGP協議中,其它類型可以是如下類型:
RTB# configure terminal
RTB(config)# router bgp 65002
RTB(config-router)# address-family ipv4 unicast
RTB(config-router-af)# redistribute
babel eigrp kernel openfabric rip static vnc
connected isis nhrp ospf sharp table vnc-direct
RTB(config-router-af)#
比如我們想要將路由表中的直連路由重分發到bgp,可以使用如下命令:
RTB(config-router)# address-family ipv4 unicast
RTB(config-router-af)# redistribute connected metric 10
我們在如下配置下觀察RTB和RTA的路由信息:
RTA
RTA# show running-config
Building configuration...
Current configuration:
!
frr version 7.1
frr defaults traditional
hostname 46d9117a0d94
log syslog informational
no ipv6 forwarding
hostname RTA
service integrated-vtysh-config
!
router bgp 65001
neighbor 10.1.1.2 remote-as external
!
line vty
!
end
RTA#
RTB
RTB# show running-config
Building configuration...
Current configuration:
!
frr version 7.1
frr defaults traditional
hostname 94f591948424
log syslog informational
no ipv6 forwarding
hostname RTB
service integrated-vtysh-config
!
interface lo
ip address 9.8.7.6/24
!
router bgp 65002
neighbor 10.1.1.1 remote-as external
!
address-family ipv4 unicast
redistribute connected metric 10
exit-address-family
!
line vty
!
end
RTB#
觀察RTB的路由表
RTB# 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, D - SHARP,
F - PBR, f - OpenFabric,
> - selected route, * - FIB route, q - queued route, r - rejected route
K>* 0.0.0.0/0 [0/0] via 172.17.0.1, eth0, 15:04:07
C>* 9.8.7.0/24 is directly connected, lo, 00:08:33
C>* 10.1.1.0/24 is directly connected, eth1, 15:04:06
C>* 172.17.0.0/16 is directly connected, eth0, 15:04:07
RTB# show ip bgp
BGP table version is 16, local router ID is 6.6.6.1, vrf id 0
Default local pref 100, local AS 65002
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
Network Next Hop Metric LocPrf Weight Path
*> 9.8.7.0/24 0.0.0.0 10 32768 ?
*> 10.1.1.0/24 0.0.0.0 10 32768 ?
*> 172.17.0.0/16 0.0.0.0 10 32768 ?
Displayed 3 routes and 3 total paths
RTB#
從上面的信息可以看出,redistribute connected命令將路由表中帶C標志的路由導入了bgp協議。
查看RTA的路由信息
RTA# 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, D - SHARP,
F - PBR, f - OpenFabric,
> - selected route, * - FIB route, q - queued route, r - rejected route
B>* 9.8.7.0/24 [20/10] via 10.1.1.2, eth1, 00:02:12
B 10.1.1.0/24 [20/10] via 10.1.1.2 inactive, 00:02:12
B 172.17.0.0/16 [20/10] via 10.1.1.2, eth1, 00:02:12
RTA# show ip bgp
BGP table version is 16, local router ID is 172.17.0.2, vrf id 0
Default local pref 100, local AS 65001
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
Network Next Hop Metric LocPrf Weight Path
*> 9.8.7.0/24 10.1.1.2 10 0 65002 ?
*> 10.1.1.0/24 10.1.1.2 10 0 65002 ?
*> 172.17.0.0/16 10.1.1.2 10 0 65002 ?
Displayed 3 routes and 3 total paths
RTA#
從上面的信息可以看出RTA收到了RTB發布的重分發路由。
總結
1.BGP發布路由有如下兩種方式:
- 使用network命令,可以發布任何路由,不管該路由是否在路由表中,這一點有思科有所不同。
- 使用redistribute命令,可以將其它類型的二路由導入BGP,然后進行發布,該方法粒度太粗,容易將不想要的路由引入BGP表中,需要借助過濾機制進行過濾。