mpls小实验

发布时间:2024年01月23日

效果:r7 ping通r1,r8; r8 ping 通r1,r7

代码:#先配置好接口ip,然后配置mpls

[r1]

ip route-static 0.0.0.0 0 12.1.1.2

[r2]

ip route-static vpn-instance 1 1.1.1.1 32 12.1.1.1

ip vpn-instance 1
? route-distinguisher 1:1
? vpn-target 1:1 export-extcommunity
? vpn-target 2:2 3:3 import-extcommunity

route recursive-lookup tunnel? ? ? ? ? ? ? ? #使能迭代隧道功能

ospf 1 router-id 2.2.2.2?
?area 0
? network 2.2.2.2 0.0.0.0?
? network 23.1.1.1 0.0.0.0?
? network 24.1.1.1 0.0.0.0?

mpls lsr-id 2.2.2.2
mpls
mpls ldp

interface GigabitEthernet0/0/0
?ip binding vpn-instance 1
interface GigabitEthernet0/0/1
?mpls
?mpls ldp

interface GigabitEthernet0/0/2
?mpls
?mpls ldp

bgp 100
?router-id 2.2.2.2
?peer 5.5.5.5 as-number 100?
?peer 5.5.5.5 connect-interface LoopBack0
?peer 6.6.6.6 as-number 100?
?ipv4-family vpnv4
? peer 5.5.5.5 enable
? peer 5.5.5.5 next-hop-local?
? peer 6.6.6.6 enable
? peer 6.6.6.6 next-hop-local?
?ipv4-family vpn-instance 1?
? import-route static
?

[r3]

route recursive-lookup tunnel

ospf 1 router-id 3.3.3.3?
?area 0.0.0.0?
? network 0.0.0.0 255.255.255.255?

mpls lsr-id 3.3.3.3
mpls
mpls ldp

interface GigabitEthernet0/0/0
?mpls
?mpls ldp

interface GigabitEthernet0/0/1
?mpls
?mpls ldp

interface GigabitEthernet0/0/2
?ip address 35.1.1.1 255.255.255.0?
?mpls
?mpls ldp

[r4] 同r3

[r5]

route recursive-lookup tunnel

ospf 1 router-id 5.5.5.5?
?area 0.0.0.0?
? network 5.5.5.5 0.0.0.0?
? network 35.1.1.2 0.0.0.0?
? network 45.1.1.2 0.0.0.0?

mpls lsr-id 5.5.5.5
mpls
mpls ldp

#r5的g0/0/0,g0/0/1和r2的g0/0/1,g0/0/2类似

ip vpn-instance 2
? route-distinguisher 2:2
? vpn-target 2:2 export-extcommunity
? vpn-target 1:1 3:3 import-extcommunity

ospf 2 vpn-instance 2
?import-route bgp
?area 0.0.0.0?
? network 57.1.1.1 0.0.0.0?

bgp 100
?router-id 5.5.5.5
?peer 2.2.2.2 as-number 100?
?peer 2.2.2.2 connect-interface LoopBack0
?peer 6.6.6.6 as-number 100?
?peer 6.6.6.6 connect-interface LoopBack0
?ipv4-family vpnv4
? peer 2.2.2.2 enable
? peer 2.2.2.2 next-hop-local?
? peer 6.6.6.6 enable
? peer 6.6.6.6 next-hop-local?
?ipv4-family vpn-instance 2?
? import-route ospf 2

interface GigabitEthernet0/0/2
?ip binding vpn-instance 2

[r6]

route recursive-lookup tunnel

ospf 1 router-id 6.6.6.6?
?area 0.0.0.0?
? network 6.6.6.6 0.0.0.0?
? network 36.1.1.2 0.0.0.0?
? network 46.1.1.2 0.0.0.0?

mpls lsr-id 6.6.6.6
mpls
mpls ldp

g0/0/0和g0/0/1同r2,R5

ip vpn-instance 3
? route-distinguisher 3:3
? vpn-target 3:3 export-extcommunity
? vpn-target 1:1 2:2 import-extcommunity

rip 1 vpn-instance 3
?version 2
?network 68.0.0.0
?import-route bgp

bgp 100
?router-id 6.6.6.6
?peer 2.2.2.2 as-number 100?
?peer 2.2.2.2 connect-interface LoopBack0
?peer 5.5.5.5 as-number 100?
?peer 5.5.5.5 connect-interface LoopBack0
?ipv4-family vpnv4
? policy vpn-target
? peer 2.2.2.2 enable
? peer 2.2.2.2 next-hop-local?
? peer 5.5.5.5 enable
? peer 5.5.5.5 next-hop-local?
?ipv4-family vpn-instance 3?
? import-route rip 1

interface GigabitEthernet0/0/2
?ip binding vpn-instance 3

[r7]

ospf 2 router-id 7.7.7.7?
?area 0.0.0.0?
? network 0.0.0.0 255.255.255.255?

[r8]

rip 1
?version 2
?network 8.0.0.0
?network 68.0.0.0

文章来源:https://blog.csdn.net/wzzzzz06/article/details/135786480
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。