Giáo trình thực hành BSCI Chương 6 - BGP
197
C
C
h
h
ư
ư
ơ
ơ
n
n
g
g
6
6
-
-
B
B
G
G
P
P
B
B
à
à
i
i
6
6
.
.
1
1
C
C
ấ
ấ
u
u
h
h
ì
ì
n
n
h
h
B
B
G
G
P
P
v
v
ớ
ớ
i
i
d
d
e
e
f
f
a
a
u
u
l
l
t
t
r
r
o
o
u
u
t
t
i
i
n
n
g
g
6
6
.
.
1
1
.
.
1
1
S
S
ơ
ơ
đ
đ
ồ
ồ
l
l
u
u
ậ
ậ
n
n
l
l
ý
ý
S0
S1
S0
S1
10.0.0.0/30
172.16.0.0/30
12.0.1.0/24
172.16.1.0/24
192.168.0.0/24
192
.
168.1.
0/
24
ISP1 ISP2
Router1
AS 200 AS 300
AS 100
Hình 6.1.1-1: Hình vẽ sơ đồ luận lý
6
6
.
.
1
1
.
.
2
2
M
M
ụ
ụ
c
c
t
t
i
i
ê
ê
u
u
c
c
ủ
ủ
a
a
b
b
à
à
i
i
t
t
h
h
ự
ự
c
c
h
h
à
à
n
n
h
h
Bài lab này cấu hình BGP trao đổi thong tin định tuyến với 2 ISP.
6
6
.
.
1
1
.
.
3
3
H
H
ư
ư
ớ
ớ
n
n
g
g
d
d
ẫ
ẫ
n
n
c
c
ấ
ấ
u
u
h
h
ì
ì
n
n
h
h
Bước 1: Cấu hình cơ bản cho Router1, ISP1, ISP2.
Router1
Router(config)#hostname Router1
Router1(config)#enable password cisco
Router1(config)#no ip domain-lookup
Giáo trình thực hành BSCI Chương 6 - BGP
198
Router1(config)#banner motd ^C Router1^C
Router1(config)#line console 0
Router1(config-line)# logging synchronous
Router1(config-line)# password cisco
Router1(config-line)# login
Router1(config)#line vty 0 4
Router1(config-line)# password cisco
Router1(config-line)# login
Router1(config)#interface Serial 1
Router1(config-if)#ip address 10.0.0.2 255.255.255.252
Router1(config-if)#no shutdown
Router1(config-if)#exit
Router1(config)#interface loopback 0
Router1(config-if)#ip address 192.168.0.1 255.255.255.0
Router1(config-if)#exit
Router1(config)#interface loopback 1
Router1(config-if)#ip address 192.168.1.1 255.255.255.0
Router1(config-if)#exit
ISP1
Router(config)#hostname ISP1
ISP1(config)#enable password cisco
ISP1(config)#no ip domain-lookup
ISP1(config)#banner motd ^C ISP1^C
ISP1(config)#line console 0
ISP1(config-line)# logging synchronous
ISP1(config-line)# password cisco
ISP1(config-line)# login
ISP1(config)#line vty 0 4
ISP1(config-line)# password cisco
ISP1(config-line)# login
IPS1(config)#interface Serial 0
IPS1(config-if)#ip address 10.0.0.1 255.255.255.252
IPS1(config-if)#clock rate 64000
IPS1(config-if)#no shutdown
IPS1(config)#int loopback 0
IPS1(config-if)#ip address 12.0.1.1 255.255.255.0
Giáo trình thực hành BSCI Chương 6 - BGP
199
IPS2
Router(config)#hostname ISP2
ISP2(config)#enable password cisco
ISP2(config)#no ip domain-lookup
ISP2(config)#banner motd ^C ISP2^C
ISP2(config)#line console 0
ISP2(config-line)# logging synchronous
ISP2(config-line)# password cisco
ISP2(config-line)# login
ISP2(config)#line vty 0 4
ISP2(config-line)# password cisco
ISP2(config-line)# login
ISP2(config)#interface serial 1
ISP2(config-if)#ip address 172.16.0.1 255.255.255.252
ISP2(config-if)#no shutdown
ISP2(config)#interface loopback 0
ISP2(config-if)#ip address 172.16.1.1 255.255.255.0
Bước 2 : Cấu hình BGP trên Router1, ISP1, ISP2.
Cấu hình BGP trên Router1
Router1(config)#router bgp 100
Router1(config-router)#neighbor 10.0.0.1 remote-as 200
Router1(config-router)#neighbor 172.16.0.1 remote-as 300
Router1(config-router)#network 192.168.0.0
Router1(config-router)#network 192.168.1.0
Router1(config-router)#exit
Cấu hình BGP trên ISP1
IPS1(config)#router bgp 200
IPS1(config-router)#neighbor 10.0.0.2 remote-as 100
IPS1(config-router)#network 12.0.1.0 mask 255.255.255.0
IPS1(config-router)#exit
Cấu hình BGP trên ISP2
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
IPS2(config-router)#exit
Bước 3: kiểm tra BGP.
Kiểm tra BGP trên Router1
Giáo trình thực hành BSCI Chương 6 - BGP
200
Router1#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
B 172.16.1.0/24 [20/0] via 172.16.0.1, 00:01:31
10.0.0.0/30 is subnetted, 1 subnets
C 10.0.0.0 is directly connected, Serial1
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:31
C 192.168.1.0/24 is directly connected, Loopback1
Router1#show ip bgp
BGP table version is 5, 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
Kiểm tra BGP trên ISP1
IPS1#show ip route
Gateway of last resort is not set
172.16.0.0/24 is subnetted, 1 subnets
B 172.16.1.0 [20/0] via 10.0.0.2, 00:03:07
10.0.0.0/30 is subnetted, 1 subnets
C 10.0.0.0 is directly connected, Serial0
B 192.168.0.0/24 [20/0] via 10.0.0.2, 00:03:36
12.0.0.0/24 is subnetted, 1 subnets
C 12.0.1.0 is directly connected, Loopback0
B 192.168.1.0/24 [20/0] via 10.0.0.2, 00:02:37
IPS1#show ip bgp
BGP table version is 5, local router ID is 10.0.0.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal
Origin codes: i - IGP, e - EGP, ? - incomplete
Giáo trình thực hành BSCI Chương 6 - BGP
201
Network Next Hop Metric LocPrf Weight Path
*> 12.0.1.0/24 0.0.0.0 0 32768 i
*> 172.16.1.0/24 10.0.0.2 0 100 300 i
*> 192.168.0.0 10.0.0.2 0 0 100 i
*> 192.168.1.0 10.0.0.2 0 0 100 i
Kiểm tra BGP trên ISP2
ISP2#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, Serial1
C 172.16.1.0/24 is directly connected, Loopback0
B 192.168.0.0/24 [20/0] via 172.16.0.2, 00:02:53
12.0.0.0/24 is subnetted, 1 subnets
B 12.0.1.0 [20/0] via 172.16.0.2, 00:02:53
B 192.168.1.0/24 [20/0] via 172.16.0.2, 00:02:00
ISP2#show ip bgp
BGP table version is 5, local router ID is 172.16.1.1
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
*> 12.0.1.0/24 172.16.0.2 0 100 200 i
*> 172.16.1.0/24 0.0.0.0 0 32768 i
*> 192.168.0.0 172.16.0.2 0 0 100 i
*> 192.168.1.0 172.16.0.2 0 0 100 i
Giáo trình thực hành BSCI Chương 6 - BGP
202
B
B
à
à
i
i
6
6
.
.
2
2
B
B
G
G
P
P
&
&
T
T
h
h
e
e
A
A
S
S
_
_
P
P
a
a
t
t
h
h
A
A
t
t
t
t
r
r
i
i
b
b
u
u
t
t
e
e
6
6
.
.
2
2
.
.
1
1
S
S
ơ
ơ
đ
đ
ồ
ồ
l
l
u
u
ậ
ậ
n
n
l
l
ý
ý
S0/3/1
S0/3/0
S0/3/1
S0/0/0
192.168.1.4/30
172.25.1.16/30
12.0.1.0/24
172.16.1.0/24
202.0.0.0/24
Router1 Router2
ISP
AS 100 AS 65000
AS 300
Hình 6.2.1-1: Hình vẽ sơ đồ luận lý
6
6
.
.
2
2
.
.
2
2
M
M
ụ
ụ
c
c
t
t
i
i
ê
ê
u
u
c
c
ù
ù
a
a
b
b
à
à
i
i
t
t
h
h
ự
ự
c
c
h
h
à
à
n
n
h
h
dùng AS_PATH Attribute to Filter Routes
6
6
.
.
2
2
.
.
3
3
H
H
ư
ư
ớ
ớ
n
n
g
g
d
d
ẫ
ẫ
n
n
c
c
ấ
ấ
u
u
h
h
ì
ì
n
n
h
h
v
v
à
à
h
h
ì
ì
n
n
h
h
v
v
ẽ
ẽ
m
m
i
i
n
n
h
h
h
h
ọ
ọ
a
a
Bước 1: Cấu hình cơ bản cho ISP, Router1, Router2
Router1
Router(config)#hostname Router1
Router1(config)#enable password cisco
Router1(config)#no ip domain-lookup
Router1(config)#banner motd ^C Router1^C
Router1(config)#line console 0
Router1(config-line)# logging synchronous
Router1(config-line)# password cisco
Giáo trình thực hành BSCI Chương 6 - BGP
203
Router1(config-line)# login
Router1(config)#line vty 0 4
Router1(config-line)# password cisco
Router1(config-line)# login
Router1(config)#interface serial 0/3/1
Router1(config-if)#ip address 192.168.1.5 255.255.255.252
Router1(config-if)#no shutdown
Router1(config)#interface loopback 0
Router1(config-if)#ip address 12.0.1.1 255.255.255.0
Router1(config-if)#exit
Router2
Router(config)#hostname Router2
Router2(config)#enable password cisco
Router2(config)#no ip domain-lookup
Router2(config)#banner motd ^C Router2^C
Router2(config)#line console 0
Router2(config-line)# logging synchronous
Router2(config-line)# password cisco
Router2(config-line)# login
Router2(config)#line vty 0 4
Router2(config-line)# password cisco
Router2(config-line)# login
Router2(config)#interface Serial 0/0/0
Router2(config-if)#ip address 172.24.1.17 255.255.255.252
Router2(config-if)#clock rate 64000
Router2(config-if)#no shutdown
Router2(config)#interface loopback 0
Router2(config-if)#ip address 172.16.1.1 255.255.255.0
ISP
Router(config)#hostname ISP1
ISP(config)#enable password cisco
ISP(config)#no ip domain-lookup
ISP(config)#banner motd ^C ISP1^C
ISP(config)#line console 0
ISP(config-line)# logging synchronous
ISP(config-line)# password cisco
ISP(config-line)# login
ISP(config)#line vty 0 4
Giáo trình thực hành BSCI Chương 6 - BGP
204
ISP(config-line)# password cisco
ISP(config-line)# login
IPS(config)#interface Serial 0/3/0
IPS(config-if)#ip address 192.168.1.6 255.255.255.252
IPS(config-if)#clock rate 64000
IPS(config-if)#no shutdown
IPS(config)#interface interface Serial 0/3/1
IPS(config-if)#ip address 172.25.1.18 255.255.255.252
IPS(config-if)#no shutdown
IPS(config)#int loopback 0
IPS(config-if)#ip address 202.0.0.1 255.255.255.0
Bước 2: Cấu hình BGP
Cấu hình BGP trên Router1
Router1(config)#router bgp 100
Router1(config-router)#neighbor 192.168.1.6 remote-as 300
Router1(config-router)#network 12.0.1.0 mask 255.255.255.0
Router1(config-router)#exit
Router1#show ip route
Gateway of last resort is not set
B 202.0.0.0/24 [20/0] via 192.168.1.6, 00:00:39
172.16.0.0/24 is subnetted, 1 subnets
B 172.16.1.0 [20/0] via 192.168.1.6, 00:00:39
12.0.0.0/24 is subnetted, 1 subnets
C 12.0.1.0 is directly connected, Loopback0
192.168.1.0/30 is subnetted, 1 subnets
C 192.168.1.4 is directly connected, Serial0/3/1
Cấu hình BGP trên Router2
Router2(config)#router bgp 65000
Router2(config-router)#neighbor 172.25.1.18 remote-as 300
Router2(config-router)#network 172.16.1.0 mask 255.255.255.0
Router2(config-router)#exit
Router2#show ip route
Gateway of last resort is not set
Giáo trình thực hành BSCI Chương 6 - BGP
205
B 202.0.0.0/24 [20/0] via 172.25.1.18, 00:01:55
172.16.0.0/24 is subnetted, 1 subnets
C 172.16.1.0 is directly connected, Loopback0
172.25.0.0/24 is subnetted, 1 subnets
C 172.25.1.0 is directly connected, Serial0/0/0
12.0.0.0/24 is subnetted, 1 subnets
B 12.0.1.0 [20/0] via 172.25.1.18, 00:01:24
Cấu hình BGP trên ISP
ISP(config)#router bgp 300
ISP(config-router)#neighbor 192.168.1.5 remote-as 100
ISP(config-router)#neighbor 172.26.1.17 remote-as 65000
ISP(config-router)#network 202.0.0.0 mask 255.255.255.0
ISP(config-router)#exit
ISP#show ip route
Gateway of last resort is 10.11.6.2 to network 0.0.0.0
C 202.0.0.0/24 is directly connected, Loopback0
172.16.0.0/24 is subnetted, 1 subnets
B 172.16.1.0 [20/0] via 172.25.1.17, 00:00:37
172.25.0.0/30 is subnetted, 1 subnets
C 172.25.1.16 is directly connected, Serial0/3/1
10.0.0.0/24 is subnetted, 1 subnets
C 10.11.6.0 is directly connected, GigabitEthernet0/0
12.0.0.0/24 is subnetted, 1 subnets
B 12.0.1.0 [20/0] via 192.168.1.5, 00:00:02
192.168.1.0/30 is subnetted, 1 subnets
C 192.168.1.4 is directly connected, Serial0/3/0
Bước 3: Remove the Private AS
ISP(config)#router bgp 300
ISP(config-router)#neighbor 192.168.1.5 remove-private-as
Giáo trình thực hành BSCI Chương 6 - BGP
206
Kiểm tra trên Router1
Hình 6.2.3-1: Show ip bgp trên Router1 để kiểm tra
Bước 4: dùng AS_PATH Attribute to Filter Routes
ISP(config)#ip as-path access-list 1 deny ^100$
ISP(config)#ip as-path access-list 1 permit .*
ISP(config)#router bgp 300
ISP(config-router)#neighbor 172.25.1.17 filter-list 1 out
Hình 6.2.3-2: Show ip route trên Router1
Hình 6.2.3-3: Show ip route trên Router2
Giáo trình thực hành BSCI Chương 6 - BGP
207
Hình 6.2.3-4: Show ip bgp regexp ^100$
Giáo trình thực hành BSCI Chương 6 - BGP
208
B
B
à
à
i
i
6
6
.
.
3
3
e
e
B
B
G
G
P
P
m
m
u
u
l
l
t
t
i
i
h
h
o
o
p
p
6
6
.
.
3
3
.
.
1
1
S
S
ơ
ơ
đ
đ
ồ
ồ
l
l
u
u
ậ
ậ
n
n
l
l
ý
ý
R1
R2
10.0.0.0/30
Lo0 : 2.2.2.2/32
Lo1 : 192.168.1.1/24
10.0.0.4/30
Fa0/0
Fa0/0
Fa0/1
Fa0/1
1.1.1.1/32
BGP AS 1
BGP AS 2
Hình 6.3.1-1: Sơ đồ luận lý
6
6
.
.
3
3
.
.
2
2
M
M
ụ
ụ
c
c
t
t
i
i
ê
ê
u
u
c
c
ủ
ủ
a
a
b
b
à
à
i
i
t
t
h
h
ự
ự
c
c
h
h
à
à
n
n
h
h
eBGP multihop có thể dùng loadshare traffic qua nhiều link eBGP
peers.
6
6
.
.
3
3
.
.
3
3
H
H
ư
ư
ớ
ớ
n
n
g
g
d
d
ẫ
ẫ
n
n
c
c
ấ
ấ
u
u
h
h
ì
ì
n
n
h
h
v
v
à
à
h
h
ì
ì
n
n
h
h
v
v
ẽ
ẽ
m
m
i
i
n
n
h
h
h
h
ọ
ọ
a
a
Bước 1: Cấu hình cơ bản R1, R2
R1
Router(config)#hostname R1
R1(config)#enable password cisco
R1(config)#no ip domain-lookup
R1(config)#banner motd ^C Router1^C
R1(config)#line console 0
R1(config-line)# logging synchronous
R1(config-line)# password cisco
R1(config-line)# login
R1(config)#line vty 0 4
R1(config-line)# password cisco
R1(config-line)# login
R1(config)# interface FastEthernet0/0
R1(config-if)#ip address 10.0.0.1 255.255.255.252
R1(config-if)#no shutdown
R1(config)# interface FastEthernet0/1
R1(config-if)#ip address 10.0.0.5 255.255.255.252
Giáo trình thực hành BSCI Chương 6 - BGP
209
R1(config-if)#no shutdown
R1(config)#interface loopback 0
R1(config-if)#ip address 1.1.1.1 255.255.255.255
R1(config-if)#exit
R2
Router(config)#hostname R2
R2(config)#enable password cisco
R2(config)#no ip domain-lookup
R2(config)#banner motd ^C Router2^C
R2(config)#line console 0
R2(config-line)# logging synchronous
R2(config-line)# password cisco
R2(config-line)# login
R2(config)#line vty 0 4
R2(config-line)# password cisco
R2(config-line)# login
R2(config)# interface FastEthernet0/0
R2(config-if)#ip address 10.0.0.2 255.255.255.252
R2(config-if)#no shutdown
R2(config)# interface FastEthernet0/0
R2(config-if)#ip address 10.0.0.6 255.255.255.252
R2(config-if)#no shutdown
R2(config)#interface loopback 0
R2(config-if)#ip address 2.2.2.2 255.255.255.0
R2(config)#interface loopback 1
R2(config-if)#ip address 192.168.1.1 255.255.255.0
Bước 2: Cấu hình eBGP multihop trên R1, R2
Cấu hình eBGP multihop trên Router1
R1(config)#router bgp 1
R1(config-router)# neighbor 2.2.2.2 remote-as 2
R1(config-router)# neighbor 2.2.2.2 ebgp-multihop 2
R1(config-router)# neighbor 2.2.2.2 update-source Loopback0
R1(config-router)#exit
R1(config)#ip route 2.2.2.2 255.255.255.255 10.0.0.2
R1(config)#ip route 2.2.2.2 255.255.255.255 10.0.0.6
Cấu hình eBGP multihop trên Router2
R2(config)#router bgp 2
Giáo trình thực hành BSCI Chương 6 - BGP
210
R2(config-router)#network 192.168.1.0
R2(config-router)# neighbor 1.1.1.1 remote-as 1
R2(config-router)# neighbor 1.1.1.1 ebgp-multihop 2
R2(config-router)#neighbor 1.1.1.1 update-source Loopback0
R2(config-router)#exit
R2(config)#ip route 1.1.1.1 255.255.255.255 10.0.0.1
R2(config)#ip route 1.1.1.1 255.255.255.255 10.0.0.5
Bước 3: Kiểm tra cấu hình
Hình 6.3.3-1: Show ip route trên R1
Hình 6.3.3-2: Show ip cef 192.168.1.0
Giáo trình thực hành BSCI Chương 6 - BGP
211
B
B
à
à
i
i
6
6
.
.
4
4
C
C
ấ
ấ
u
u
h
h
ì
ì
n
n
h
h
I
I
B
B
G
G
P
P
v
v
à
à
E
E
B
B
G
G
P
P
,
,
L
L
o
o
c
c
a
a
l
l
P
P
r
r
e
e
f
f
e
e
r
r
e
e
n
n
c
c
e
e
v
v
à
à
M
M
E
E
D
D
(
(
M
M
u
u
l
l
t
t
i
i
-
-
E
E
x
x
i
i
t
t
D
D
i
i
s
s
c
c
r
r
i
i
m
m
i
i
n
n
a
a
t
t
o
o
r
r
)
)
6
6
.
.
4
4
.
.
1
1
S
S
ơ
ơ
đ
đ
ồ
ồ
l
l
u
u
ậ
ậ
n
n
l
l
ý
ý
S0/3/0
S0/3/1
S0/3/0
S0/0/1
192.168.1.4/30
172.16.1.0/24
Lo0: 192.168.100.0/24
Lo0: 172.16.32.0/24
Lo0: 172.16.64.0/24
ISP R2
R1
AS 64512
EIGRP
192.168.1.0/30
S0/3/1
S0/0/0
iBGP
EBGP
EBGP
Hình 6.4.1-1: Hình vẽ sơ đồ luận lý
6
6
.
.
4
4
.
.
2
2
M
M
ụ
ụ
c
c
t
t
i
i
ê
ê
u
u
c
c
ủ
ủ
a
a
b
b
à
à
i
i
t
t
h
h
ự
ự
c
c
h
h
à
à
n
n
h
h
Cấu hình IBGP và EBGP, Local Preference và MED (Multi-Exit
Discriminator)
6
6
.
.
4
4
.
.
3
3
H
H
ư
ư
ớ
ớ
n
n
g
g
d
d
ẫ
ẫ
n
n
c
c
ấ
ấ
u
u
h
h
ì
ì
n
n
h
h
v
v
à
à
h
h
ì
ì
n
n
h
h
v
v
ẽ
ẽ
m
m
i
i
n
n
h
h
h
h
ọ
ọ
a
a
Bước 1: Cấu hình cơ bản trên Router1, Router2, ISP
Router1
Router(config)#hostname Router1
Router1(config)#enable password cisco
Router1(config)#no ip domain-lookup
Giáo trình thực hành BSCI Chương 6 - BGP
212
Router1(config)#banner motd ^C Router1^C
Router1(config)#line console 0
Router1(config-line)# logging synchronous
Router1(config-line)# password cisco
Router1(config-line)# login
Router1(config)#line vty 0 4
Router1(config-line)# password cisco
Router1(config-line)# login
Router1(config)#interface Serial 0/3/0
Router1(config-if)#ip address 172.16.1.1 255.255.255.0
Router1(config-if)#clock rate 64000
Router1(config-if)#no shutdown
Router1(config)#interface serial 0/3/1
Router1(config-if)#ip address 192.168.1.6 255.255.255.252
Router1(config-if)#no shutdown
Router1(config)#interface loopback 0
Router1(config-if)#ip address 172.16.64.1 255.255.255.0
Router1(config-if)#exit
Router2
Router(config)#hostname Router2
Router2(config)#enable password cisco
Router2(config)#no ip domain-lookup
Router2(config)#banner motd ^C Router2^C
Router2(config)#line console 0
Router2(config-line)# logging synchronous
Router2(config-line)# password cisco
Router2(config-line)# login
Router2(config)#line vty 0 4
Router2(config-line)# password cisco
Router2(config-line)# login
Router2(config)#interface Serial 0/0/0
Router2(config-if)#ip address 192.168.1.2 255.255.255.252
Router2(config-if)#clock rate 64000
Router2(config-if)#no shutdown
Router2(config)#interface Serial 0/0/1
Router2(config-if)#ip address 172.16.1.2 255.255.255.0
Router2(config-if)#no shutdown
Router2(config)#interface loopback 0
Giáo trình thực hành BSCI Chương 6 - BGP
213
Router2(config-if)#ip address 172.16.32.1 255.255.255.0
ISP
Router(config)#hostname ISP
ISP(config)#enable password cisco
ISP(config)#no ip domain-lookup
ISP(config)#banner motd ^C ISP^C
ISP(config)#line console 0
ISP(config-line)# logging synchronous
ISP(config-line)# password cisco
ISP(config-line)# login
ISP(config)#line vty 0 4
ISP(config-line)# password cisco
ISP(config-line)# login
IPS(config)#interface Serial 0/3/0
IPS(config-if)#ip address 192.168.1.5 255.255.255.252
IPS(config-if)#clock rate 64000
IPS(config-if)#no shutdown
IPS(config)#interface interface Serial 0/3/1
IPS(config-if)#ip address 192.168.1.1 255.255.255.252
IPS(config-if)#no shutdown
IPS(config)#int loopback 0
IPS(config-if)#ip address 192 168.100.1 255.255.255.0
Bước 2 : Cấu hình EIGRP trên Router1 và Router2
Cấu hình EIGRP trên Router1
Router1(config)#router eigrp 64512
Router1(config-router)#network 172.16.1.1 0.0.0.0
Router1(config-router)#network 172.16.64.1 0.0.0.0
Router1(config-router)#no auto-summary
Hình 6.4.3-1: Show ip eirgp neighbors trên Router1
Cấu hình EIGRP trên Router2
Router2(config)#router eigrp 64512
Router2(config-router)#network 172.16.1.2 0.0.0.0
Router2(config-router)#network 172.16.32.1 0.0.0.0
Router2(config-router)#no auto-summary
Giáo trình thực hành BSCI Chương 6 - BGP
214
Hình 6.4.3-2: Show ip eirgp neighbors trên Router1
Bước 3: Cấu hình iBGP trên Router1 và Router2
Cấu hình iBGP trên Router1
Router1(config)#router bgp 64512
Router1(config-router)#neighbor 172.16.32.1 remote-as 64512
Router1(config-router)#neighbor 172.16.32.1 update-source loopback 0
Router1(config-router)#end
Hình 6.4.3-3: Show ip bgp neighbors trên Router1
Cấu hình iBGP trên Router2
Router2(config)#router bgp 64512
Router2(config-router)#neighbor 172.16.64.1 remote-as 64512
Router2(config-router)#neighbor 172.16.64.1 update-source loopback 0
Router2(config-router)#end
Hình 6.4.3-4: Show ip bgp neighbors trên Router2
Bước 4: Cấu hình EBGP (ISP run EBGP với Router1 và Router2)
Cấu hình EBGP trên ISP
ISP(config)#router bgp 200
ISP(config-router)#neighbor 192.168.1.6 remote-as 64512
ISP(config-router)#neighbor 192.168.1.2 remote-as 64512
ISP(config-router)#network 192.168.100.0 mask 255.255.255.0
ISP(config-router)#network 192.168.1.4 mask 255.255.255.252
ISP(config-router)#network 192.168.1.0 mask 255.255.255.252
ISP(config-router)#end
Cấu hình EBGP trên Router1
Router1(config)#router bgp 64512
Router1(config-router)#neighbor 192.168.1.5 remote-as 200
Router1(config-router)#network 172.16.64.0 mask 255.255.255.0
Router1(config-router)#network 172.16.1.0 mask 255.255.255.0
Router1(config-router)#end
Giáo trình thực hành BSCI Chương 6 - BGP
215
Cấu hình EBGP trên Router2
Router2(config)#router bgp 64512
Router2(config-router)#neighbor 192.168.1.1 remote-as 200
Router2(config-router)#network 172.16.32.0 mask 255.255.255.0
Router2(config-router)#network 172.16.1.0 mask 255.255.255.0
Router2(config-router)#end
Bước 5: Kiểm tra BGP Neighbors
Hình 6.4.3-5: Show ip bgp neighbors trên ISP
Hình 6.4.3-6: Show ip bgp neighbors trên Router1
Hình 6.4.3-7: Show ip bgp neighbors trên Router2
Bước 6 Kiểm tra Which Path Traffic Takes
Hình 6.4.3-8: Show ip bgp trên ISP
Giáo trình thực hành BSCI Chương 6 - BGP
216
Hình 6.4.3-9: Show ip bgp trên Router1
Hình 6.4.3-10: Show ip bgp trên Router2
Bước 7: BGP Next-Hop-Self
Kiểm tra trước khi sử dụng Next-Hop-Seft
Hình 6.4.3-11: Show ip bgp Router1 trước khi dùng Next-Hop-Self
Giáo trình thực hành BSCI Chương 6 - BGP
217
Hình 6.4.3-12: Show ip route Router1 trước khi dùng Next-Hop-Self
Hình 6.4.3-13: Show ip bgp Router2 trước khi dùng Next-Hop-Self
Hình 6.4.3-14: Show ip route Router2 trước khi dùng Next-Hop-Self
Cấu hình Next-Hop-Self trên Router1
Router1(config)#router bgp 64512
Router1(config-router)#neighbor 172.16.32.1 next-hop-self
Cấu hình Next-Hop-Self trên Router2
Router2(config)#router bgp 64512
Giáo trình thực hành BSCI Chương 6 - BGP
218
Router2(config-router)#neighbor 172.16.64.1 next-hop-self
Kiểm tra sau khi sử dụng Next-Hop-Self
Hình 6.4.3-15: Show ip route Router1 sau khi dùng Next-Hop-Self
Hình 6.4.3-16: Show ip route Router2 sau khi dùng Next-Hop-Self
Bước 8: Set BGP Local Preference
Set BGP Local Preference trên Router1
Router1(config)#route-map PRIMARY_LocPrf_IN permit 10
Router1(config-route-map)#set local-preference 150
Router1(config-route-map)#exit
Router1(config)#router bgp 64512
Router1(config-router)#neighbor 192.168.1.5 route-map PRIMARY_ LocPrf_IN
in
Router1(config-router)#end
Router1#clear ip bgp * soft
Set BGP Local Preference trên Router2
Router2(config)#route-map SECONDARY_ LocPrf_IN permit 10
Router2(config-route-map)#set local-preference 125
Router2(config-route-map)#exit
Router2(config)#router bgp 64512
Giáo trình thực hành BSCI Chương 6 - BGP
219
Router2(config-router)#neighbor 192.168.1.1 route-map SECONDARY_
LocPrf_IN in
Router2(config-router)#end
Router2#clear ip bgp * soft
Kiểm tra kết quả sau khi set BGP Local Preference
Hình 6.4.3-17: Show ip bgp sau khi set BGP Local Preference trên Router1
Hình 6.4.3-18: Show ip bgp sau khi set BGP Local Preference trên Router2
Bước 9: Set BGP MED
Set BGP MED trên Router1
Router1(config)#route-map PRIMARY_MED_OUT permit 10
Router1(config-route-map)#set metric 50
Router1(config-route-map)#exit
Router1(config)#router bgp 64512
Router1(config-router)#neighbor 192.168.1.5 route-map
PRIMARY_MED_OUT out
Router1(config-router)#end
Router1#clear ip bgp * soft
Set BGP MED trên Router2
Router2(config)#route-map SECONDARY_MED_OUT permit 10
Router2(config-route-map)#set metric 100
Router2(config-route-map)#exit
Giáo trình thực hành BSCI Chương 6 - BGP
220
Router2(config)#router bgp 64512
Router2(config-router)#neighbor 192.168.1.1 route-map
SECONDARY_MED_OUT out
Router2(config-router)#end
Router2#clear ip bgp * soft
Kiểm tra kết quả sau khi set BGP MED
Hình 6.4.3-19: Show ip bgp trên ISP sau khi set BGP MED
Bước 10: Establish a Default Network
Router1(config)#ip default-network 192.168.100.0
Router1(config)#router bgp 64512
Router1(config-router)#neighbor 172.16.32.1 default-originate
Router1(config-router)#end
Kiểm tra cấu hình trên Router1 và Rout2
Hình 6.4.3-20: Show ip route trên Router1 sau khi có default network
Giáo trình thực hành BSCI Chương 6 - BGP
221
Hình 6.4.3-21: Show ip route tren Router2 sau khi có default network