LAB 7-1: CƠ BẢN VỀ BGP
Mô tả
Trong bài thực hành này, chúng ta sẽ cấu hình BGP cơ bản để kết nối với hai ISP. Mục tiêu của bài lab là giúp ngườI thực hành hiểu các lệnh cơ bản của BGP, cách tạo các quan hệ neighbor trong BGP.
Công ty XYZ ở Sài Gòn là một công ty chuyên kinh doanh buôn bán qua mạng. Do yêu cầu về tính dự phòng, mạng của XYZ thuộc AS100 có kết nối đến hai ISP sử dụng BGP có dạng sơ đồ trên. Do đây là dạng multihoming, bắt buộc phảI dùng BGP.
Thực hiện
1. Kết nối các thiết bị theo sơ đồ như trên. Cấu hình hostname, địa chỉ IP các cổng serial, cổng loopback theo đúng sơ đồ. Chưa cấu hình giao thức định tuyến. Kiểm tra các kết nối trực tiếp bằng lệnh ping và show cdp neighbor. Chú ý lúc này ISP1 chưa thể ping được ISP2.
2. Cấu hình BGP ở cả router ISP1, ISP2 và SaiGon:
ISP1(config)#router bgp 200
ISP1(config-router)#neighbor 10.0.0.2 remote-as 100
ISP1(config-router)#network 12.0.1.0 mask 255.255.255.0
Trên router ISP2, ta cấu hình như sau:
ISP2(config)#router bgp 300
ISP2(config-router)#neighbor 172.16.0.2 remote-as 100
ISP2(config-router)#network 172.16.1.0 mask 255.255.255.0
Cấu hình router SaiGon3 chạy BGP với cả hai ISP:
SaiGon(config)#router bgp 100
SaiGon(config-router)#neighbor 10.0.0.1 remote-as 200
SaiGon(config-router)#neighbor 172.16.0.1 remote-as 300
SaiGon(config-router)#network 192.168.0.0
SaiGon(config-router)#network 192.168.1.0
Nếu bạn không chỉ ra giá trị netmask ở câu lệnh network thì router sẽ lấy giá trị mask mặc định theo lớp địa chỉ mà network đó thuộc về. Trong cấu hình BGP của router Saigon, các địa chỉ 192.168.1.0 và 192.168.0.0 là các địa chỉ lớp C nên giá trị netmask mặc định là 255.255.255.0.
Kiểm tra bảng route tại SaiGon:
SaiGon#show ip route
Gateway of last resort is not set
172.16.0.0/16 is variably subnetted, 2 subnets, 2 masks
C 172.16.0.0/30 is directly connected, Serial0/1
B 172.16.1.0/24 [20/0] via 172.16.0.1, 00:00:36
10.0.0.0/30 is subnetted, 1 subnets
C 10.0.0.0 is directly connected, Serial0/0
C 192.168.0.0/24 is directly connected, Loopback0
12.0.0.0/24 is subnetted, 1 subnets
B 12.0.1.0 [20/0] via 10.0.0.1, 00:00:41
C 192.168.1.0/24 is directly connected, Loopback1
Router SaiGon đã thiết lập các route đến các loopback cổng của các router ISP. Kiểm tra các kết nối này bằng lệnh ping, và kết quả phải ping thành công.
3. Dùng lệnh show ip bgp để kiểm tra nội dung bảng BGP của router Saigon:
SaiGon#show ip bgp
BGP table version is 17, local router ID is 192.168.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 12.0.1.0/24 10.0.0.1 0 0 200 i
*> 172.16.1.0/24 172.16.0.1 0 0 300 i
*> 192.168.0.0 0.0.0.0 0 32768 i
*> 192.168.1.0 0.0.0.0 0 32768 i
Table version có thể thay đổi tùy theo tình huống cụ thể. Ví dụ, ta shutdown cổng loopback 0 của ISP1 sau đó no shutdown trở lại, table version sẽ tăng lên 1 đơn vị so với trước đó.
4. Kiểm tra bảng định tuyến tại ISP2 bằng lệnh show ip route. ISP2 phải có network 12.0.1.0 trong bảng định tuyến này. Router SaiGon đã quảng bá các network của ISP1 cho ISP2. ISP2 sau đó đưa các network này vào bảng route của nó. Điều này là không mong muốn do Saigon có thể trở thành một transit AS, đưa các transit traffic. Ta sẽ cấu hình SaiGon sao cho nó chỉ quảng bá các network của SaiGon là 192.168.0.0/24 và 192.168.1.0/24 cho cả hai ISP. Trên SaiGon, ta cấu hình access-list:
SaiGon(config)#access-list 1 permit 192.168.0.0 0.0.1.255
Sau đó, sử dụng access list này như là một route filter, dùng từ khóa distribute-list trong lệnh BGP neighbor:
SaiGon(config)#router bgp 100
SaiGon(config-router)#neighbor 10.0.0.1 distribute-list 1 out
SaiGon(config-router)#neighbor 172.16.0.1 distribute-list 1 out
Sau khi cấu hình route filter, kiểm tra lại bảng route của ISP2, route đến network có thể vẫn còn trong đó.
Đánh lệnh clear ip bgp * và chờ vài giây để các router đạt đến trạng thái Establish. Sau đó kiểm tra bảng route của ISP2, các route đến network của ISP1 sẽ không xuất hiện trong bảng route của ISP2. Route đến network 172.16.1.0 của ISP2 cũng không xuất hiện trong bảng route của ISP1.
5. Bây giờ, ta đã có liên kết bằng BGP giữa SaiGon và hai ISP. Vấn đề tiếp theo là khai báo primary route và backup route. Để thực hiện điều này, có thể sử dụng floating static route hoặc khai báo trong BGP.
Sử dụng phương pháp dùng tuyến đường tĩnh , ta kiểm tra bảng định tuyến trên router SaiGon:
SaiGon#show ip route
Gateway of last resort is not set
172.16.0.0/16 is variably subnetted, 2 subnets, 2 masks
C 172.16.0.0/30 is directly connected, Serial0/1
B 172.16.1.0/24 [20/0] via 172.16.0.1, 00:00:36
10.0.0.0/30 is subnetted, 1 subnets
C 10.0.0.0 is directly connected, Serial0/0
C 192.168.0.0/24 is directly connected, Loopback0
12.0.0.0/24 is subnetted, 1 subnets
B 12.0.1.0 [20/0] via 10.0.0.1, 00:00:41
C 192.168.1.0/24 is directly connected, Loopback1
Chú ý rằng ta chưa xác định “Gateway of last resort”. Đây là một việc cần phải thực hiện do router SaiGon là một border router cho toàn bộ mạng của công ty. Giả sử ISP1 là primary provider và ISP2 là backup provider, ta cấu hình như sau:
SaiGon(config)#ip route 0.0.0.0 0.0.0.0 10.0.0.1 210
SaiGon(config)#ip route 0.0.0.0 0.0.0.0 172.16.0.1 220
Để kiểm tra default route đã được thực hiện, ta dùng show ip route trên router SaiGon:
SaiGon#show ip route
Gateway of last resort is 10.0.0.1 to network 0.0.0.0
172.16.0.0/16 is variably subnetted, 2 subnets, 2 masks
C 172.16.0.0/30 is directly connected, Serial0/1
B 172.16.1.0/24 [20/0] via 172.16.0.1, 00:01:28
10.0.0.0/30 is subnetted, 1 subnets
C 10.0.0.0 is directly connected, Serial0/0
C 192.168.0.0/24 is directly connected, Loopback0
12.0.0.0/24 is subnetted, 1 subnets
B 12.0.1.0 [20/0] via 10.0.0.1, 00:01:34
C 192.168.1.0/24 is directly connected, Loopback1
S* 0.0.0.0/0 [210/0] via 10.0.0.1
Để kiểm tra default route này, trước hết ta tạo một loopback interface trên ISP1:
ISP1(config)#interface loopback 100
ISP1(config-if)#ip add 210.210.210.1 255.255.255.0
Trên router SaiGon, dùng lệnh clear ip bgp 10.0.0.1 để thiết lập lại kết nối BGP với neighbor 10.0.0.1:
SaiGon#clear ip bgp 10.0.0.1
Sau một lúc, khi kết nối BGP với host 10.0.0.1 được thiết lập lại, kiểm tra bảng route của router SaiGon để chắc chắn rằng network 210.210.210.1/24 không xuất hiện trong đó:
SaiGon#show ip route
Gateway of last resort is 10.0.0.1 to network 0.0.0.0
172.16.0.0/16 is variably subnetted, 2 subnets, 2 masks
C 172.16.0.0/30 is directly connected, Serial0/1
B 172.16.1.0/24 [20/0] via 172.16.0.1, 00:04:00
10.0.0.0/30 is subnetted, 1 subnets
C 10.0.0.0 is directly connected, Serial0/0
C 192.168.0.0/24 is directly connected, Loopback0
12.0.0.0/24 is subnetted, 1 subnets
B 12.0.1.0 [20/0] via 10.0.0.1, 00:00:35
C 192.168.1.0/24 is directly connected, Loopback1
S* 0.0.0.0/0 [210/0] via 10.0.0.1
Dùng extend ping từ địa chỉ 192.168.1.1 của SaiGon đến địa chỉ 210.210.210.1:
SaiGon#ping
Protocol [ip]:
Target IP address: 210.210.210.1
Repeat count [5]:
Datagram size [100]:
Timeout in seconds [2]:
Extended commands [n]: y
Source address or interface: 192.168.1.1
Type of service [0]:
Set DF bit in IP header? [no]:
Validate reply data? [no]:
Data pattern [0xABCD]:
Loose, Strict, Record, Timestamp, Verbose[none]:
Sweep range of sizes [n]:
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 210.210.210.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 28/30/32 ms
Bước 7
Một phương pháp khác để giải quyết vấn đề default route của router SaiGon là dùng lệnh default-network thay vì sử dụng route 0.0.0.0/0
Trước hết, ta bỏ các floating static route trong bước trước:
SaiGon(config)#no ip route 0.0.0.0 0.0.0.0 10.0.0.1 210
SaiGon(config)#no ip route 0.0.0.0 0.0.0.0 172.16.0.1 220
Ta sẽ quảng bá network 210.210.210.0/24 trên router ISP1:
ISP1(config)#router bgp 200
ISP1(config-router)#network 210.210.210.0
ISP1(config-router)#^Z
ISP1#clear ip bgp 10.0.0.2
Router SaiGon bây giờ cần phải cấu hình bằng lệnh default-network để thiết lập “Gateway of last resort”:
SaiGon(config)#ip default-network 210.210.210.0
SaiGon#show ip route
Gateway of last resort is 10.0.0.1 to network 210.210.210.0
B* 210.210.210.0/24 [20/0] via 10.0.0.1, 00:00:21
172.16.0.0/16 is variably subnetted, 2 subnets, 2 masks
C 172.16.0.0/30 is directly connected, Serial0/1
B 172.16.1.0/24 [20/0] via 172.16.0.1, 00:07:20
10.0.0.0/30 is subnetted, 1 subnets
C 10.0.0.0 is directly connected, Serial0/0
C 192.168.0.0/24 is directly connected, Loopback0
12.0.0.0/24 is subnetted, 1 subnets
B 12.0.1.0 [20/0] via 10.0.0.1, 00:00:50
C 192.168.1.0/24 is directly connected, Loopback1
Ta đã cấu hình default route cho router SaiGon, để thiết lập kết nối dự phòng với ISP2, ta dùng tuyến đường tĩnh :
SaiGon(config)#ip route 0.0.0.0 0.0.0.0 172.16.0.1 220
Các route được học từ eBGP có AD bằng 20 sẽ được ưu tiên hơn các route có AD lớn hơn 20, như route vừa cấu hình trên với AD bằng 220. Route này có vai trò như một backup route khi không còn route đến network 210.210.210.0/24.
Kiểm tra lại bảng route của SaiGon, ta sẽ thấy hai default route xuất hiện, nhưng chỉ có route đến network 210.210.210/24 được chọn cho “Gateway of last resort”:
SaiGon#show ip route
Gateway of last resort is 10.0.0.1 to network 210.210.210.0
B* 210.210.210.0/24 [20/0] via 10.0.0.1, 00:00:52
172.16.0.0/16 is variably subnetted, 2 subnets, 2 masks
C 172.16.0.0/30 is directly connected, Serial0/1
B 172.16.1.0/24 [20/0] via 172.16.0.1, 00:07:51
10.0.0.0/30 is subnetted, 1 subnets
C 10.0.0.0 is directly connected, Serial0/0
C 192.168.0.0/24 is directly connected, Loopback0
12.0.0.0/24 is subnetted, 1 subnets
B 12.0.1.0 [20/0] via 10.0.0.1, 00:01:20
C 192.168.1.0/24 is directly connected, Loopback1
S* 0.0.0.0/0 [220/0] via 172.16.0.1
Khi reset liên kết BGP với router láng giềng 10.0.0.1, router SaiGon sẽ chọn network 0.0.0.0/0 cho default route. Khi liên kết BGP với router láng giềng 10.0.0.1 được thiết lập thành công, router SaiGon sẽ chọn network 210.210.210.0/24 cho default route.
SaiGon#clear ip bgp 10.0.0.1
SaiGon#show ip route
Gateway of last resort is 172.16.0.1 to network 0.0.0.0
172.16.0.0/16 is variably subnetted, 2 subnets, 2 masks
C 172.16.0.0/30 is directly connected, Serial0/1
B 172.16.1.0/24 [20/0] via 172.16.0.1, 00:08:10
10.0.0.0/30 is subnetted, 1 subnets
C 10.0.0.0 is directly connected, Serial0/0
C 192.168.0.0/24 is directly connected, Loopback0
C 192.168.1.0/24 is directly connected, Loopback1
S* 0.0.0.0/0 [220/0] via 172.16.0.1
Cấu hình
SaiGon#show running-config
Building configuration...
Current configuration:
!
version 11.3
service timestamps debug uptime
service timestamps log uptime
no service password-encryption
!
hostname SaiGon
!
ip subnet-zero
no ip domain-lookup
!
interface Loopback0
ip address 192.168.0.1 255.255.255.0
!
interface Loopback1
ip address 192.168.1.1 255.255.255.0
!
interface Serial0/0
ip address 10.0.0.2 255.255.255.252
no ip mroute-cache
no fair-queue
clockrate 64000
!
interface Serial0/1
ip address 172.16.0.2 255.255.255.252
!
router bgp 100
network 192.168.0.0
network 192.168.1.0
neighbor 10.0.0.1 remote-as 200
neighbor 10.0.0.1 distribute-list 1 out
neighbor 172.16.0.1 remote-as 300
neighbor 172.16.0.1 distribute-list 1 out
!
ip classless
ip default-network 210.210.210.0
ip route 0.0.0.0 0.0.0.0 172.16.0.1 220
!
access-list 1 permit 192.168.0.0 0.0.1.255
!
line con 0
logging synchronous
line aux 0
line vty 0 4
privilege level 15
no login
!
no scheduler allocate
end
ISP1#show running-config
Building configuration...
Current configuration:
!
version 12.0
service timestamps debug uptime
service timestamps log uptime
no service password-encryption
!
hostname ISP1
!
ip subnet-zero
no ip domain-lookup
!
interface Loopback0
ip address 12.0.1.1 255.255.255.0
no ip directed-broadcast
!
interface Loopback100
ip address 210.210.210.1 255.255.255.0
no ip directed-broadcast
!
interface Serial0
ip address 10.0.0.1 255.255.255.252
no ip directed-broadcast
no ip mroute-cache
no fair-queue
!
router bgp 200
network 12.0.1.0 mask 255.255.255.0
network 210.210.210.0
neighbor 10.0.0.2 remote-as 100
!
ip classless
no ip http server
!
line con 0
exec-timeout 0 0
logging synchronous
transport input none
line aux 0
line vty 0 4
privilege level 15
no login
!
end
ISP2#show running-config
Building configuration...
Current configuration:
!
version 12.1
service timestamps debug uptime
service timestamps log uptime
no service password-encryption
!
hostname ISP2
!
ip subnet-zero
no ip domain-lookup
!
interface Loopback0
ip address 172.16.1.1 255.255.255.0
!
interface Serial1
ip address 172.16.0.1 255.255.255.252
clockrate 64000
!
router bgp 300
network 172.16.1.0 mask 255.255.255.0
neighbor 172.16.0.2 remote-as 100
!
ip classless
no ip http server
!
line con 0
logging synchronous
transport input none
line aux 0
line vty 0 4
privilege level 15
no login
!
end
Mô tả
Trong bài thực hành này, chúng ta sẽ cấu hình BGP cơ bản để kết nối với hai ISP. Mục tiêu của bài lab là giúp ngườI thực hành hiểu các lệnh cơ bản của BGP, cách tạo các quan hệ neighbor trong BGP.
Công ty XYZ ở Sài Gòn là một công ty chuyên kinh doanh buôn bán qua mạng. Do yêu cầu về tính dự phòng, mạng của XYZ thuộc AS100 có kết nối đến hai ISP sử dụng BGP có dạng sơ đồ trên. Do đây là dạng multihoming, bắt buộc phảI dùng BGP.
Thực hiện
1. Kết nối các thiết bị theo sơ đồ như trên. Cấu hình hostname, địa chỉ IP các cổng serial, cổng loopback theo đúng sơ đồ. Chưa cấu hình giao thức định tuyến. Kiểm tra các kết nối trực tiếp bằng lệnh ping và show cdp neighbor. Chú ý lúc này ISP1 chưa thể ping được ISP2.
2. Cấu hình BGP ở cả router ISP1, ISP2 và SaiGon:
ISP1(config)#router bgp 200
ISP1(config-router)#neighbor 10.0.0.2 remote-as 100
ISP1(config-router)#network 12.0.1.0 mask 255.255.255.0
Trên router ISP2, ta cấu hình như sau:
ISP2(config)#router bgp 300
ISP2(config-router)#neighbor 172.16.0.2 remote-as 100
ISP2(config-router)#network 172.16.1.0 mask 255.255.255.0
Cấu hình router SaiGon3 chạy BGP với cả hai ISP:
SaiGon(config)#router bgp 100
SaiGon(config-router)#neighbor 10.0.0.1 remote-as 200
SaiGon(config-router)#neighbor 172.16.0.1 remote-as 300
SaiGon(config-router)#network 192.168.0.0
SaiGon(config-router)#network 192.168.1.0
Nếu bạn không chỉ ra giá trị netmask ở câu lệnh network thì router sẽ lấy giá trị mask mặc định theo lớp địa chỉ mà network đó thuộc về. Trong cấu hình BGP của router Saigon, các địa chỉ 192.168.1.0 và 192.168.0.0 là các địa chỉ lớp C nên giá trị netmask mặc định là 255.255.255.0.
Kiểm tra bảng route tại SaiGon:
SaiGon#show ip route
Gateway of last resort is not set
172.16.0.0/16 is variably subnetted, 2 subnets, 2 masks
C 172.16.0.0/30 is directly connected, Serial0/1
B 172.16.1.0/24 [20/0] via 172.16.0.1, 00:00:36
10.0.0.0/30 is subnetted, 1 subnets
C 10.0.0.0 is directly connected, Serial0/0
C 192.168.0.0/24 is directly connected, Loopback0
12.0.0.0/24 is subnetted, 1 subnets
B 12.0.1.0 [20/0] via 10.0.0.1, 00:00:41
C 192.168.1.0/24 is directly connected, Loopback1
Router SaiGon đã thiết lập các route đến các loopback cổng của các router ISP. Kiểm tra các kết nối này bằng lệnh ping, và kết quả phải ping thành công.
3. Dùng lệnh show ip bgp để kiểm tra nội dung bảng BGP của router Saigon:
SaiGon#show ip bgp
BGP table version is 17, local router ID is 192.168.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 12.0.1.0/24 10.0.0.1 0 0 200 i
*> 172.16.1.0/24 172.16.0.1 0 0 300 i
*> 192.168.0.0 0.0.0.0 0 32768 i
*> 192.168.1.0 0.0.0.0 0 32768 i
Table version có thể thay đổi tùy theo tình huống cụ thể. Ví dụ, ta shutdown cổng loopback 0 của ISP1 sau đó no shutdown trở lại, table version sẽ tăng lên 1 đơn vị so với trước đó.
4. Kiểm tra bảng định tuyến tại ISP2 bằng lệnh show ip route. ISP2 phải có network 12.0.1.0 trong bảng định tuyến này. Router SaiGon đã quảng bá các network của ISP1 cho ISP2. ISP2 sau đó đưa các network này vào bảng route của nó. Điều này là không mong muốn do Saigon có thể trở thành một transit AS, đưa các transit traffic. Ta sẽ cấu hình SaiGon sao cho nó chỉ quảng bá các network của SaiGon là 192.168.0.0/24 và 192.168.1.0/24 cho cả hai ISP. Trên SaiGon, ta cấu hình access-list:
SaiGon(config)#access-list 1 permit 192.168.0.0 0.0.1.255
Sau đó, sử dụng access list này như là một route filter, dùng từ khóa distribute-list trong lệnh BGP neighbor:
SaiGon(config)#router bgp 100
SaiGon(config-router)#neighbor 10.0.0.1 distribute-list 1 out
SaiGon(config-router)#neighbor 172.16.0.1 distribute-list 1 out
Sau khi cấu hình route filter, kiểm tra lại bảng route của ISP2, route đến network có thể vẫn còn trong đó.
Đánh lệnh clear ip bgp * và chờ vài giây để các router đạt đến trạng thái Establish. Sau đó kiểm tra bảng route của ISP2, các route đến network của ISP1 sẽ không xuất hiện trong bảng route của ISP2. Route đến network 172.16.1.0 của ISP2 cũng không xuất hiện trong bảng route của ISP1.
5. Bây giờ, ta đã có liên kết bằng BGP giữa SaiGon và hai ISP. Vấn đề tiếp theo là khai báo primary route và backup route. Để thực hiện điều này, có thể sử dụng floating static route hoặc khai báo trong BGP.
Sử dụng phương pháp dùng tuyến đường tĩnh , ta kiểm tra bảng định tuyến trên router SaiGon:
SaiGon#show ip route
Gateway of last resort is not set
172.16.0.0/16 is variably subnetted, 2 subnets, 2 masks
C 172.16.0.0/30 is directly connected, Serial0/1
B 172.16.1.0/24 [20/0] via 172.16.0.1, 00:00:36
10.0.0.0/30 is subnetted, 1 subnets
C 10.0.0.0 is directly connected, Serial0/0
C 192.168.0.0/24 is directly connected, Loopback0
12.0.0.0/24 is subnetted, 1 subnets
B 12.0.1.0 [20/0] via 10.0.0.1, 00:00:41
C 192.168.1.0/24 is directly connected, Loopback1
Chú ý rằng ta chưa xác định “Gateway of last resort”. Đây là một việc cần phải thực hiện do router SaiGon là một border router cho toàn bộ mạng của công ty. Giả sử ISP1 là primary provider và ISP2 là backup provider, ta cấu hình như sau:
SaiGon(config)#ip route 0.0.0.0 0.0.0.0 10.0.0.1 210
SaiGon(config)#ip route 0.0.0.0 0.0.0.0 172.16.0.1 220
Để kiểm tra default route đã được thực hiện, ta dùng show ip route trên router SaiGon:
SaiGon#show ip route
Gateway of last resort is 10.0.0.1 to network 0.0.0.0
172.16.0.0/16 is variably subnetted, 2 subnets, 2 masks
C 172.16.0.0/30 is directly connected, Serial0/1
B 172.16.1.0/24 [20/0] via 172.16.0.1, 00:01:28
10.0.0.0/30 is subnetted, 1 subnets
C 10.0.0.0 is directly connected, Serial0/0
C 192.168.0.0/24 is directly connected, Loopback0
12.0.0.0/24 is subnetted, 1 subnets
B 12.0.1.0 [20/0] via 10.0.0.1, 00:01:34
C 192.168.1.0/24 is directly connected, Loopback1
S* 0.0.0.0/0 [210/0] via 10.0.0.1
Để kiểm tra default route này, trước hết ta tạo một loopback interface trên ISP1:
ISP1(config)#interface loopback 100
ISP1(config-if)#ip add 210.210.210.1 255.255.255.0
Trên router SaiGon, dùng lệnh clear ip bgp 10.0.0.1 để thiết lập lại kết nối BGP với neighbor 10.0.0.1:
SaiGon#clear ip bgp 10.0.0.1
Sau một lúc, khi kết nối BGP với host 10.0.0.1 được thiết lập lại, kiểm tra bảng route của router SaiGon để chắc chắn rằng network 210.210.210.1/24 không xuất hiện trong đó:
SaiGon#show ip route
Gateway of last resort is 10.0.0.1 to network 0.0.0.0
172.16.0.0/16 is variably subnetted, 2 subnets, 2 masks
C 172.16.0.0/30 is directly connected, Serial0/1
B 172.16.1.0/24 [20/0] via 172.16.0.1, 00:04:00
10.0.0.0/30 is subnetted, 1 subnets
C 10.0.0.0 is directly connected, Serial0/0
C 192.168.0.0/24 is directly connected, Loopback0
12.0.0.0/24 is subnetted, 1 subnets
B 12.0.1.0 [20/0] via 10.0.0.1, 00:00:35
C 192.168.1.0/24 is directly connected, Loopback1
S* 0.0.0.0/0 [210/0] via 10.0.0.1
Dùng extend ping từ địa chỉ 192.168.1.1 của SaiGon đến địa chỉ 210.210.210.1:
SaiGon#ping
Protocol [ip]:
Target IP address: 210.210.210.1
Repeat count [5]:
Datagram size [100]:
Timeout in seconds [2]:
Extended commands [n]: y
Source address or interface: 192.168.1.1
Type of service [0]:
Set DF bit in IP header? [no]:
Validate reply data? [no]:
Data pattern [0xABCD]:
Loose, Strict, Record, Timestamp, Verbose[none]:
Sweep range of sizes [n]:
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 210.210.210.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 28/30/32 ms
Bước 7
Một phương pháp khác để giải quyết vấn đề default route của router SaiGon là dùng lệnh default-network thay vì sử dụng route 0.0.0.0/0
Trước hết, ta bỏ các floating static route trong bước trước:
SaiGon(config)#no ip route 0.0.0.0 0.0.0.0 10.0.0.1 210
SaiGon(config)#no ip route 0.0.0.0 0.0.0.0 172.16.0.1 220
Ta sẽ quảng bá network 210.210.210.0/24 trên router ISP1:
ISP1(config)#router bgp 200
ISP1(config-router)#network 210.210.210.0
ISP1(config-router)#^Z
ISP1#clear ip bgp 10.0.0.2
Router SaiGon bây giờ cần phải cấu hình bằng lệnh default-network để thiết lập “Gateway of last resort”:
SaiGon(config)#ip default-network 210.210.210.0
SaiGon#show ip route
Gateway of last resort is 10.0.0.1 to network 210.210.210.0
B* 210.210.210.0/24 [20/0] via 10.0.0.1, 00:00:21
172.16.0.0/16 is variably subnetted, 2 subnets, 2 masks
C 172.16.0.0/30 is directly connected, Serial0/1
B 172.16.1.0/24 [20/0] via 172.16.0.1, 00:07:20
10.0.0.0/30 is subnetted, 1 subnets
C 10.0.0.0 is directly connected, Serial0/0
C 192.168.0.0/24 is directly connected, Loopback0
12.0.0.0/24 is subnetted, 1 subnets
B 12.0.1.0 [20/0] via 10.0.0.1, 00:00:50
C 192.168.1.0/24 is directly connected, Loopback1
Ta đã cấu hình default route cho router SaiGon, để thiết lập kết nối dự phòng với ISP2, ta dùng tuyến đường tĩnh :
SaiGon(config)#ip route 0.0.0.0 0.0.0.0 172.16.0.1 220
Các route được học từ eBGP có AD bằng 20 sẽ được ưu tiên hơn các route có AD lớn hơn 20, như route vừa cấu hình trên với AD bằng 220. Route này có vai trò như một backup route khi không còn route đến network 210.210.210.0/24.
Kiểm tra lại bảng route của SaiGon, ta sẽ thấy hai default route xuất hiện, nhưng chỉ có route đến network 210.210.210/24 được chọn cho “Gateway of last resort”:
SaiGon#show ip route
Gateway of last resort is 10.0.0.1 to network 210.210.210.0
B* 210.210.210.0/24 [20/0] via 10.0.0.1, 00:00:52
172.16.0.0/16 is variably subnetted, 2 subnets, 2 masks
C 172.16.0.0/30 is directly connected, Serial0/1
B 172.16.1.0/24 [20/0] via 172.16.0.1, 00:07:51
10.0.0.0/30 is subnetted, 1 subnets
C 10.0.0.0 is directly connected, Serial0/0
C 192.168.0.0/24 is directly connected, Loopback0
12.0.0.0/24 is subnetted, 1 subnets
B 12.0.1.0 [20/0] via 10.0.0.1, 00:01:20
C 192.168.1.0/24 is directly connected, Loopback1
S* 0.0.0.0/0 [220/0] via 172.16.0.1
Khi reset liên kết BGP với router láng giềng 10.0.0.1, router SaiGon sẽ chọn network 0.0.0.0/0 cho default route. Khi liên kết BGP với router láng giềng 10.0.0.1 được thiết lập thành công, router SaiGon sẽ chọn network 210.210.210.0/24 cho default route.
SaiGon#clear ip bgp 10.0.0.1
SaiGon#show ip route
Gateway of last resort is 172.16.0.1 to network 0.0.0.0
172.16.0.0/16 is variably subnetted, 2 subnets, 2 masks
C 172.16.0.0/30 is directly connected, Serial0/1
B 172.16.1.0/24 [20/0] via 172.16.0.1, 00:08:10
10.0.0.0/30 is subnetted, 1 subnets
C 10.0.0.0 is directly connected, Serial0/0
C 192.168.0.0/24 is directly connected, Loopback0
C 192.168.1.0/24 is directly connected, Loopback1
S* 0.0.0.0/0 [220/0] via 172.16.0.1
Cấu hình
SaiGon#show running-config
Building configuration...
Current configuration:
!
version 11.3
service timestamps debug uptime
service timestamps log uptime
no service password-encryption
!
hostname SaiGon
!
ip subnet-zero
no ip domain-lookup
!
interface Loopback0
ip address 192.168.0.1 255.255.255.0
!
interface Loopback1
ip address 192.168.1.1 255.255.255.0
!
interface Serial0/0
ip address 10.0.0.2 255.255.255.252
no ip mroute-cache
no fair-queue
clockrate 64000
!
interface Serial0/1
ip address 172.16.0.2 255.255.255.252
!
router bgp 100
network 192.168.0.0
network 192.168.1.0
neighbor 10.0.0.1 remote-as 200
neighbor 10.0.0.1 distribute-list 1 out
neighbor 172.16.0.1 remote-as 300
neighbor 172.16.0.1 distribute-list 1 out
!
ip classless
ip default-network 210.210.210.0
ip route 0.0.0.0 0.0.0.0 172.16.0.1 220
!
access-list 1 permit 192.168.0.0 0.0.1.255
!
line con 0
logging synchronous
line aux 0
line vty 0 4
privilege level 15
no login
!
no scheduler allocate
end
ISP1#show running-config
Building configuration...
Current configuration:
!
version 12.0
service timestamps debug uptime
service timestamps log uptime
no service password-encryption
!
hostname ISP1
!
ip subnet-zero
no ip domain-lookup
!
interface Loopback0
ip address 12.0.1.1 255.255.255.0
no ip directed-broadcast
!
interface Loopback100
ip address 210.210.210.1 255.255.255.0
no ip directed-broadcast
!
interface Serial0
ip address 10.0.0.1 255.255.255.252
no ip directed-broadcast
no ip mroute-cache
no fair-queue
!
router bgp 200
network 12.0.1.0 mask 255.255.255.0
network 210.210.210.0
neighbor 10.0.0.2 remote-as 100
!
ip classless
no ip http server
!
line con 0
exec-timeout 0 0
logging synchronous
transport input none
line aux 0
line vty 0 4
privilege level 15
no login
!
end
ISP2#show running-config
Building configuration...
Current configuration:
!
version 12.1
service timestamps debug uptime
service timestamps log uptime
no service password-encryption
!
hostname ISP2
!
ip subnet-zero
no ip domain-lookup
!
interface Loopback0
ip address 172.16.1.1 255.255.255.0
!
interface Serial1
ip address 172.16.0.1 255.255.255.252
clockrate 64000
!
router bgp 300
network 172.16.1.0 mask 255.255.255.0
neighbor 172.16.0.2 remote-as 100
!
ip classless
no ip http server
!
line con 0
logging synchronous
transport input none
line aux 0
line vty 0 4
privilege level 15
no login
!
end
Comment