AS_path filter-list laborozás.
Topológia:
4.4.4.4-et fogjuk R3-on belehirdetni BGP-be, amelyet R2 iBGP-vel megtanul és továbbhirdeti eBGP peerjének, R1-nek.
Alap BGP konfigurációk:
!R1
interface Loopback0
ip address 1.1.1.1 255.255.255.0
!
interface FastEthernet0/0
ip address 10.0.12.1 255.255.255.0
duplex auto
speed auto
!
interface FastEthernet0/1
no ip address
shutdown
duplex auto
speed auto
!
router bgp 1
no synchronization
bgp log-neighbor-changes
neighbor 2.2.2.2 remote-as 23
neighbor 2.2.2.2 ebgp-multihop 3
neighbor 2.2.2.2 update-source Loopback0
no auto-summary!R2
interface Loopback0
ip address 2.2.2.2 255.255.255.0
!
interface FastEthernet0/0
ip address 10.0.12.2 255.255.255.0
duplex auto
speed auto
!
interface FastEthernet0/1
ip address 10.0.23.2 255.255.255.0
duplex auto
speed auto
!
router bgp 23
no synchronization
bgp log-neighbor-changes
neighbor 1.1.1.1 remote-as 1
neighbor 1.1.1.1 ebgp-multihop 3
neighbor 1.1.1.1 update-source Loopback0
neighbor 1.1.1.1 filter-list 1 out
neighbor 3.3.3.3 remote-as 23
neighbor 3.3.3.3 update-source Loopback0
no auto-summary
!R3
interface Loopback0
ip address 3.3.3.3 255.255.255.0
!
!
interface FastEthernet0/0
ip address 10.0.23.3 255.255.255.0
duplex auto
speed auto
!
interface FastEthernet0/1
no ip address
shutdown
duplex auto
speed auto
!
router bgp 23
no synchronization
bgp log-neighbor-changes
neighbor 2.2.2.2 remote-as 23
neighbor 2.2.2.2 update-source Loopback0
no auto-summary
A BGP nem fog összeállni, mivel nem definiáltuk még a statikus route-kat.
!R1
ip route 2.2.2.0 255.255.255.0 FastEthernet0/0
!R2
ip route 1.1.1.0 255.255.255.0 FastEthernet0/0
ip route 3.3.3.0 255.255.255.0 FastEthernet0/1!R3
ip route 2.2.2.0 255.255.255.0 FastEthernet0/0
Áll a BGP.
R2#sh ip bgp s
BGP router identifier 2.2.2.2, local AS number 23
BGP table version is 1, main routing table version 1Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
1.1.1.1 4 1 8 8 1 0 0 00:04:37 0
3.3.3.3 4 23 4 4 1 0 0 00:00:10 0
Következő lépésként hirdessük R3-n bele BGP-be a 4.4.4.0/24-et!
!R3
interface Loopback1
ip address 4.4.4.4 255.255.255.0
router bgp 23
network 4.4.4.0 mask 255.255.255.0
R1 látja a 4.4.4.0/24, de pingelni nem tudja.
R1#sh ip route
Codes: C – connected, S – static, R – RIP, M – mobile, B – BGP
D – EIGRP, EX – EIGRP external, O – OSPF, IA – OSPF inter area
N1 – OSPF NSSA external type 1, N2 – OSPF NSSA external type 2
E1 – OSPF external type 1, E2 – OSPF external type 2
i – IS-IS, su – IS-IS summary, L1 – IS-IS level-1, L2 – IS-IS level-2
ia – IS-IS inter area, * – candidate default, U – per-user static route
o – ODR, P – periodic downloaded static routeGateway of last resort is not set
1.0.0.0/24 is subnetted, 1 subnets
C 1.1.1.0 is directly connected, Loopback0
2.0.0.0/24 is subnetted, 1 subnets
S 2.2.2.0 is directly connected, FastEthernet0/0
4.0.0.0/24 is subnetted, 1 subnets
B 4.4.4.0 [20/0] via 2.2.2.2, 00:01:00
10.0.0.0/24 is subnetted, 1 subnets
C 10.0.12.0 is directly connected, FastEthernet0/0
R1#ping 4.4.4.4Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 4.4.4.4, timeout is 2 seconds:
…..
Success rate is 0 percent (0/5)
Miért? Mert a routing két irányú dolog. R1 elküldi az ICMP-t R2-nek, aki elküldi R3-nak. Tehát az oda irány jó. R3 viszont nem tudja, hogy merre küldje a csomagokat 1.1.1.1-nek. Az egyszerűség kedvéért definiáljunk egy default route-t R3-n, és nézzük, mi történik.
!R3
ip route 0.0.0.0 0.0.0.0 FastEthernet0/0
R1#ping 4.4.4.4
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 4.4.4.4, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 216/288/384 ms
R1#
Működik.
Próbáljuk meg kiszűrni R2-n, hogy a 4.4.4.0/24 NLRI-t ne hirdesse R1 felé. Ehhez as-path filter-list-et kell használnunk, regex-ekkel.
!R2
ip as-path access-list 1 deny ^$
ip as-path access-list 1 permit .*router bgp 23
!!! Lényegtelen részek törölve !!!
neighbor 1.1.1.1 filter-list 1 out
R1 látja még 4.4.4.0/24-t?
!!! Előtte !!!
R1#sh ip route bgp
4.0.0.0/24 is subnetted, 1 subnets
B 4.4.4.0 [20/0] via 2.2.2.2, 00:03:20
!!! Utána !!!R1#sh ip route bgp
R1#sh ip route bgp
R1#
R2-n az alábbi paranccsal le tudjuk ellenőrizni, hogy érvényes -e egy adott regex valamelyik NLRI-re:
R2#sh ip bgp regexp ^$
BGP table version is 2, local router ID is 2.2.2.2
Status codes: s suppressed, d damped, h history, * valid, > best, i – internal,
r RIB-failure, S Stale
Origin codes: i – IGP, e – EGP, ? – incompleteNetwork Next Hop Metric LocPrf Weight Path
*>i4.4.4.0/24 3.3.3.3 0 100 0 i
R2#
A ^$ egyébként az AS-en belült megtanult path-ra érvényes, a .* pedig minden másra (olyan, mint a prefix-listáknál a 0.0.0.0/0 le 32)
