R1:
interface GigabitEthernet0/0/0
ip address 12.1.1.1 255.255.255.0
interface LoopBack0
ip address 1.1.1.1 255.255.255.255
R2:
interface GigabitEthernet0/0/0
ip address 12.1.1.2 255.255.255.0
interface GigabitEthernet0/0/1
ip address 23.1.1.2 255.255.255.0
interface LoopBack0
ip address 2.2.2.2 255.255.255.255
R3:
interface GigabitEthernet0/0/0
ip address 23.1.1.3 255.255.255.0
interface LoopBack0
ip address 3.3.3.3 255.255.255.255
R4:
interface GigabitEthernet0/0/0
ip address 192.168.14.4 255.255.255.0
interface LoopBack0
ip address 172.16.1.1 255.255.255.0
R5:
interface GigabitEthernet0/0/0
ip address 192.168.15.5 255.255.255.0
interface LoopBack0
ip address 172.16.1.1 255.255.255.0
R6:
interface GigabitEthernet0/0/0
ip address 192.168.36.6 255.255.255.0
interface LoopBack0
ip address 172.16.2.1 255.255.255.0
R7:
interface GigabitEthernet0/0/0
ip address 192.168.37.7 255.255.255.0
interface LoopBack0
ip address 172.16.2.1 255.255.255.0
R1:
isis 1
is-level level-2
network-entity 49.0123.0000.0000.0001.00
interface GigabitEthernet0/0/0
isis enable 1
interface LoopBack0
isis enable 1
R2:
isis 1
is-level level-2
network-entity 49.0123.0000.0000.0002.00
interface GigabitEthernet0/0/0
isis enable 1
interface GigabitEthernet0/0/1
isis enable 1
interface LoopBack0
isis enable 1
R3:
isis 1
is-level level-2
network-entity 49.0123.0000.0000.0003.00
interface GigabitEthernet0/0/0
isis enable 1
interface LoopBack0
isis enable 1
R1:
bgp 100
router-id 1.1.1.1
undo default ipv4-unicast
peer 3.3.3.3 as-number 100
peer 3.3.3.3 connect-interface LoopBack0
ipv4-family v4
peer 3.3.3.3 enable
R3:
bgp 100
router-id 3.3.3.3
undo default ipv4-unicast
peer 1.1.1.1 as-number 100
peer 1.1.1.1 connect-interface LoopBack0
ipv4-family v4
peer 1.1.1.1 enable
#
[R1]dis bgp v4 all peer //注意此时查看v4邻居,而不是ipv4邻居。
R1:
mpls lsr-id 1.1.1.1
mpls
mpls ldp
interface GigabitEthernet0/0/0
mpls
mpls ldp
R2:
mpls lsr-id 2.2.2.2
mpls
mpls ldp
interface GigabitEthernet0/0/0
mpls
mpls ldp
interface GigabitEthernet0/0/1
mpls
mpls ldp
R3:
mpls lsr-id 3.3.3.3
mpls
mpls ldp
interface GigabitEthernet0/0/0
mpls
mpls ldp
#
[R2]dis mpls ldp peer //查看LDP邻居
R1:
ip -instance 4
ipv4-family
route-distinguisher 4:4
-target 4:6 export-extcommunity
-target 6:4 import-extcommunity
R3:
ip -instance 6
ipv4-family
route-distinguisher 6:6
-target 6:4 export-extcommunity
-target 4:6 import-extcommunity
#
3.1.2 R1将G0/0/1划入VRF4,IP地址192.168.14.1/24
R3将G0/0/1划入VRF6,IP地址192.168.36.3/24
R1:
interface GigabitEthernet0/0/1
ip binding -instance 4
ip address 192.168.14.1 255.255.255.0
R3:
interface GigabitEthernet0/0/1
ip binding -instance 6
ip address 192.168.36.3 255.255.255.0
R1:
bgp 100
ipv4-family -instance 4
peer 192.168.14.4 as-number 65001
R4:
bgp 65001
peer 192.168.14.1 as-number 100
R3:
bgp 100
ipv4-family -instance 6
peer 192.168.36.6 as-number 65001
R6:
bgp 65001
peer 192.168.36.3 as-number 100
#
[R1]dis bgp v4 all peer //R1认为R4是v4邻居
[R4]dis bgp peer //R4认为R1是ipv4邻居
R4:
bgp 65001
network 172.16.1.0 255.255.255.0
R6:
bgp 65001
network 172.16.2.0 255.255.255.0
R4:
bgp 65001
peer 192.168.14.1 allow-as-loop
R6:
bgp 65001
peer 192.168.36.3 allow-as-loop
#
[R4]dis bgp routing-table //收到和本地AS相同的路由
[R6]dis bgp routing-table
3.2 客户B与ISP之间运行OSPF,满足以下需求:
3.2.1 R1创建VRF,名称5,RD5:5,出方向RT5:7
R3创建VRF,名称7,RD7:7,出方向RT7:5
R1/3配置合适的入方向RT,接收对端v4路由。
R1:
ip -instance 5
ipv4-family
route-distinguisher 5:5
-target 5:7 export-extcommunity
-target 7:5 import-extcommunity
R3:
ip -instance 7
ipv4-family
route-distinguisher 7:7
-target 7:5 export-extcommunity
-target 5:7 import-extcommunity
R1:
interface GigabitEthernet0/0/2
ip binding -instance 5
ip address 192.168.15.1 255.255.255.0
R3:
interface GigabitEthernet0/0/2
ip binding -instance 7
ip address 192.168.37.3 255.255.255.0
R1:
ospf 1 router-id 1.1.1.1 -instance 5
import-route bgp
area 0.0.0.0
network 192.168.15.1 0.0.0.0
R5:
ospf 1 router-id 5.5.5.5’
area 0.0.0.0
network 172.16.1.1 0.0.0.0
network 192.168.15.5 0.0.0.0
R3:
ospf 1 router-id 3.3.3.3 -instance 7
import-route bgp
area 0.0.0.0
network 192.168.37.3 0.0.0.0
R7:
ospf 1 router-id 7.7.7.7
area 0.0.0.0
network 172.16.2.1 0.0.0.0
network 192.168.37.7 0.0.0.0
#
[R1]dis ospf peer brief //OSPF可以直接查看VRF邻居
[R3]dis ospf peer brief
R1:
bgp 100
ipv4-family -instance 5
import-route ospf 1
R3:
bgp 100
ipv4-family -instance 7
import-route ospf 1
R1:
ospf 1 router-id 1.1.1.1 -instance 5
import-route bgp
R3:
ospf 1 router-id 3.3.3.3 -instance 7
import-route bgp
[R5]dis ospf routing
[R7]dis ospf routing
R1:
interface LoopBack0
ip address 192.168.1.1 255.255.255.0
#
interface GigabitEthernet0/0/0
ip address 12.1.1.1 255.255.255.0
#
R2:
interface GigabitEthernet0/0/0
ip address 12.1.1.2 255.255.255.0
#
interface GigabitEthernet0/0/1
ip address 23.1.1.2 255.255.255.0
#
R3:
interface LoopBack0
ip address 192.168.3.1 255.255.255.0
#
interface GigabitEthernet0/0/0
ip address 23.1.1.3 255.255.255.0
R1:
ip route-static 0.0.0.0 0.0.0.0 12.1.1.2
R3:
ip route-static 0.0.0.0 0.0.0.0 23.1.1.2
R1:
interface Tunnel0/0/0
ip address 192.168.13.1 255.255.255.0
tunnel-protocol gre
source 12.1.1.1
destination 23.1.1.3
R3:
interface Tunnel0/0/0
ip address 192.168.13.3 255.255.255.0
tunnel-protocol gre
source 23.1.1.3
destination 12.1.1.1
R1:
ospf 1 router-id 1.1.1.1
area 0.0.0.0
network 192.168.1.1 0.0.0.0
network 192.168.13.1 0.0.0.0
#
R3:
ospf 1 router-id 3.3.3.3
area 0.0.0.0
network 192.168.3.1 0.0.0.0
network 192.168.13.3 0.0.0.0
*关于OSPF不能宣告公网接口的原因:
如果R1宣告12.1.1.0/24到ospf中,那么R3就会从隧道接口通过OSPF学习到这条路由。
那么当R3与12.1.1.1通信时,就会将数据包发往隧道接口。
而隧道接口新封装的目的IP又是12.1.1.1,再次递归到隧道接口。
导致循环封装IP层而无法发包。
如果R1不宣告12.1.1.0/24到ospf中,那么R3就会依靠默认路由与12.1.1.1通信,默认路由出接口直接就是物理接口,就能正常发包。
本篇实验拓扑及配置步骤参考资料来自思博教育