一、实验需求
CE1作为Hub,CE2和CE3作为sopoke,要求CE2和CE3之间的通信需要通过CE1。
二、实验拓扑
三、实验配置
步骤一(基础配置,略)
如图分配各设备的IP地址(CE1的两个子接口IP暂不配置),AS200设备间运行OSPF协议,并配置MPLS。
步骤二: 建立PE1和PE2之间的BGP邻居
对PE1:
[PE1]bgp 200
[PE1-bgp]undo default ipv4-unicast
[PE1-bgp]peer 4.4.4.4 as-number 200
[PE1-bgp]peer 4.4.4.4 connect-interface lo0
[PE1-bgp]ipv4-family vpnv4
[PE1-bgp-af-vpnv4]peer 4.4.4.4 enable
对PE2:
[PE2]bgp 200
[PE2-bgp]undo default ipv4-unicast
[PE2-bgp]peer 2.2.2.2 as-number 200
[PE2-bgp]peer 2.2.2.2 connect-interface lo0
[PE2-bgp]ipv4-family vpnv4
[PE2-bgp-af-vpnv4]peer 2.2.2.2 enable
效果验证:
PE1与PE2建立了BGP邻居:
步骤三:配置CE1和PE1的子接口进行对接
对CE1:
[CE1]int g0/0/0.10
[CE1-GigabitEthernet0/0/0.10]dot1q termination vid 10
[CE1-GigabitEthernet0/0/0.10]ip address 12.1.1.1 24
[CE1-GigabitEthernet0/0/0.10]arp broadcast enable
[CE1-GigabitEthernet0/0/0.10]int g0/0/0.20
[CE1-GigabitEthernet0/0/0.20]dot1q termination vid 20
[CE1-GigabitEthernet0/0/0.20]ip address 112.1.1.1 24
[CE1-GigabitEthernet0/0/0.20]arp broadcast enable
对PE1:
[PE1]int g0/0/0.10
[PE1-GigabitEthernet0/0/0.10]dot1q termination vid 10
[PE1-GigabitEthernet0/0/0.10]ip address 12.1.1.2 24
[PE1-GigabitEthernet0/0/0.10]arp broadcast enable
[PE1-GigabitEthernet0/0/0.10]int g0/0/0.20
[PE1-GigabitEthernet0/0/0.20]dot1q termination vid 20
[PE1-GigabitEthernet0/0/0.20]ip address 112.1.1.2 24
[PE1-GigabitEthernet0/0/0.20]arp broadcast enable
效果验证:
CE1和PE1可以互通
步骤四:按拓扑图规划RT值进行配置
对PE1,配置虚拟专用网实例in和and,并设置相应的RT、RD值:
[PE1]ip vpn-instance in
[PE1-vpn-instance-in-af-ipv4]route-distinguisher 1:1
[PE1-vpn-instance-in-af-ipv4]vpn-target 200:1 import-extcommunity
[PE1]ip vpn-inst out
[PE1-vpn-instance-out]ipv4-family
[PE1-vpn-instance-out-af-ipv4]route-distinguisher 1:2
[PE1-vpn-instance-out-af-ipv4]vpn-target 100:1 export-extcommunity
对PE2,分别配置实例CE2和CE3,并设置相应的RT、RD值:
[PE2]ip vpn-instance CE2
[PE2-vpn-instance-CE2]ipv4-family
[PE2-vpn-instance-CE2-af-ipv4]route-distinguisher 2:2
[PE2-vpn-instance-CE2-af-ipv4]vpn-target 200:1 export-extcommunity
[PE2-vpn-instance-CE2-af-ipv4]vpn-target 100:1 import-extcommunity
[PE2]ip vpn-instance CE3
[PE2-vpn-instance-CE3]ipv4-family
[PE2-vpn-instance-CE3-af-ipv4]route-distinguisher 2:3
[PE2-vpn-instance-CE3-af-ipv4]vpn-target 200:1 export-extcommunity
[PE2-vpn-instance-CE3-af-ipv4]vpn-target 100:1 import-extcommunity
步骤五:建立CE1和PE1的邻居
对CE1:
[CE1]bgp 100
[CE1-bgp]peer 12.1.1.2 as-number 200
[CE1-bgp]peer 112.1.1.2 as-number 200
[CE1-bgp]network 1.1.1.1 32
对PE1:
[PE1]int g0/0/0.10
[PE1-GigabitEthernet0/0/0.10]ip binding vpn-instance in
[PE1-GigabitEthernet0/0/0.10]ip address 12.1.1.2 24
[PE1-GigabitEthernet0/0/0.10]int g0/0/0.20
[PE1-GigabitEthernet0/0/0.20]ip binding vpn-instance out
[PE1-GigabitEthernet0/0/0.20]ip address 112.1.1.2 24
[PE1]bgp 200
[PE1-bgp]ipv4-family vpn-instance in
[PE1-bgp-in]peer 12.1.1.1 as-number 100
[PE1-bgp]ipv4-family vpn-instance out
[PE1-bgp-in]peer 112.1.1.1 as-number 100
效果验证:PE1的out和in实例均有了1.1.1.1的路由
步骤六:在PE1上解决因防环机制造成的路由丢弃
对PE1:
[PE1]bgp 200
[PE1-bgp]ipv4-family vpn-instance out
[PE1-bgp-out]peer 112.1.1.1 allow-as-loop
步骤七:配置PE2和CE2以及CE3之间的BGP邻居
对PE2
[PE2]int g0/0/1
[PE2-GigabitEthernet0/0/1]ip binding vpn-instance CE2
[PE2-GigabitEthernet0/0/1]ip address 45.1.1.4 24
[PE2-GigabitEthernet0/0/1]int g0/0/2
[PE2-GigabitEthernet0/0/2]ip binding vpn-instance CE3
[PE2-GigabitEthernet0/0/2]ip address 46.1.1.4 24
[PE2-GigabitEthernet0/0/2]qu
[PE2]bgp 200
[PE2-bgp]ipv4-family vpn-instance CE2
[PE2-bgp-CE2]peer 45.1.1.5 as-number 300
[PE2-bgp-CE2]qu
[PE2-bgp]ipv4-family vpn-instance CE3
[PE2-bgp-CE3]peer 46.1.1.6 as-number 400
对CE2
[CE2]bgp 300
[CE2-bgp]peer 45.1.1.4 as-number 200
[CE2-bgp]network 5.5.5.5 32
对CE3
[CE3]bgp 400
[CE3-bgp]peer 46.1.1.4 as-number 200
[CE3-bgp]network 6.6.6.6 32
四、实验效果
从CE3上 tracert CE2 发现经过了CE1,实验成功。