21-路由策略典型配置舉例
本章節下載: 21-路由策略典型配置舉例 (197.79 KB)
資料版本:6W100-20190628
Copyright © 2019 bobty下载软件 版權所有,保留一切權利。
非經本公司書麵許可,任何單位和個人不得擅自摘抄、複製本文檔內容的部分或全部,並不得以任何形式傳播。
除bobty下载软件 的商標外,本手冊中出現的其它公司的商標、產品標識及商品名稱,由各自權利人擁有。
本文檔中的信息可能變動,恕不另行通知。
本文檔介紹路由策略配置舉例。
路由策略是為了改變網絡流量所經過的途徑而修改路由信息的技術,主要通過改變路由屬性(包括可達性)來實現。
本文檔不嚴格與具體軟、硬件版本對應,如果使用過程中與產品實際情況有差異,請參考相關產品手冊,或以設備實際情況為準。
本文檔中的配置均是在實驗室環境下進行的配置和驗證,配置前設備的所有參數均采用出廠時的缺省配置。如果您已經對設備進行了配置,為了保證配置效果,請確認現有配置和以下舉例中的配置不衝突。
本文檔假設您已了解路由策略特性。
如圖1所示,某公司的兩個部門相距較遠,Device A和Device F分別作為這兩個部門的出口設備,AS 100內部使用OSPF作為IGP。現要求:
· 通過部署BGP,使兩個部門可以通信;
· 通過配置路由策略,將Device B<->Device C<->Device D鏈路作為主鏈路,負責轉發Device A和Device F之間的流量;當主鏈路斷開時,自動切換到Device B<->Device E<->Device D這條路徑進行通信。
設備 |
接口 |
IP地址 |
設備 |
接口 |
IP地址 |
Device A |
Vlan-int100 |
120.1.0.1/24 |
Device D |
Vlan-int20 |
10.2.0.101/24 |
Device B |
Vlan-int10 |
10.1.0.101/24 |
|
Vlan-int40 |
13.1.1.101/24 |
|
Vlan-int30 |
192.168.0.101/24 |
|
Vlan-int100 |
120.2.0.2/24 |
|
Vlan-int100 |
120.1.0.2/24 |
Device E |
Vlan-int30 |
192.168.0.102/24 |
Device C |
Vlan-int10 |
10.1.0.102/24 |
|
Vlan-int40 |
13.1.1.102/24 |
|
Vlan-int20 |
10.2.0.102/24 |
Device F |
Vlan-int100 |
120.2.0.1/24 |
· 為了使Device B<->Device C<->Device D成為主鏈路,需要:
¡ 在Device B上配置路由策略來調整AS 100前往AS 200兩條路徑的本地優先級
- Device D-> Device C-> Device B的本地優先級為200;
- Device D-> Device E-> Device B的本地優先級為缺省值100;
¡ 在Device D上配置路由策略來調整AS 100前往AS 300兩條路徑的本地優先級
- Device B-> Device C-> Device D的本地優先級為200;
- Device B-> Device E-> Device D的本地優先級為缺省值100。
· 為了使AS 100內通信的報文使用BGP而不是OSPF選路,需要將IBGP路由優先級配置高於OSPF路由優先級。
本舉例是在S6890-CMW710-R2712版本上進行配置和驗證的。
缺省情況下,S6890係列交換機的接口處於ADM(Administratively Down)狀態,請根據實際需要在對應接口視圖下使用undo shutdown命令開啟接口。
# 配置Device A各接口的IP地址
<DeviceA> system-view
[DeviceA] interface vlan-interface100
[DeviceA-Vlan-interface100] ip address 120.1.0.1 24
[DeviceA-Vlan-interface100] quit
# 請參考以上方法配置其它相關接口的IP地址,配置步驟這裏省略。
<DeviceB> system-view
[DeviceB] ospf
[DeviceB-ospf-1] import-route direct
[DeviceB-ospf-1] area 0
[DeviceB-ospf-1-area-0.0.0.0] network 10.1.0.0 0.0.0.255
[DeviceB-ospf-1-area-0.0.0.0] network 192.168.0.0 0.0.0.255
[DeviceB-ospf-1-area-0.0.0.0] quit
[DeviceB-ospf-1] quit
<DeviceC> system-view
[DeviceC] ospf
[DeviceC-ospf-1] area 0
[DeviceC-ospf-1-area-0.0.0.0] network 10.1.0.0 0.0.0.255
[DeviceC-ospf-1-area-0.0.0.0] network 10.2.0.0 0.0.0.255
[DeviceC-ospf-1-area-0.0.0.0] quit
[DeviceC-ospf-1] quit
<DeviceD> system-view
[DeviceD] ospf
[DeviceD-ospf-1] import-route direct
[DeviceD-ospf-1] area 0
[DeviceD-ospf-1-area-0.0.0.0] network 10.2.0.0 0.0.0.255
[DeviceD-ospf-1-area-0.0.0.0] network 13.1.1.0 0.0.0.255
[DeviceD-ospf-1-area-0.0.0.0] quit
[DeviceD-ospf-1] quit
<DeviceE> system-view
[DeviceE] ospf
[DeviceE-ospf-1] area 0
[DeviceE-ospf-1-area-0.0.0.0] network 13.1.1.0 0.0.0.255
[DeviceE-ospf-1-area-0.0.0.0] network 192.168.0.0 0.0.0.255
[DeviceE-ospf-1-area-0.0.0.0] quit
[DeviceE-ospf-1] quit
# 啟動BGP,指定本地AS號為200,指定BGP路由器的Router ID為1.1.1.1。
[DeviceA] bgp 200
[DeviceA-bgp-default] router-id 1.1.1.1
# 配置Device A和Device B建立EBGP連接。
[DeviceA-bgp-default] peer 120.1.0.2 as-number 100
# 創建BGP IPv4單播地址族,並進入BGP IPv4單播地址族視圖。
[DeviceA-bgp-default] address-family ipv4 unicast
# 使能Device A與對等體120.1.0.2交換IPv4單播路由信息的能力。
[DeviceA-bgp-default-ipv4] peer 120.1.0.2 enable
# 在BGP IPv4單播地址族視圖下,將本地路由表中到達120.1.0.0/24網段的路由添加到BGP路由表中。
[DeviceA-bgp-default-ipv4] network 120.1.0.0 255.255.255.0
[DeviceA-bgp-default-ipv4] quit
# 啟動BGP,指定本地AS號為100,指定BGP路由器的Router ID為2.2.2.2。
[DeviceB] bgp 100
[DeviceB-bgp-default] router-id 2.2.2.2
# 配置Device B和Device A建立EBGP連接。
[DeviceB-bgp-default] peer 120.1.0.1 as-number 200
# 配置Device B和Device D建立IBGP連接。
[DeviceB-bgp-default] peer 10.2.0.101 as-number 100
[DeviceB-bgp-default] peer 13.1.1.101 as-number 100
# 創建BGP IPv4單播地址族,並進入BGP IPv4單播地址族視圖。
[DeviceB-bgp-default] address-family ipv4 unicast
# 使能Device B與對等體10.2.0.101交換IPv4單播路由信息的能力。
[DeviceB-bgp-default-ipv4] peer 10.2.0.101 enable
# 在BGP IPv4單播地址族視圖下,配置向對等體10.2.0.101發布BGP路由時,將下一跳屬性修改為自身的地址。
[DeviceB-bgp-default-ipv4] peer 10.2.0.101 next-hop-local
# 使能Device B與對等體13.1.1.101交換IPv4單播路由信息的能力。
[DeviceB-bgp-default-ipv4] peer 13.1.1.101 enable
# 在BGP IPv4單播地址族視圖下,配置向對等體13.1.1.101發布BGP路由時,將下一跳屬性修改為自身的地址。
[DeviceB-bgp-default-ipv4] peer 13.1.1.101 next-hop-local
# 使能Device B與對等體120.1.0.1交換IPv4單播路由信息的能力。
[DeviceB-bgp-default-ipv4] peer 120.1.0.1 enable
[DeviceB-bgp-default-ipv4] quit
# 啟動BGP,指定本地AS號為100,指定BGP路由器的Router ID為4.4.4.4。
[DeviceD] bgp 100
[DeviceD-bgp-default] router-id 4.4.4.4
# 配置Device D和Device B建立IBGP連接。
[DeviceD-bgp-default] peer 10.1.0.101 as-number 100
[DeviceD-bgp-default] peer 192.168.0.101 as-number 100
# 配置Device D和Device F建立EBGP連接。
[DeviceD-bgp-default] peer 120.2.0.1 as-number 300
# 創建BGP IPv4單播地址族,並進入BGP IPv4單播地址族視圖。
[DeviceD-bgp-default] address-family ipv4 unicast
# 使能Device D與對等體10.1.0.101交換IPv4單播路由信息的能力。
[DeviceD-bgp-default-ipv4] peer 10.1.0.101 enable
# 在BGP IPv4單播地址族視圖下,配置向對等體10.1.0.101發布BGP路由時,將下一跳屬性修改為自身的地址。
[DeviceD-bgp-default-ipv4] peer 10.1.0.101 next-hop-local
# 使能Device D與對等體192.168.0.101交換IPv4單播路由信息的能力。
[DeviceD-bgp-default-ipv4] peer 192.168.0.101 enable
# 在BGP IPv4單播地址族視圖下,配置向對等體192.168.0.101發布BGP路由時,將下一跳屬性修改為自身的地址。
[DeviceD-bgp-default-ipv4] peer 192.168.0.101 next-hop-local
# 使能Device D與對等體120.2.0.1交換IPv4單播路由信息的能力。
[DeviceD-bgp-default-ipv4] peer 120.2.0.1 enable
[DeviceD-bgp-default-ipv4] quit
#啟動BGP,指定本地AS號為300,指定BGP路由器的Router ID為6.6.6.6。
<DeviceF> system-view
[DeviceF] bgp 300
[DeviceF-bgp-default] router-id 6.6.6.6
# 配置Device F和Device D建立EBGP連接。
[DeviceF-bgp-default] peer 120.2.0.2 as-number 100
# 創建BGP IPv4單播地址族,並進入BGP IPv4單播地址族視圖。
[DeviceF-bgp-default] address-family ipv4 unicast
# 在BGP IPv4單播地址族視圖下,將本地路由表中到達120.2.0.0/24網段的路由添加到BGP路由表中。
[DeviceF-bgp-default-ipv4] network 120.2.0.0 255.255.255.0
# 使能Device F與對等體120.2.0.2交換IPv4單播路由信息的能力。
[DeviceF-bgp-default-ipv4] peer 120.2.0.2 enable
[DeviceF-bgp-default-ipv4] quit
# 完成以上配置後,在Device B上通過命令display bgp peer查看BGP對等體信息。
[DeviceB] display bgp peer ipv4
BGP local router ID: 2.2.2.2
Local AS number: 100
Total number of peers: 3 Peers in established state: 3
* - Dynamically created peer
Peer AS MsgRcvd MsgSent OutQ PrefRcv Up/Down State
10.2.0.101 100 6 4 0 1 00:00:56 Established
13.1.1.101 100 6 5 0 1 00:00:56 Established
120.1.0.1 200 6 5 0 1 00:00:56 Established
以上信息可以看到Device B與Device D建立IBGP連接,Device B與Device A建立EBGP連接,且均處於Established狀態。
# 完成以上配置後,從Device A上ping Device F的IP地址。
[DeviceA] ping 120.2.0.1
Ping 120.2.0.1 (120.2.0.1): 56 data bytes, press CTRL_C to break
56 bytes from 120.2.0.1: icmp_seq=0 ttl=252 time=1.189 ms
56 bytes from 120.2.0.1: icmp_seq=1 ttl=252 time=1.095 ms
56 bytes from 120.2.0.1: icmp_seq=2 ttl=252 time=1.086 ms
56 bytes from 120.2.0.1: icmp_seq=3 ttl=252 time=1.097 ms
56 bytes from 120.2.0.1: icmp_seq=4 ttl=252 time=1.089 ms
--- Ping statistics for 120.2.0.1 ---
5 packet(s) transmitted, 5 packet(s) received, 0.0% packet loss
round-trip min/avg/max/std-dev = 1.086/1.111/1.189/0.039 ms
以上顯示信息表明Device A和Device F之間路由可達。
# 創建ACL 2000,允許源IP地址為120.1.0.0/24的報文通過。
[DeviceB] acl basic 2000
[DeviceB-acl-ipv4-basic-2000] rule permit source 120.1.0.0 0.0.0.255
[DeviceB-acl-ipv4-basic-2000] quit
# 配置路由策略,將從對等體120.1.0.1學習到的路由發布給對等體10.2.0.101時,設置本地優先級為200。
[DeviceB] route-policy local-pre permit node 10
[DeviceB-route-policy-local-pre-10] if-match ip address acl 2000
[DeviceB-route-policy-local-pre-10] apply local-preference 200
[DeviceB-route-policy-local-pre-10] quit
[DeviceB] bgp 100
[DeviceB-bgp-default] address-family ipv4 unicast
[DeviceB-bgp-default-ipv4] peer 10.2.0.101 route-policy local-pre export
# 配置EBGP路由優先級為255,配置IBGP路由優先級為100,配置本地路由優先級為130,使IBGP路由優先級優於OSPF路由。
[DeviceB-bgp-default-ipv4] preference 255 100 130
[DeviceB-bgp-default-ipv4] quit
# 創建ACL 2000,允許源IP地址為120.2.0.0/24的報文通過。
[DeviceD] acl basic 2000
[DeviceD-acl-ipv4-basic-2000] rule permit source 120.2.0.0 0.0.0.255
[DeviceD-acl-ipv4-basic-2000] quit
# 配置路由策略,將從對等體120.2.0.1學習到的路由發布給對等體10.1.0.101時,設置本地優先級為200。
[DeviceD] route-policy local-pre permit node 10
[DeviceD-route-policy-local-pre-10] if-match ip address acl 2000
[DeviceD-route-policy-local-pre-10] apply local-preference 200
[DeviceD-route-policy-local-pre-10] quit
[DeviceD] bgp 100
[DeviceD-bgp-default] address-family ipv4 unicast
[DeviceD-bgp-default-ipv4] peer 10.1.0.101 route-policy local-pre export
#配置EBGP路由優先級為255,配置IBGP路由優先級為100,配置本地路由優先級為130,使IBGP路由優先級優於OSPF路由。
[DeviceD-bgp-default-ipv4] preference 255 100 130
[DeviceD-bgp-default-ipv4] quit
# 在Device B上使用display bgp routing-table ipv4命令查看BGP路由表,可以看到2條120.2.0.0/24的路由,本地路由優先級分別為100和200。
[DeviceB] display bgp routing-table ipv4
Total number of routes: 3
BGP local router ID is 2.2.2.2
Status codes: * - valid, > - best, d - dampened, h - history
s - suppressed, S - stale, i - internal, e – external
a - additional-path
Origin: i - IGP, e - EGP, ? - incomplete
Network NextHop MED LocPrf PrefVal Path/Ogn
* >e 120.1.0.0/24 120.1.0.1 0 0 200i
* >i 120.2.0.0/24 10.2.0.101 0 200 0 300i
* i 13.1.1.101 0 100 0 300i
# 在Device A上tracert Device F,查看到報文傳輸路徑是Device A-> Device B-> Device C-> Device D-> Device F
[DeviceA] tracert 120.2.0.1
traceroute to 120.2.0.1 (120.2.0.1), 30 hops at most, 52 bytes each packet, press CTRL_C to break
1 120.1.0.2 (120.1.0.2) 2.208 ms 1.119 ms 1.085 ms
2 10.1.0.102 (10.1.0.102) 1.083 ms 1.100 ms 1.085 ms
3 10.2.0.101 (10.2.0.101) 2.364 ms 1.099 ms 1.086 ms
4 120.2.0.1 (120.2.0.1) 3.825 ms 3.693 ms 4.008 ms
# 主鏈路斷開後再查看Device B的BGP路由表,存在1條120.2.0.0/24的路由。
[DeviceB] display bgp routing-table ipv4
Total number of routes: 2
BGP local router ID is 2.2.2.2
Status codes: * - valid, > - best, d - dampened, h - history
s - suppressed, S - stale, i - internal, e – external
a - additional-path
Origin: i - IGP, e - EGP, ? - incomplete
Network NextHop MED LocPrf PrefVal Path/Ogn
* >e 120.1.0.0/24 120.1.0.1 0 0 200i
* >i 120.2.0.0/24 13.1.1.101 0 100 0 300i
# 再次在Device A上tracert Device F,查看到報文傳輸路徑是Device A-> Device B-> Device E-> Device D-> Device F
[DeviceA] tracert 120.2.0.1
traceroute to 120.2.0.1 (120.2.0.1), 30 hops at most, 52 bytes each packet, pres
s CTRL_C to break
1 120.1.0.2 (120.1.0.2) 2.308 ms 1.127 ms 1.091 ms
2 192.168.0.102 (192.168.0.102) 1.086 ms 1.102 ms 1.096 ms
3 13.1.1.101 (13.1.1.101) 2.451 ms 2.087 ms 1.092 ms
4 120.2.0.1 (120.2.0.1) 3.533 ms 3.818 ms 4.002 ms
以上信息表明主備鏈路切換成功。
· Device A:
#
vlan 100
#
interface Vlan-interface100
ip address 120.1.0.1 255.255.255.0
#
bgp 200
router-id 1.1.1.1
peer 120.1.0.2 as-number 100
#
address-family ipv4 unicast
network 120.1.0.0 255.255.255.0
peer 120.1.0.2 enable
#
· Device B:
#
ospf 1
import-route direct
area 0.0.0.0
network 10.1.0.0 0.0.0.255
network 192.168.0.0 0.0.0.255
#
vlan 10
#
vlan 30
#
vlan 100
#
interface Vlan-interface10
ip address 10.1.0.101 255.255.255.0
#
interface Vlan-interface30
ip address 192.168.0.101 255.255.255.0
#
interface Vlan-interface100
ip address 120.1.0.2 255.255.255.0
#
bgp 100
router-id 2.2.2.2
peer 10.2.0.101 as-number 100
peer 13.1.1.101 as-number 100
peer 120.1.0.1 as-number 200
#
address-family ipv4 unicast
preference 255 100 130
peer 10.2.0.101 enable
peer 10.2.0.101 next-hop-local
peer 10.2.0.101 route-policy local-pre export
peer 13.1.1.101 enable
peer 13.1.1.101 next-hop-local
peer 120.1.0.1 enable
#
route-policy local-pre permit node 10
if-match ip address acl 2000
apply local-preference 200
#
acl number 2000
rule 0 permit source 120.1.0.0 0.0.0.255
#
· Device C:
#
ospf 1
area 0.0.0.0
network 10.1.0.0 0.0.0.255
network 10.2.0.0 0.0.0.255
#
vlan 10
#
vlan 20
#
interface Vlan-interface10
ip address 10.1.0.102 255.255.255.0
#
interface Vlan-interface20
ip address 10.2.0.102 255.255.255.0
#
· Device D
#
ospf 1
import-route direct
area 0.0.0.0
network 10.2.0.0 0.0.0.255
network 13.1.1.0 0.0.0.255
#
vlan 20
#
vlan 40
#
vlan 100
#
interface Vlan-interface20
ip address 10.2.0.101 255.255.255.0
#
interface Vlan-interface40
ip address 13.1.1.101 255.255.255.0
#
interface Vlan-interface100
ip address 120.2.0.2 255.255.255.0
#
bgp 100
router-id 4.4.4.4
peer 10.1.0.101 as-number 100
peer 120.2.0.1 as-number 300
peer 192.168.0.101 as-number 100
#
address-family ipv4 unicast
preference 255 100 130
peer 10.1.0.101 enable
peer 10.1.0.101 next-hop-local
peer 10.1.0.101 route-policy local-pre export
peer 192.168.0.101 enable
peer 192.168.0.101 next-hop-local
peer 120.2.0.1 enable
#
route-policy local-pre permit node 10
if-match ip address acl 2000
apply local-preference 200
#
#
acl number 2000
rule 0 permit source 120.2.0.0 0.0.0.255
#
· Device E:
#
ospf 1
area 0.0.0.0
network 13.1.1.0 0.0.0.255
network 192.168.0.0 0.0.0.255
#
vlan 30
#
vlan 40
#
interface Vlan-interface30
ip address 192.168.0.102 255.255.255.0
#
interface Vlan-interface40
ip address 13.1.1.102 255.255.255.0
#
· Device F:
#
vlan 100
#
interface Vlan-interface100
ip address 120.2.0.1 255.255.255.0
#
bgp 300
router-id 6.6.6.6
peer 120.2.0.2 as-number 100
#
address-family ipv4 unicast
network 120.2.0.0 255.255.255.0
peer 120.2.0.2 enable
#
· H3C S6890係列交換機 三層技術-IP路由配置指導(R27xx)
· H3C S6890係列交換機 三層技術-IP路由命令參考(R27xx)
不同款型規格的資料略有差異, 詳細信息請向具體銷售和400谘詢。H3C保留在沒有任何通知或提示的情況下對資料內容進行修改的權利!