拓扑图
设备 | 接口 | IP地址 | 子网掩码 | 默认网关 |
---|---|---|---|---|
R1 | G0/0/0 | 10.0.12.1 | 255.255.255.0 | N/A |
Look 0 | 10.0.1.1 | 255.255.255.255 | N/A | |
R2 | G0/0/0 | 10.0.12.2 | 255.255.255.0 | |
G0/0/1 | 10.0.23.2 | 255.255.255.0 | N/A | |
Look 0 | 10.0.1.1 | 255.255.255.255 | N/A | |
R3 | G0/0/0 | 10.0.23.3 | 255.255.255.0 | N/A |
Look | 10.0.3.3 | 255.255.255.255 | N/A |
1.基本配置
R1:
sys
sysname R1
int loop 0
ip add 10.0.1.1 32
int g0/0/0
ip add 10.0.12.1 24
q
R2:
sys
sysname R2
int loop 0
ip add 10.0.2.2 32
int g0/0/0
ip add 10.0.12.2 24
int g0/0/1
ip add 10.0.23.2 24
q
R3:
sys
sysname R3
int loop 0
ip add 10.0.3.3 32
int g0/0/1
ip add 10.0.23.3 24
q
2.配置OSPF路由协议
R1
ospf router-id 10.0.1.1 //用look的ip地址作id名
area 0 //区域0
network 10.0.12.0 0.0.0.255 //宣告进OSPF
network 10.0.1.1 0.0.0.0 //0.0.0.0表示全匹配,0.0.0.255表示匹配后八位
R2
ospf router-id 10.0.2.2
area 0
network 10.0.12.0 0.0.0.255
network 10.0.2.2 0.0.0.0
network 10.0.23.0 0.0.0.255
R3
ospf router-id 10.0.3.3
area 0
network 10.0.23.0 0.0.0.255
network 10.0.3.3 0.0.0.0
3.配置MPLS协议
[R1]mpls lsr-id 10.0.1.1 //配置LSR ID
[R1]mpls //全局中启动MPLS
Info: Mpls starting, please wait... OK!
[R1-mpls]int g0/0/0
[R1-GigabitEthernet0/0/0]mpls //在要转发MPLS报文的接口上启动MPLS
R2
mpls lsr-id 10.0.2.2
mpls
int g0/0/0
mpls
int g0/0/1
mpls
R3
mpls lsr-id 10.0.3.3
mpls
int g0/0/1
mpls
4.配置静态LSP
配置R1去R3的LSP
[R1]static-lsp ingress R1toR3 destination 10.0.3.3 32 nexthop 10.0.12.2 out-label 102
//配置R1到R3的静态LSP的Ingress,分配标签
[R2]mpls lsr-id 10.0.2.2
[R2]mpls
Info: Mpls starting, please wait... OK!
[R2-mpls]int g0/0/0
[R2-GigabitEthernet0/0/0]mpls
[R2-GigabitEthernet0/0/0]int g0/0/1
[R2-GigabitEthernet0/0/1]mpls
[R2]static-lsp transit R1toR3 incoming-interface GigabitEthernet 0/0/0 in-label 102 nexthop 10.0.23.3 out-label 203
//配置R1到R3的静态LSP的Transit,分配标签
[R3]mpls lsr-id 10.0.2.2
[R3]mpls
[R3-mpls]int g0/0/1
[R3-GigabitEthernet0/0/1]mpls
[R3]static-lsp egress R1toR3 incoming-interface GigabitEthernet 0/0/1 in-label 203
//配置R1到R3的静态LSP的Egress,分配标签
验证
验证去往10.0.3.3 32的MPLS报文经过的路径
LSP具有单向性
配置R3去R1的LSP
[R3]static-lsp ingress R3toR1 destination 10.0.1.1 32 nexthop 10.0.23.2 out-label 101
[R2]static-lsp transit R3toR1 incoming-interface GigabitEthernet 0/0/1 in-label 101 nexthop 10.0.12.1 out-label 201
[R1]static-lsp egress R3toR1 incoming-interface GigabitEthernet 0/0/0 in-label 201
验证
5.利用LDP动态分发标签并建立LSP
[R1]undo static-lsp ingress R1toR3 //删除之前的静态LSP
[R1]undo static-lsp egress R3toR1
[R2]undo static-lsp transit R1toR3
[R2]undo static-lsp transit R3toR1
[R3]undo static-lsp egress R1toR3
[R3]undo static-lsp ingress R3toR1
[R1]mpls ldp //全局启动LDP
[R1-mpls-ldp]int g0/0/0
[R1-GigabitEthernet0/0/0]mpls ldp //接口上启动LDP
[R2]mpls ldp //全局启动LDP
[R2-mpls-ldp]int g0/0/0
[R2-GigabitEthernet0/0/0]mpls ldp //接口上启动LDP
[R2-mpls-ldp]int g0/0/1
[R2-GigabitEthernet0/0/1]mpls ldp //接口上启动LDP
[R3]mpls ldp //全局启动LDP
[R3-mpls-ldp]int g0/0/1
[R3-GigabitEthernet0/0/1]mpls ldp //接口上启动LDP
//要先配置MPLS才可以配置LDP
验证
查看LDP接口
g0/0/0接口启动了LDP,标签分发方式为DU方式
查看LDP会话信息
查看LSP信息
在R1上验证去往10.0.3.3/32的MPLS报文经过的路径
报文出发时标签是1025,经过R2后被替换成了3
实验结束