PDA

View Full Version : Hiệu chỉnh Route trong BGP dựa trên prefix



danghoangkhanh
29-05-2008, 07:19 PM
Hiệu chỉnh Route trong BGP


http://wimaxpro.org/Hinh_upload/hinh_forum/bgp_test.JPG


Mô tả:
Trong bài Lab này , chúng ta sử dụng các thuộc tính BGP để hiệu chỉnh đường đi của Router

Yêu cầu:
- Traffic giữa R2 & R3 truyền qua link FAST ETHERNET
- Traffic còn lại truyền trên đường SERIAL

Thực hiện:
1. Kết nối mạng theo sơ đồ trên. Cấu hình hostname, địa chỉ IP cho các cổng theo đúng sơ đồ. Chưa cấu hình giao thức định tuyến. Kiểm tra kết nối bằng lệnh Ping và show cdp neighbor.
2. Cấu hình định tuyến eBGP cho các Router:

R1(config)#router bgp 1
R1(config-router)# neighbor 192.168.12.2 remote-as 2
R1(config-router)# neighbor 192.168.21.2 remote-as 2
R1(config-router)# neighbor 192.168.31.3 remote-as 3
R1(config-router)# neighbor 192.168.13.3 remote-as 3
R1(config-router)# neighbor 192.168.14.4 remote-as 4


R2(config)#router bgp 2
R2(config-router)# neighbor 192.168.12.1 remote-as 1
R2(config-router)# neighbor 192.168.21.1 remote-as 1
R2(config-router)# network 2.2.2.0 mask 255.255.255.0


R3(config)#router bgp 3
R3(config-router)# neighbor 192.168.13.1 remote-as 1
R3(config-router)# neighbor 192.168.31.1 remote-as 1
R3(config-router)# network 3.3.3.0 mask 255.255.255.0



R4(config)#router bgp 4
R4(config-router)# neighbor 192.168.14.1 remote-as 1
R4(config-router)# network 4.4.4.0 mask 255.255.255.0


Dùng lệnh show ip route và show ip bgp để kiểm tra

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 route

Gateway of last resort is not set

C 192.168.12.0/24 is directly connected, Serial2/2
1.0.0.0/24 is subnetted, 1 subnets
C 1.1.1.0 is directly connected, Loopback0
C 192.168.13.0/24 is directly connected, Serial2/3
2.0.0.0/24 is subnetted, 1 subnets
B 2.2.2.0 [20/0] via 192.168.12.2, 00:32 :40
C 192.168.14.0/24 is directly connected, Serial2/4
C 192.168.31.0/24 is directly connected, FastEthernet1/1
3.0.0.0/24 is subnetted, 1 subnets
B 3.3.3.0 [20/0] via 192.168.13.3, 00:32 :40
4.0.0.0/24 is subnetted, 1 subnets
B 4.4.4.0 [20/0] via 192.168.14.4, 00:32 :40
C 192.168.21.0/24 is directly connected, FastEthernet1/0

3. Tạo Access-List .

R1(config)# ip access-list standard net2
R1(config-std-nacl)# permit 2.2.2.0 0.0.0.255
R1(config)# ip access-list standard net3
R1(config-std-nacl)# permit 3.3.3.0 0.0.0.255
R1(config)# ip access-list standard net4
R1(config-std-nacl)# permit 4.4.4.0 0.0.0.255

4. Trên R1 tạo route-map, ta gán giá trị MED tương ứng cho từng net. Giá trị MED càng nhỏ sẽ càng được ưu tiên.

R1(config)# route-map F_R3 permit 10
R1(config-route-map)# match ip address net2
R1(config-route-map)# set metric 150

R1(config)# route-map F_R3 permit 20
R1(config-route-map)# set metric 300

R1(config)# route-map F_R2 permit 10
R1(config-route-map)# match ip address net3
R1(config-route-map)# set metric 150

R1(config)# route-map F_R2 permit 20
R1(config-route-map)# set metric 300

R1(config)# route-map S_R2 permit 10
R1(config-route-map)# match ip address net4
R1(config-route-map)# set metric 150

R1(config)# route-map S_R2 permit 20
R1(config-route-map)# set metric 300

R1(config)# route-map S_R3 permit 10
R1(config-route-map)# match ip address net4
R1(config-route-map)# set metric 150

R1(config)# route-map S_R3 permit 20
R1(config-route-map)# set metric 300


5. Apply trên BGP cho từng neighbor tương ứng theo chiều out

R1(config)#router bgp 1
R1(config-router)#neighbor 192.168.12.2 route-map S_R2 out
R1(config-router)#neighbor 192.168.13.3 route-map S_R3 out
R1(config-router)#neighbor 192.168.21.2 route-map F_R2 out
R1(config-router)#neighbor 192.168.31.3 route-map F_R3 out


6. Sau đó dùng lệnh clear ip bgp * trên các router để khởi động lại các kết nối BGP.
Dùng lệnh show ip bgp trên R2 và R3 để kiểm tra

R2#sh ip bgp
BGP table version is 24, 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, ? - incomplete

Network Next Hop Metric LocPrf Weight Path
*> 2.2.2.0/24 0.0.0.0 0 32768 i

*> 3.3.3.0/24 192.168.21.1 150 0 1 3 i
* 192.168.12.1 300 0 1 3 i

* 4.4.4.0/24 192.168.21.1 300 0 1 4 i
*> 192.168.12.1 150 0 1 4 i


Ta thấy rằng lúc này trên R2 có 2 đường đi tới mạng 3.3.3.0/24 nhưng sẽ ưu tiên đi qua đường 192.168.21.1 – FAST ETHERNET ( có kí hiệu > tức best route)

Tương tự trên R2 cũng có 2 đường đi tới mạng 4.4.4.0/24 nhưng sẽ ưu tiên đi qua đường 192.168.12.1 – SERIAL ( có kí hiệu > tức best route)


Kiểm tra tương tự trên R3

R3#sh ip bgp
BGP table version is 16, local router ID is 3.3.3.3
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

Network Next Hop Metric LocPrf Weight Path
*> 2.2.2.0/24 192.168.31.1 150 0 1 2 i
* 192.168.13.1 300 0 1 2 i

*> 3.3.3.0/24 0.0.0.0 0 32768 i

* 4.4.4.0/24 192.168.31.1 300 0 1 4 i
*> 192.168.13.1 150 0 1 4 i

Gunz
30-05-2008, 02:19 PM
Anh show luôn trên R4 để xem lúc đi vào mạng 2.2.2.0/24 và 3.3.3.0/24 thì traffic có đi qua đường serial không.

danghoangkhanh
30-05-2008, 03:04 PM
Hi,


Traceroute từ R4 tới R2 thấy nó dùng đường serial để đi.


R4#traceroute
Protocol [ip]:
Target IP address: 2.2.2.2
Source address: 4.4.4.4
Numeric display [n]:
Timeout in seconds [3]:
Probe count [3]:
Minimum Time to Live [1]:
Maximum Time to Live [30]:
Port Number [33434]:
Loose, Strict, Record, Timestamp, Verbose[none]:
Type escape sequence to abort.
Tracing the route to 2.2.2.2

1 192.168.14.1 84 msec 64 msec 64 msec
2 192.168.12.2 124 msec 148 msec *


Tương tự từ R4 tới R3

R4#traceroute
Protocol [ip]:
Target IP address: 3.3.3.3
Source address: 4.4.4.4
Numeric display [n]:
Timeout in seconds [3]:
Probe count [3]:
Minimum Time to Live [1]:
Maximum Time to Live [30]:
Port Number [33434]:
Loose, Strict, Record, Timestamp, Verbose[none]:
Type escape sequence to abort.
Tracing the route to 3.3.3.3

1 192.168.14.1 84 msec 104 msec 104 msec
2 192.168.13.3 64 msec 140 msec *

nmhungvasc
30-05-2008, 04:11 PM
chào Danghoangkhanh

Minh dang doc phan bgp , thay kho hieu qua ?
Bai lab cua ban rat hay , Khanh có thể giải thích giúp mình các câu lệnh sau nhé :

3. Tạo Access-List .

R1(config)# ip access-list standard net2
R1(config-std-nacl)# permit 2.2.2.0 0.0.0.255
R1(config)# ip access-list standard net3
R1(config-std-nacl)# permit 3.3.3.0 0.0.0.255
R1(config)# ip access-list standard net4
R1(config-std-nacl)# permit 4.4.4.0 0.0.0.255
( Phần này ok rùi )

4. Trên R1 tạo route-map, ta gán giá trị MED tương ứng cho từng net. Giá trị MED càng nhỏ sẽ càng được ưu tiên.

R1(config)# route-map F_R3 permit 10
R1(config-route-map)# match ip address net2
R1(config-route-map)# set metric 150

R1(config)# route-map F_R3 permit 20
R1(config-route-map)# set metric 300

R1(config)# route-map F_R2 permit 10
R1(config-route-map)# match ip address net3
R1(config-route-map)# set metric 150

R1(config)# route-map F_R2 permit 20
R1(config-route-map)# set metric 300

R1(config)# route-map S_R2 permit 10
R1(config-route-map)# match ip address net4
R1(config-route-map)# set metric 150

R1(config)# route-map S_R2 permit 20
R1(config-route-map)# set metric 300

R1(config)# route-map S_R3 permit 10
R1(config-route-map)# match ip address net4
R1(config-route-map)# set metric 150

R1(config)# route-map S_R3 permit 20
R1(config-route-map)# set metric 300


5. Apply trên BGP cho từng neighbor tương ứng theo chiều out

R1(config)#router bgp 1
R1(config-router)#neighbor 192.168.12.2 route-map S_R2 out
R1(config-router)#neighbor 192.168.13.3 route-map S_R3 out
R1(config-router)#neighbor 192.168.21.2 route-map F_R2 out
R1(config-router)#neighbor 192.168.31.3 route-map F_R3 out

Cám ơn Khanh nhiều

danghoangkhanh
02-06-2008, 03:13 PM
chào Danghoangkhanh

Minh dang doc phan bgp , thay kho hieu qua ?
Bai lab cua ban rat hay , Khanh có thể giải thích giúp mình các câu lệnh sau nhé :

3. Tạo Access-List .

R1(config)# ip access-list standard net2
R1(config-std-nacl)# permit 2.2.2.0 0.0.0.255
R1(config)# ip access-list standard net3
R1(config-std-nacl)# permit 3.3.3.0 0.0.0.255
R1(config)# ip access-list standard net4
R1(config-std-nacl)# permit 4.4.4.0 0.0.0.255
( Phần này ok rùi )

4. Trên R1 tạo route-map, ta gán giá trị MED tương ứng cho từng net. Giá trị MED càng nhỏ sẽ càng được ưu tiên.

R1(config)# route-map F_R3 permit 10
R1(config-route-map)# match ip address net2
R1(config-route-map)# set metric 150

R1(config)# route-map F_R3 permit 20
R1(config-route-map)# set metric 300

R1(config)# route-map F_R2 permit 10
R1(config-route-map)# match ip address net3
R1(config-route-map)# set metric 150

R1(config)# route-map F_R2 permit 20
R1(config-route-map)# set metric 300

R1(config)# route-map S_R2 permit 10
R1(config-route-map)# match ip address net4
R1(config-route-map)# set metric 150

R1(config)# route-map S_R2 permit 20
R1(config-route-map)# set metric 300

R1(config)# route-map S_R3 permit 10
R1(config-route-map)# match ip address net4
R1(config-route-map)# set metric 150

R1(config)# route-map S_R3 permit 20
R1(config-route-map)# set metric 300


5. Apply trên BGP cho từng neighbor tương ứng theo chiều out

R1(config)#router bgp 1
R1(config-router)#neighbor 192.168.12.2 route-map S_R2 out
R1(config-router)#neighbor 192.168.13.3 route-map S_R3 out
R1(config-router)#neighbor 192.168.21.2 route-map F_R2 out
R1(config-router)#neighbor 192.168.31.3 route-map F_R3 out

Cám ơn Khanh nhiều

Khúc này là sử dụng route-map để map từng prefix và gán giá trị metric (MED) tương ứng rồi sau đó apply đối với từng neighbor. Đối với link nào ta muốn sử dụng cho prefix nào thì gán giá trị MED ưu tiên là 150, còn lại gán là 300.

Cách làm này ko hay lắm vì nếu trên R2 & R3 có nhiều prefix thì sẽ phải làm rất mệt. Theo lời anh minhnguyenfr nói nên dùng route-map trên AS thì sẽ hay hơn nhiều đó.

Gunz
02-06-2008, 04:26 PM
A cho e hỏi route-map trên AS là như thế nào vậy? Có gì khác so với route-map a làm ở trên?
Nếu được a cho e xin ví dụ hoặc tài liệu nói về route-map trên AS, cái này e không hiểu lắm ^ ^!
Cám ơn a nhìu nhìu ^ ^!

trainingit
02-06-2008, 05:38 PM
bạn xem phần : Controlling Routing Update (BGP) trong quyển

Cisco Press - CCNP Self-Study CCNP BSCI Exam Certification Guide Third Edition

http://www.orbitfiles.com/download/id2345147883