MPLS ×××
最近在学习MPLS,感觉有点头痛,这是个比较好的例子,暂时先挂在这了!
拓扑:
LSP-----标签交换路径
说明: r1在AS1中,r2 r5在AS100中,r6在AS6中,r2与r5建立IBGP且AS为100; r2 r3 r4 r5为MPLS domin,
r2-r5-ibgp-AS100---------------------r2-r5-ibgp-AS100
-------AS1-r1-----EBGP--------|--r2--------r3--------r4------------r5--|--------EBGP-----r6-AS6---
r2-r3-r4-r5--MPLS Domain
-------AS1-r1-----EBGP--------|--r2--------r3--------r4------------r5--|--------EBGP-----r6-AS6---
r2-r3-r4-r5--MPLS Domain
==================================================================================================================
练习拓扑Rack02:
r2-r5-ibgp-AS100----------------------------r2-r5-ibgp-AS100
-------AS1-r4-----EBGP----------|--r2-----------r3------------r1----------------r5--|--------EBGP-----r6-AS6---
e0 e0/0 e0/1 e0/1 e0/0 e0/0 e0/1 e0/1 e0/0 e0
192.168.42.0/24 192.168.23.0/024 192.168.31.0/24 192.168.15.0/24 192.168.56.0/24
r2-r3-r4-r5--MPLS Domain
因为以下没有启用MPLS,所以r4拼不通r6的环回接口(因为有黑洞,启用mpls之后也不行,因为r2 r5是以物理口建ibgp邻居,r1向r2回包时会pop弹掉标签而导致不通),练习笔记中的配置则可以拼通(建议使用练习笔记中的配置)
IP初始化:
r4:
en
conf t
host r4
no ip domain-lookup
line con 0
logg sy
exec-timeout 0 0
exit
no ip routing
ip routing
defa int e0
defa int e1
defa int s0
defa int s1
no int loo0
int e0
ip add 192.168.42.4 255.255.255.0
no sh
int lo0
ip add 192.168.4.1 255.255.255.0
ip ospf network point-to-point
end
conf t
router bgp 4
bgp router-id 4.4.4.4
no sy
no au
neighbor 192.168.42.2 remote 100
net 192.168.42.0 mask 255.255.255.0
net 192.168.4.0 mask 255.255.255.0
end
conf t
host r4
no ip domain-lookup
line con 0
logg sy
exec-timeout 0 0
exit
no ip routing
ip routing
defa int e0
defa int e1
defa int s0
defa int s1
no int loo0
int e0
ip add 192.168.42.4 255.255.255.0
no sh
int lo0
ip add 192.168.4.1 255.255.255.0
ip ospf network point-to-point
end
conf t
router bgp 4
bgp router-id 4.4.4.4
no sy
no au
neighbor 192.168.42.2 remote 100
net 192.168.42.0 mask 255.255.255.0
net 192.168.4.0 mask 255.255.255.0
end
r2:
en
conf t
host r2
no ip domain-lookup
line con 0
logg sy
exec-timeout 0 0
exit
no ip routing
ip routing
defa int e0/0
defa int e0/1
defa int s0/0
defa int s0/1
no int loo0
int e0/0
ip add 192.168.42.2 255.255.255.0
no sh
int e0/1
ip add 192.168.23.2 255.255.255.0
no sh
int lo0
ip add 192.168.2.1 255.255.255.0
ip ospf network point-to-point
end
conf t
router ospf 100
router-id 2.2.2.2
net 192.168.23.2 0.0.0.0 a 0
net 192.168.2.1 0.0.0.0 a 0
end
router bgp 100
bgp router-id 2.2.2.2
no sy
no au
neighbor 192.168.42.4 remote 4
neighbor 192.168.15.5 remote 100
network 192.168.23.0 mask 255.255.2550
network 192.168.2.0 mask 255.255.255.0
end
conf t
host r2
no ip domain-lookup
line con 0
logg sy
exec-timeout 0 0
exit
no ip routing
ip routing
defa int e0/0
defa int e0/1
defa int s0/0
defa int s0/1
no int loo0
int e0/0
ip add 192.168.42.2 255.255.255.0
no sh
int e0/1
ip add 192.168.23.2 255.255.255.0
no sh
int lo0
ip add 192.168.2.1 255.255.255.0
ip ospf network point-to-point
end
conf t
router ospf 100
router-id 2.2.2.2
net 192.168.23.2 0.0.0.0 a 0
net 192.168.2.1 0.0.0.0 a 0
end
router bgp 100
bgp router-id 2.2.2.2
no sy
no au
neighbor 192.168.42.4 remote 4
neighbor 192.168.15.5 remote 100
network 192.168.23.0 mask 255.255.2550
network 192.168.2.0 mask 255.255.255.0
end
r3:
en
conf t
host r3
no ip domain-lookup
line con 0
logg sy
exec-timeout 0 0
exit
no ip routing
ip routing
defa int e0/0
defa int e0/1
defa int s0/0
defa int s0/1
no int loo0
int e0/0
ip add 192.168.31.3 255.255.255.0
no sh
int e0/1
ip add 192.168.23.3 255.255.255.0
no sh
int lo0
ip add 192.168.3.1 255.255.255.0
ip ospf network point-to-point
end
conf t
router ospf 100
router-id 3.3.3.3
net 192.168.23.3 0.0.0.0 a 0
net 192.168.31.3 0.0.0.0 a 0
net 192.168.3.1 0.0.0.0 a 0
end
conf t
host r3
no ip domain-lookup
line con 0
logg sy
exec-timeout 0 0
exit
no ip routing
ip routing
defa int e0/0
defa int e0/1
defa int s0/0
defa int s0/1
no int loo0
int e0/0
ip add 192.168.31.3 255.255.255.0
no sh
int e0/1
ip add 192.168.23.3 255.255.255.0
no sh
int lo0
ip add 192.168.3.1 255.255.255.0
ip ospf network point-to-point
end
conf t
router ospf 100
router-id 3.3.3.3
net 192.168.23.3 0.0.0.0 a 0
net 192.168.31.3 0.0.0.0 a 0
net 192.168.3.1 0.0.0.0 a 0
end
r1:
en
conf t
host r1
no ip domain-lookup
line con 0
logg sy
exec-timeout 0 0
exit
no ip routing
ip routing
defa int e0/0
defa int e0/1
defa int s0/0
defa int s0/1
no int loo0
int e0/0
ip add 192.168.31.1 255.255.255.0
no sh
int e0/1
ip add 192.168.15.1 255.255.255.0
no sh
int lo0
ip add 192.168.1.1 255.255.255.0
ip ospf network point-to-point
end
conf t
router ospf 100
router-id 1.1.1.1
network 192.168.31.1 0.0.0.0 a 0
network 192.168.15.1 0.0.0.0 a 0
network 192.168.1.1 0.0.0.0 a 0
end
conf t
host r1
no ip domain-lookup
line con 0
logg sy
exec-timeout 0 0
exit
no ip routing
ip routing
defa int e0/0
defa int e0/1
defa int s0/0
defa int s0/1
no int loo0
int e0/0
ip add 192.168.31.1 255.255.255.0
no sh
int e0/1
ip add 192.168.15.1 255.255.255.0
no sh
int lo0
ip add 192.168.1.1 255.255.255.0
ip ospf network point-to-point
end
conf t
router ospf 100
router-id 1.1.1.1
network 192.168.31.1 0.0.0.0 a 0
network 192.168.15.1 0.0.0.0 a 0
network 192.168.1.1 0.0.0.0 a 0
end
r5:
en
conf t
host r5
no ip domain-lookup
line con 0
logg sy
exec-timeout 0 0
exit
no ip routing
ip routing
defa int e0/0
defa int e0/1
defa int s0/0
defa int s0/1
no int loo0
int e0/1
ip add 192.168.15.5 255.255.255.0
no sh
int e0/0
ip add 192.168.56.5 255.255.255.0
no sh
int lo0
ip add 192.168.5.1 255.255.255.0
ip ospf network point-to-point
end
conf t
router ospf 100
router-id 5.5.5.5
net 192.168.15.5 0.0.0.0 a 0
net 192.168.56.5 0.0.0.0 a 0
net 192.168.5.1 0.0.0.0 a 0
router bgp 100
bgp router-id 5.5.5.5
no sy
no au
neighbor 192.168.23.2 remote 100
neighbor 192.168.56.6 remote 6
network 192.168.15.0 mask 255.255.255.0
network 192.168.56.0 mask 255.255.255.0
end
conf t
host r5
no ip domain-lookup
line con 0
logg sy
exec-timeout 0 0
exit
no ip routing
ip routing
defa int e0/0
defa int e0/1
defa int s0/0
defa int s0/1
no int loo0
int e0/1
ip add 192.168.15.5 255.255.255.0
no sh
int e0/0
ip add 192.168.56.5 255.255.255.0
no sh
int lo0
ip add 192.168.5.1 255.255.255.0
ip ospf network point-to-point
end
conf t
router ospf 100
router-id 5.5.5.5
net 192.168.15.5 0.0.0.0 a 0
net 192.168.56.5 0.0.0.0 a 0
net 192.168.5.1 0.0.0.0 a 0
router bgp 100
bgp router-id 5.5.5.5
no sy
no au
neighbor 192.168.23.2 remote 100
neighbor 192.168.56.6 remote 6
network 192.168.15.0 mask 255.255.255.0
network 192.168.56.0 mask 255.255.255.0
end
r6:
en
conf t
host r6
no ip domain-lookup
line con 0
logg sy
exec-timeout 0 0
exit
no ip routing
ip routing
defa int e0
defa int e1
defa int s0
defa int s1
no int loo0
int e0
ip add 192.168.56.6 255.255.255.0
no sh
int lo0
ip add 192.168.6.1 255.255.255.0
ip ospf network point-to-point
end
conf t
router bgp 6
bgp router-id 6.6.6.6
no sy
no au
neighbor 192.168.56.5 remote 100
net 192.168.56.0 mask 255.255.255.0
net 192.168.6.0 mask 255.255.255.0
end
conf t
host r6
no ip domain-lookup
line con 0
logg sy
exec-timeout 0 0
exit
no ip routing
ip routing
defa int e0
defa int e1
defa int s0
defa int s1
no int loo0
int e0
ip add 192.168.56.6 255.255.255.0
no sh
int lo0
ip add 192.168.6.1 255.255.255.0
ip ospf network point-to-point
end
conf t
router bgp 6
bgp router-id 6.6.6.6
no sy
no au
neighbor 192.168.56.5 remote 100
net 192.168.56.0 mask 255.255.255.0
net 192.168.6.0 mask 255.255.255.0
end
sw1:
en
vl da
vl 42 na r4-r2
vl 31 na r3-r1
vl 56 na r5-r6
exit
conf t
host sw1
no ip domain-lookup
line con 0
logg sy
exec-timeout 0 0
exit
no ip routing
ip routing
int ra f0/4 , f0/2
sw mo ac
sw ac vl 42
int ra f0/3 , f0/1
sw mo ac
sw ac vl 31
int ra f0/5 , f0/6
sw mo ac
sw ac vl 56
end
vl da
vl 42 na r4-r2
vl 31 na r3-r1
vl 56 na r5-r6
exit
conf t
host sw1
no ip domain-lookup
line con 0
logg sy
exec-timeout 0 0
exit
no ip routing
ip routing
int ra f0/4 , f0/2
sw mo ac
sw ac vl 42
int ra f0/3 , f0/1
sw mo ac
sw ac vl 31
int ra f0/5 , f0/6
sw mo ac
sw ac vl 56
end
sw2:
en
vl da
vl 23 na r2-r3
vl 15 na r1-r5
exit
conf t
host sw2
no ip domain-lookup
line con 0
logg sy
exec-timeout 0 0
exit
no ip routing
ip routing
int ra f0/2-3
sw mo ac
sw ac vl 23
int ra f0/1 , f0/5
sw mo ac
sw ac vl 15
end
===========================================================================================
r3#debug mpls packets
MPLS packet debugging is on
r3#
COMM_SERV_RACK2>4
[Resuming connection 4 to r4 ... ]
COMM_SERV_RACK2>4
[Resuming connection 4 to r4 ... ]
r4#traceroute ip
Target IP address: 192.168.6.1
Source address: 192.168.4.1
Numeric display [n]:
Timeout in seconds [3]:
Probe count [3]:
Minimum Time to Live [1]:
Maximum Time to Live [30]:
Port Number [33434]:
Loose, Strict, Record, Timestamp, Verbose[none]:
Type escape sequence to abort.
Tracing the route to 192.168.6.1
Source address: 192.168.4.1
Numeric display [n]:
Timeout in seconds [3]:
Probe count [3]:
Minimum Time to Live [1]:
Maximum Time to Live [30]:
Port Number [33434]:
Loose, Strict, Record, Timestamp, Verbose[none]:
Type escape sequence to abort.
Tracing the route to 192.168.6.1
1 192.168.42.2 4 msec 4 msec 4 msec
2 192.168.15.5 [AS 100] 8 msec 12 msec 12 msec
3 192.168.56.6 [AS 100] 12 msec
COMM_SERV_RACK2>3
[Resuming connection 3 to r3 ... ]
2 192.168.15.5 [AS 100] 8 msec 12 msec 12 msec
3 192.168.56.6 [AS 100] 12 msec
COMM_SERV_RACK2>3
[Resuming connection 3 to r3 ... ]
*Ma: Et0/0: recvd: CoS=6, TTL=254, Label(s)=20
*Mar 2 04:16:17.044: MPLS: Et0/1: xmit: (no label)
*Mar 2 04:16:17.052: MPLS: Et0/1: recvd: CoS=0, TTL=255, Label(s)=18
*Mar 2 04:16:17.052: MPLS: Et0/0: xmit: CoS=0, TTL=254, Label(s)=17
*Mar 2 04:16:17.060: MPLS: Et0/0: recvd: CoS=6, TTL=253, Label(s)=20
*Mar 2 04:16:17.060: MPLS: Et0/1: xmit: (no label)
*Mar 2 04:16:17.068: MPLS: Et0/1: recvd: CoS=0, TTL=255, Label(s)=18
*Mar 2 04:16:17.072: MPLS: Et0/0: xmit: CoS=0, TTL=254, Label(s)=17
r3#
*Mar 2 04:16:20.069: MPLS: Et0/1: recvd: CoS=0, TTL=255, Label(s)=18
*Mar 2 04:16:20.069: MPLS: Et0/0: xmit: CoS=0, TTL=254, Label(s)=17
*Mar 2 04:16:20.077: MPLS: Et0/0: recvd: CoS=6, TTL=253, Label(s)=20
*Mar 2 04:16:20.077: MPLS: Et0/1: xmit: (no label)
r3#
*Mar 2 04:16:21.612: MPLS: Et0/1: recvd: CoS=6, TTL=255, Label(s)=18
*Mar 2 04:16:21.612: MPLS: Et0/0: xmit: CoS=6, TTL=254, Label(s)=17
*Mar 2 04:16:21.620: MPLS: Et0/0: recvd: CoS=6, TTL=254, Label(s)=20
*Mar 2 04:16:21.620: MPLS: Et0/1: xmit: (no label)
*Mar 2 04:16:21.820: MPLS: Et0/1: recvd: CoS=6, TTL=255, Label(s)=18
*Mar 2 04:16:21.820: MPLS: Et0/0: xmit: CoS=6, TTL=254, Label(s)=17
r3#und all
All possible debugging has been turned off
r3#
COMM_SERV_RACK2>2
[Resuming connection 2 to r2 ... ]
*Mar 2 04:16:17.044: MPLS: Et0/1: xmit: (no label)
*Mar 2 04:16:17.052: MPLS: Et0/1: recvd: CoS=0, TTL=255, Label(s)=18
*Mar 2 04:16:17.052: MPLS: Et0/0: xmit: CoS=0, TTL=254, Label(s)=17
*Mar 2 04:16:17.060: MPLS: Et0/0: recvd: CoS=6, TTL=253, Label(s)=20
*Mar 2 04:16:17.060: MPLS: Et0/1: xmit: (no label)
*Mar 2 04:16:17.068: MPLS: Et0/1: recvd: CoS=0, TTL=255, Label(s)=18
*Mar 2 04:16:17.072: MPLS: Et0/0: xmit: CoS=0, TTL=254, Label(s)=17
r3#
*Mar 2 04:16:20.069: MPLS: Et0/1: recvd: CoS=0, TTL=255, Label(s)=18
*Mar 2 04:16:20.069: MPLS: Et0/0: xmit: CoS=0, TTL=254, Label(s)=17
*Mar 2 04:16:20.077: MPLS: Et0/0: recvd: CoS=6, TTL=253, Label(s)=20
*Mar 2 04:16:20.077: MPLS: Et0/1: xmit: (no label)
r3#
*Mar 2 04:16:21.612: MPLS: Et0/1: recvd: CoS=6, TTL=255, Label(s)=18
*Mar 2 04:16:21.612: MPLS: Et0/0: xmit: CoS=6, TTL=254, Label(s)=17
*Mar 2 04:16:21.620: MPLS: Et0/0: recvd: CoS=6, TTL=254, Label(s)=20
*Mar 2 04:16:21.620: MPLS: Et0/1: xmit: (no label)
*Mar 2 04:16:21.820: MPLS: Et0/1: recvd: CoS=6, TTL=255, Label(s)=18
*Mar 2 04:16:21.820: MPLS: Et0/0: xmit: CoS=6, TTL=254, Label(s)=17
r3#und all
All possible debugging has been turned off
r3#
COMM_SERV_RACK2>2
[Resuming connection 2 to r2 ... ]
r2#sh mpls forwarding-table
Local Outgoing Prefix Bytes tag Outgoing Next Hop
tag tag or VC or Tunnel Id switched interface
16 Pop tag 192.168.31.0/24 0 Et0/1 192.168.23.3
17 16 192.168.15.0/24 0 Et0/1 192.168.23.3
18 17 192.168.56.0/24 0 Et0/1 192.168.23.3
19 Untagged 192.168.4.0/24 0 Et0/0 192.168.42.4
20 18 192.168.5.0/24 0 Et0/1 192.168.23.3
21 19 192.168.1.0/24 0 Et0/1 192.168.23.3
22 Pop tag 192.168.3.0/24 0 Et0/1 192.168.23.3
Local Outgoing Prefix Bytes tag Outgoing Next Hop
tag tag or VC or Tunnel Id switched interface
16 Pop tag 192.168.31.0/24 0 Et0/1 192.168.23.3
17 16 192.168.15.0/24 0 Et0/1 192.168.23.3
18 17 192.168.56.0/24 0 Et0/1 192.168.23.3
19 Untagged 192.168.4.0/24 0 Et0/0 192.168.42.4
20 18 192.168.5.0/24 0 Et0/1 192.168.23.3
21 19 192.168.1.0/24 0 Et0/1 192.168.23.3
22 Pop tag 192.168.3.0/24 0 Et0/1 192.168.23.3
r2#
r2#sh mpls ldp bind
tib entry: 192.168.1.0/24, rev 16
local binding: tag: 21
remote binding: tsr: 192.168.3.1:0, tag: 19
tib entry: 192.168.2.0/24, rev 18
local binding: tag: imp-null
remote binding: tsr: 192.168.3.1:0, tag: 20
tib entry: 192.168.3.0/24, rev 20
local binding: tag: 22
remote binding: tsr: 192.168.3.1:0, tag: imp-null
tib entry: 192.168.4.0/24, rev 10
local binding: tag: 19
tib entry: 192.168.5.0/24, rev 12
local binding: tag: 20
remote binding: tsr: 192.168.3.1:0, tag: 18
tib entry: 192.168.15.0/24, rev 4
local binding: tag: 17
remote binding: tsr: 192.168.3.1:0, tag: 16
tib entry: 192.168.23.0/24, rev 14
local binding: tag: imp-null
remote binding: tsr: 192.168.3.1:0, tag: imp-null
tib entry: 192.168.31.0/24, rev 2
local binding: tag: 16
remote binding: tsr: 192.168.3.1:0, tag: imp-null
tib entry: 192.168.42.0/24, rev 6
local binding: tag: imp-null
tib entry: 192.168.56.0/24, rev 8
local binding: tag: 18
remote binding: tsr: 192.168.3.1:0, tag: 17
r2#
r2#sh mpls ldp bind
tib entry: 192.168.1.0/24, rev 16
local binding: tag: 21
remote binding: tsr: 192.168.3.1:0, tag: 19
tib entry: 192.168.2.0/24, rev 18
local binding: tag: imp-null
remote binding: tsr: 192.168.3.1:0, tag: 20
tib entry: 192.168.3.0/24, rev 20
local binding: tag: 22
remote binding: tsr: 192.168.3.1:0, tag: imp-null
tib entry: 192.168.4.0/24, rev 10
local binding: tag: 19
tib entry: 192.168.5.0/24, rev 12
local binding: tag: 20
remote binding: tsr: 192.168.3.1:0, tag: 18
tib entry: 192.168.15.0/24, rev 4
local binding: tag: 17
remote binding: tsr: 192.168.3.1:0, tag: 16
tib entry: 192.168.23.0/24, rev 14
local binding: tag: imp-null
remote binding: tsr: 192.168.3.1:0, tag: imp-null
tib entry: 192.168.31.0/24, rev 2
local binding: tag: 16
remote binding: tsr: 192.168.3.1:0, tag: imp-null
tib entry: 192.168.42.0/24, rev 6
local binding: tag: imp-null
tib entry: 192.168.56.0/24, rev 8
local binding: tag: 18
remote binding: tsr: 192.168.3.1:0, tag: 17
r2#
r5#clear ip cef * prefix-statistics
如果r2与r5之间的环回口为192.168.2.1/24, 结果在r5上的OSPF产生/32位的主机路由而分配标签也可能会导致出问题(IOS有关)
=====================================================================================================================
!! ok !!! !!! ok !!! !!! ok !!! !!! ok !!! !!! ok !!! !!! ok !!! !!! ok !!! !!! ok !!! !!! ok !!! !!! ok !!
=====================================================================================================================
!! ok !!! !!! ok !!! !!! ok !!! !!! ok !!! !!! ok !!! !!! ok !!! !!! ok !!! !!! ok !!! !!! ok !!! !!! ok !!
=====================================================================================================================
MPLS ×××:
GRE / IPSec ***
L2TP----(Layer 2 Tunneling Protocol)
L2F-----(Layer 2 Forwarding Protocol)
PPTP----(Point-to-Point Tunneling)
L2F-----(Layer 2 Forwarding Protocol)
PPTP----(Point-to-Point Tunneling)
Overlay ××× 与 Peer to Peer ××× 的区别:
Overlay ××× 在ISP端并不参与客户路由(如 GRE tunnel / IPSec); ××× 对端是客户去做的;
peer to peer *** 早期使用较少:
客户路由隔离;客户路由的传递;
客户路由隔离;客户路由的传递;
现在的MPLS即为peer to peer ***, 它能解决上述两个问题.
---C----CE----PE-----P-----P-----P----PE---CE-----C----
VRF-----虚拟路由器,做本地隔离;RD------路由器地址做全局隔离,地址为64位,加上32位的IP路由构成96位的××× V4路由,如1:1-10.1.1.0;7:7-10.1.1.0
r2#enable
r2(config)#ip cef
r2(config)#ip vrf r1
r2(config-vrf)#rd 1:1 / rd 192.168.42.2:1
r2(config)#ip vrf r10
r2(config-vrf)#rd 10:10 / rd 192.168.42.2:10
r2(config-vrf)#exit
r2(config)#int e0/0.42
r2(config-subif)#ip vrf forwarding r1 --------------------原地址会自动移除,需重设地址;
r2(config-subif)#ip add 192.168.42.2 255.255.255.0
r2(config)#int e0/0.102
r2(config-subif)#ip vrf forwarding r10 --------------------原地址会自动移除,需重设地址;
r2(config-subif)#ip add 192.168.102.2 255.255.255.0
r2(config-subif)#end
r2#sh run
r2#sh ip route vrf r1 -----------------------------------查看虚拟子路由器r1的路由表;
r2#ping vrf r1 192.168.42.4 ------------------------------拼虚拟子路由器中的192.168.42.4地址;
r2#ping vrf r1 10.2.1.1 ----------------------------------拼r4 路由器中的10.2.1.1地址
r2(config)#ip cef
r2(config)#ip vrf r1
r2(config-vrf)#rd 1:1 / rd 192.168.42.2:1
r2(config)#ip vrf r10
r2(config-vrf)#rd 10:10 / rd 192.168.42.2:10
r2(config-vrf)#exit
r2(config)#int e0/0.42
r2(config-subif)#ip vrf forwarding r1 --------------------原地址会自动移除,需重设地址;
r2(config-subif)#ip add 192.168.42.2 255.255.255.0
r2(config)#int e0/0.102
r2(config-subif)#ip vrf forwarding r10 --------------------原地址会自动移除,需重设地址;
r2(config-subif)#ip add 192.168.102.2 255.255.255.0
r2(config-subif)#end
r2#sh run
r2#sh ip route vrf r1 -----------------------------------查看虚拟子路由器r1的路由表;
r2#ping vrf r1 192.168.42.4 ------------------------------拼虚拟子路由器中的192.168.42.4地址;
r2#ping vrf r1 10.2.1.1 ----------------------------------拼r4 路由器中的10.2.1.1地址
r2(config)#ip route vrf r1 10.0.0.0 255.252.0.0 e0/0.42 192.168.42.4 -----r2添加到达r4的环回口的静态路由;
r2(config)#ip route vrf r10 10.0.0.0 255.252.0.0 e0/0.102 192.168.102.10 -----r2添加到达r4的环回口的静态路由;
r2(config)#ip route vrf r10 10.0.0.0 255.252.0.0 e0/0.102 192.168.102.10 -----r2添加到达r4的环回口的静态路由;
r2(config)#router bgp 100
r2(config-router)#no bgp default ipv4-unicast --------------------------------关闭bgp单播建邻居传32位路由功能
r2(config-router)#no bgp default ipv4-unicast --------------------------------关闭bgp单播建邻居传32位路由功能
r2(config-router)#address-family ipv4
r2(config-router-af)#neighbor 192.168.5.1 activate ---------------------------开启bgp 32位邻居,可传32位路由
r2(config-router-af)#neighbor 192.168.5.1 activate ---------------------------开启bgp 32位邻居,可传32位路由
r2(config-router)#address-family ***v4 ---------------------------------------开启bgp传96位路由功能
r2(config-router-af)#neighbor 192.168.5.1 activate ---------------------------r2与r5在***v4中建邻居关系
r2(config-router-af)#neighbor 192.168.5.1 activate ---------------------------r2与r5在***v4中建邻居关系
r2#sh ip bgp ***v4 all summary -----------------------------------------------查看bgp邻居关系
r2#sh ip bgp ***v4 * summary -----------------------------------------------查看bgp邻居关系
BGP router identifier 2.2.2.2, local AS number 100
BGP table version is 1, main routing table version 1
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
192.168.5.1 4 100 1153 1152 1 0 0 00:02:54 0
192.168.5.1 4 100 1153 1152 1 0 0 00:02:54 0
r2#sh ip protocols vrf r1 ---------------------------------------------------查看r2上vrf运行的路由协议
r2#conf t
r2(config)#router bgp 100
r2(config-router)#address-family ipv4 vrf r1
r2(config-router-af)#redistribute static
r2(config-router-af)#exit
r2(config)#router bgp 100
r2(config-router)#address-family ipv4 vrf r1
r2(config-router-af)#redistribute static
r2(config-router-af)#exit
r2(config-router)#address-family ipv4 vrf r10
r2(config-router-af)#redistribute static -----------------让路由器r4与r10的路由经bgp传输
r2(config-router-af)#redistribute static -----------------让路由器r4与r10的路由经bgp传输
r2#sh ip bgp ***v4 all -----------------------------------查看bgp 的***v4 bgp路由
r2#sh ip bgp ***v4 all neighbors 192.168.5.1 advertised-routes -----查看发给r5的bgp ***v4路由条目
r2(config)#ip vrf r1
r2(config-vrf)#route-target export 1:1 / 100:1 --------------------导出值可不写1:1,可以与 vrf r1的rd值不相同,如100:1
r2(config)#ip vrf r10
r2(config-vrf)#route-target export 10:10 / 1000:10 ------------------让r2的bgp路由能通过***v4发出给r5
r2(config)#ip vrf r1
r2(config-vrf)#route-target import 6:6
r2(config)#ip vrf r10
r2(config-vrf)route-target import 11:11 ------------------让r2能接收r5发过来的***v4路由,默认不接收
r2#sh ip vrf detail --------------------------------------查看vrf的明细信息
r4#conf t
r4(config)#ip cef
r4(config)#ip routing
r4(config)#ip route 0.0.0.0 0.0.0.0 e0/0.12 192.168.42.2
r4(config)#end
r4#ping 192.168.42.2
r4#ping 172.16.1.1 source 10.1.1.1 ----------------------测试通
r4#telnet 172.16.3.1 /source-interface loopback 1 ----------测试成功,可看到r4 telnet 到达r6
r10#telnet 172.16.1.1 /source-interface loopback 1 --------测试成功,可看到r10 telnet 到达r11
---------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------
ok ! ok ! ok ! ok ! ok ! ok ! ok ! ok ! ok ! ok ! ok ! ok ! ok ! ok ! ok ! ok ! ok ! ok !
---------------------------------------------------------------------------------------------------------------
IP初始化:
r4:
en
conf t
host r4
no ip domain-lookup
line con 0
logg sy
exec-timeout 0 0
exit
no ip routing
ip routing
defa int e0
defa int e1
defa int s0
defa int s1
no int loo0
ip cef
int e0
ip add 192.168.42.4 255.255.255.0
no sh
int lo0
ip add 192.168.4.1 255.255.255.0
ip ospf network point-to-point
int lo1
ip add 10.1.1.1 255.255.255.0
ip ospf network point-to-point
int lo2
ip add 10.2.1.1 255.255.255.0
ip ospf network point-to-point
int lo3
ip add 10.3.1.1 255.255.255.0
ip ospf network point-to-point
end
conf t
ip route 0.0.0.0 0.0.0.0 e0 192.168.42.2
end
conf t
host r4
no ip domain-lookup
line con 0
logg sy
exec-timeout 0 0
exit
no ip routing
ip routing
defa int e0
defa int e1
defa int s0
defa int s1
no int loo0
ip cef
int e0
ip add 192.168.42.4 255.255.255.0
no sh
int lo0
ip add 192.168.4.1 255.255.255.0
ip ospf network point-to-point
int lo1
ip add 10.1.1.1 255.255.255.0
ip ospf network point-to-point
int lo2
ip add 10.2.1.1 255.255.255.0
ip ospf network point-to-point
int lo3
ip add 10.3.1.1 255.255.255.0
ip ospf network point-to-point
end
conf t
ip route 0.0.0.0 0.0.0.0 e0 192.168.42.2
end
--------------------------------------------------------------------------------------------------------------
r2:
en
conf t
host r2
no ip domain-lookup
line con 0
logg sy
exec-timeout 0 0
exit
no ip routing
ip routing
defa int e0/0
defa int e0/1
defa int s0/0
defa int s0/1
no int loo0
ip cef
int e0/0
no sh
int e0/0.42
en do 42
ip add 192.168.42.2 255.255.255.0
no sh
int e0/0.102
en do 102
ip add 192.168.102.2 255.255.255.0
no sh
int e0/1
ip add 192.168.23.2 255.255.255.0
no sh
int lo0
ip add 192.168.2.1 255.255.255.0
ip ospf network point-to-point
end
conf t
router ospf 100
router-id 2.2.2.2
net 192.168.23.2 0.0.0.0 a 0
net 192.168.2.1 0.0.0.0 a 0
end
conf t
router bgp 100
bgp router-id 2.2.2.2
no sy
no au
neighbor 192.168.42.4 remote 4
neighbor 192.168.5.1 remote 100
neighbor 192.168.5.1 update-source loop0
neighbor 192.168.5.1 ebgp
network 192.168.23.0 mask 255.255.255.0
network 192.168.2.0 mask 255.255.255.0
end
en
conf t
int e0/0
no sh
int e0/0.42
en do 42
ip add 192.168.42.2 255.255.255.0
no sh
int e0/0.102
en do 102
ip add 192.168.102.2 255.255.255.0
no sh
end
enable
conf t
ip cef
mpls label range 2000 2999
mpls label protocol ldp
int e0/1
mpls ip
end
conf t
ip vrf r1
rd 1:1
exit
ip vrf r10
rd 10:10
exit
int e0/0.42
ip vrf forward r1
ip add 192.168.42.2 255.255.255.0
int e0/0.102
ip vrf forward r10
ip add 192.168.102.2 255.255.255.0
end
conf t
ip route vrf r1 10.0.0.0 255.252.0.0 e0/0.42 192.168.42.4
ip route vrf r10 10.0.0.0 255.252.0.0 e0/0.102 192.168.102.10
end
conf t
ip vrf r1
route-target export 1:1
exit
ip vrf r10
route-target export 10:10
exit
ip vrf r1
route-target import 6:6
exit
ip vrf r10
route-target import 11:11
end
conf t
router bgp 100
no bgp default ipv4-unicast
address-family ipv4
neighbor 192.168.5.1 activate
exit
address-family ***v4
neighbor 192.168.5.1 activate
exit
address-family ipv4 vrf r1
redistribute static
exit
address-family ipv4 vrf r10
redistribute static
exit
end
conf t
host r2
no ip domain-lookup
line con 0
logg sy
exec-timeout 0 0
exit
no ip routing
ip routing
defa int e0/0
defa int e0/1
defa int s0/0
defa int s0/1
no int loo0
ip cef
int e0/0
no sh
int e0/0.42
en do 42
ip add 192.168.42.2 255.255.255.0
no sh
int e0/0.102
en do 102
ip add 192.168.102.2 255.255.255.0
no sh
int e0/1
ip add 192.168.23.2 255.255.255.0
no sh
int lo0
ip add 192.168.2.1 255.255.255.0
ip ospf network point-to-point
end
conf t
router ospf 100
router-id 2.2.2.2
net 192.168.23.2 0.0.0.0 a 0
net 192.168.2.1 0.0.0.0 a 0
end
conf t
router bgp 100
bgp router-id 2.2.2.2
no sy
no au
neighbor 192.168.42.4 remote 4
neighbor 192.168.5.1 remote 100
neighbor 192.168.5.1 update-source loop0
neighbor 192.168.5.1 ebgp
network 192.168.23.0 mask 255.255.255.0
network 192.168.2.0 mask 255.255.255.0
end
en
conf t
int e0/0
no sh
int e0/0.42
en do 42
ip add 192.168.42.2 255.255.255.0
no sh
int e0/0.102
en do 102
ip add 192.168.102.2 255.255.255.0
no sh
end
enable
conf t
ip cef
mpls label range 2000 2999
mpls label protocol ldp
int e0/1
mpls ip
end
conf t
ip vrf r1
rd 1:1
exit
ip vrf r10
rd 10:10
exit
int e0/0.42
ip vrf forward r1
ip add 192.168.42.2 255.255.255.0
int e0/0.102
ip vrf forward r10
ip add 192.168.102.2 255.255.255.0
end
conf t
ip route vrf r1 10.0.0.0 255.252.0.0 e0/0.42 192.168.42.4
ip route vrf r10 10.0.0.0 255.252.0.0 e0/0.102 192.168.102.10
end
conf t
ip vrf r1
route-target export 1:1
exit
ip vrf r10
route-target export 10:10
exit
ip vrf r1
route-target import 6:6
exit
ip vrf r10
route-target import 11:11
end
conf t
router bgp 100
no bgp default ipv4-unicast
address-family ipv4
neighbor 192.168.5.1 activate
exit
address-family ***v4
neighbor 192.168.5.1 activate
exit
address-family ipv4 vrf r1
redistribute static
exit
address-family ipv4 vrf r10
redistribute static
exit
end
注: 当时忘了 ip route vrf r10 10.0.0.0 255.252.0.0 e0/0.102 192.168.102.10 则
r10#telnet 172.16.1.1 /source-interface loopback 1 -----无效!!!!! 查了很久
int e0/0.42
ip vrf forward r1 -------------------------------------写了该行后下行的地址要重写过
ip add 192.168.42.2 255.255.255.0 ---------------------因为上面,此处地址要重写过
--------------------------------------------------------------------------------------------------------------
r3:
en
conf t
host r3
no ip domain-lookup
line con 0
logg sy
exec-timeout 0 0
exit
no ip routing
ip routing
defa int e0/0
defa int e0/1
defa int s0/0
defa int s0/1
no int loo0
ip cef
int e0/0
ip add 192.168.31.3 255.255.255.0
no sh
int e0/1
ip add 192.168.23.3 255.255.255.0
no sh
int lo0
ip add 192.168.3.1 255.255.255.0
ip ospf network point-to-point
end
conf t
router ospf 100
router-id 3.3.3.3
net 192.168.23.3 0.0.0.0 a 0
net 192.168.31.3 0.0.0.0 a 0
net 192.168.3.1 0.0.0.0 a 0
end
conf t
ip cef
mpls label range 3000 3999
mpls label protocol ldp
int e0/1
mpls ip
int e0/0
mpls ip
end
conf t
host r3
no ip domain-lookup
line con 0
logg sy
exec-timeout 0 0
exit
no ip routing
ip routing
defa int e0/0
defa int e0/1
defa int s0/0
defa int s0/1
no int loo0
ip cef
int e0/0
ip add 192.168.31.3 255.255.255.0
no sh
int e0/1
ip add 192.168.23.3 255.255.255.0
no sh
int lo0
ip add 192.168.3.1 255.255.255.0
ip ospf network point-to-point
end
conf t
router ospf 100
router-id 3.3.3.3
net 192.168.23.3 0.0.0.0 a 0
net 192.168.31.3 0.0.0.0 a 0
net 192.168.3.1 0.0.0.0 a 0
end
conf t
ip cef
mpls label range 3000 3999
mpls label protocol ldp
int e0/1
mpls ip
int e0/0
mpls ip
end
--------------------------------------------------------------------------------------------------------------
r1:
en
conf t
host r1
no ip domain-lookup
line con 0
logg sy
exec-timeout 0 0
exit
no ip routing
ip routing
defa int e0/0
defa int e0/1
defa int s0/0
defa int s0/1
no int loo0
int e0/0
ip add 192.168.31.1 255.255.255.0
no sh
int e0/1
ip add 192.168.15.1 255.255.255.0
no sh
int lo0
ip add 192.168.1.1 255.255.255.0
ip ospf network point-to-point
end
conf t
router ospf 100
router-id 1.1.1.1
network 192.168.31.1 0.0.0.0 a 0
network 192.168.15.1 0.0.0.0 a 0
network 192.168.1.1 0.0.0.0 a 0
end
conf t
ip cef
mpls label range 1000 1999
mpls label protocol ldp
int e0/1
mpls ip
int e0/0
mpls ip
end
conf t
host r1
no ip domain-lookup
line con 0
logg sy
exec-timeout 0 0
exit
no ip routing
ip routing
defa int e0/0
defa int e0/1
defa int s0/0
defa int s0/1
no int loo0
int e0/0
ip add 192.168.31.1 255.255.255.0
no sh
int e0/1
ip add 192.168.15.1 255.255.255.0
no sh
int lo0
ip add 192.168.1.1 255.255.255.0
ip ospf network point-to-point
end
conf t
router ospf 100
router-id 1.1.1.1
network 192.168.31.1 0.0.0.0 a 0
network 192.168.15.1 0.0.0.0 a 0
network 192.168.1.1 0.0.0.0 a 0
end
conf t
ip cef
mpls label range 1000 1999
mpls label protocol ldp
int e0/1
mpls ip
int e0/0
mpls ip
end
--------------------------------------------------------------------------------------------------------------
r5:
en
conf t
host r5
no ip domain-lookup
line con 0
logg sy
exec-timeout 0 0
exit
no ip routing
ip routing
defa int e0/0
defa int e0/1
defa int s0/0
defa int s0/1
no int loo0
ip cef
int e0/1
ip add 192.168.15.5 255.255.255.0
no sh
int e0/0
no sh
int e0/0.56
en do 56
ip add 192.168.56.5 255.255.255.0
no sh
int e0/0.115
en do 115
ip add 192.168.115.5 255.255.255.0
no sh
int lo0
ip add 192.168.5.1 255.255.255.0
ip ospf network point-to-point
end
conf t
router ospf 100
router-id 5.5.5.5
net 192.168.15.5 0.0.0.0 a 0
net 192.168.56.5 0.0.0.0 a 0
net 192.168.5.1 0.0.0.0 a 0
router bgp 100
bgp router-id 5.5.5.5
no sy
no au
neighbor 192.168.2.1 remote 100
neighbor 192.168.2.1 update-source loop0
neighbor 192.168.2.1 ebgp
neighbor 192.168.56.6 remote 6
network 192.168.15.0 mask 255.255.255.0
network 192.168.56.0 mask 255.255.255.0
end
conf t
int e0/0
no sh
int e0/0.56
en do 56
ip add 192.168.56.5 255.255.255.0
no sh
int e0/0.115
en do 115
ip add 192.168.115.5 255.255.255.0
no sh
end
conf t
ip cef
mpls label range 5000 5999
mpls label protocol ldp
int e0/1
mpls ip
end
conf t
ip vrf r6
rd 6:6
exit
ip vrf r11
rd 11:11
exit
int e0/0.56
ip vrf forward r6
ip add 192.168.56.5 255.255.255.0
int e0/0.115
ip vrf forward r11
ip add 192.168.115.5 255.255.255.0
end
conf t
ip route vrf r6 172.16.0.0 255.255.252.0 e0/0.56 192.168.56.6
ip route vrf r11 172.16.0.0 255.255.252.0 e0/0.115 192.168.115.11
end
conf t
ip vrf r6
route-target export 6:6
exit
ip vrf r11
route-target export 11:11
exit
ip vrf r6
route-target import 1:1
exit
ip vrf r11
route-target import 10:10
end
conf t
router bgp 100
no bgp default ipv4-unicast
address-family ipv4
neighbor 192.168.2.1 activate
exit
address-family ***v4
neighbor 192.168.2.1 activate
exit
address-family ipv4 vrf r6
redistribute static
exit
address-family ipv4 vrf r11
redistribute static
end
--------------------------------------------------------------------------------------------------------------
r6:
en
conf t
host r6
no ip domain-lookup
line con 0
logg sy
exec-timeout 0 0
exit
no ip routing
ip routing
defa int e0
defa int e1
defa int s0
defa int s1
no int loo0
line vty 0 4
pass cisco2
login
int e0
ip add 192.168.56.6 255.255.255.0
no sh
int lo0
ip add 192.168.6.1 255.255.255.0
ip ospf network point-to-point
int lo1
ip add 172.16.1.1 255.255.255.0
ip ospf network point-to-point
int lo2
ip add 172.16.2.1 255.255.255.0
ip ospf network point-to-point
int lo3
ip add 172.16.3.1 255.255.255.0
ip ospf network point-to-point
end
conf t
ip route 0.0.0.0 0.0.0.0 e0 192.168.56.5
end
conf t
host r6
no ip domain-lookup
line con 0
logg sy
exec-timeout 0 0
exit
no ip routing
ip routing
defa int e0
defa int e1
defa int s0
defa int s1
no int loo0
line vty 0 4
pass cisco2
login
int e0
ip add 192.168.56.6 255.255.255.0
no sh
int lo0
ip add 192.168.6.1 255.255.255.0
ip ospf network point-to-point
int lo1
ip add 172.16.1.1 255.255.255.0
ip ospf network point-to-point
int lo2
ip add 172.16.2.1 255.255.255.0
ip ospf network point-to-point
int lo3
ip add 172.16.3.1 255.255.255.0
ip ospf network point-to-point
end
conf t
ip route 0.0.0.0 0.0.0.0 e0 192.168.56.5
end
--------------------------------------------------------------------------------------------------------------
r10:
en
conf t
host r10
no ip domain-lookup
line con 0
logg sy
exec-timeout 0 0
exit
no ip routing
ip routing
defa int e0
defa int s0
defa int s1
no int loo0
int e0
ip add 192.168.102.10 255.255.255.0
no sh
int lo0
ip add 192.168.10.1 255.255.255.0
ip ospf network point-to-point
int lo1
ip add 10.1.1.1 255.255.255.0
ip ospf network point-to-point
int lo2
ip add 10.2.1.1 255.255.255.0
ip ospf network point-to-point
int lo3
ip add 10.3.1.1 255.255.255.0
ip ospf network point-to-point
end
conf t
ip route 0.0.0.0 0.0.0.0 e0 192.168.102.2
end
conf t
host r10
no ip domain-lookup
line con 0
logg sy
exec-timeout 0 0
exit
no ip routing
ip routing
defa int e0
defa int s0
defa int s1
no int loo0
int e0
ip add 192.168.102.10 255.255.255.0
no sh
int lo0
ip add 192.168.10.1 255.255.255.0
ip ospf network point-to-point
int lo1
ip add 10.1.1.1 255.255.255.0
ip ospf network point-to-point
int lo2
ip add 10.2.1.1 255.255.255.0
ip ospf network point-to-point
int lo3
ip add 10.3.1.1 255.255.255.0
ip ospf network point-to-point
end
conf t
ip route 0.0.0.0 0.0.0.0 e0 192.168.102.2
end
--------------------------------------------------------------------------------------------------------------
r11:
en
conf t
host r11
no ip domain-lookup
line con 0
logg sy
exec-timeout 0 0
exit
no ip routing
ip routing
defa int e0
defa int s0
defa int s1
no int loo0
line vty 0 4
pass cisco2
login
int e0
ip add 192.168.115.11 255.255.255.0
no sh
int lo0
ip add 192.168.11.1 255.255.255.0
ip ospf network point-to-point
int lo1
ip add 172.16.1.1 255.255.255.0
ip ospf network point-to-point
int lo2
ip add 172.16.2.1 255.255.255.0
ip ospf network point-to-point
int lo3
ip add 172.16.3.1 255.255.255.0
ip ospf network point-to-point
end
conf t
ip route 0.0.0.0 0.0.0.0 e0 192.168.115.5
end
conf t
host r11
no ip domain-lookup
line con 0
logg sy
exec-timeout 0 0
exit
no ip routing
ip routing
defa int e0
defa int s0
defa int s1
no int loo0
line vty 0 4
pass cisco2
login
int e0
ip add 192.168.115.11 255.255.255.0
no sh
int lo0
ip add 192.168.11.1 255.255.255.0
ip ospf network point-to-point
int lo1
ip add 172.16.1.1 255.255.255.0
ip ospf network point-to-point
int lo2
ip add 172.16.2.1 255.255.255.0
ip ospf network point-to-point
int lo3
ip add 172.16.3.1 255.255.255.0
ip ospf network point-to-point
end
conf t
ip route 0.0.0.0 0.0.0.0 e0 192.168.115.5
end
转载于:https://blog.51cto.com/justim/218928