
四台PC的IP地址如图所示,子网掩码均为255.255.255.0,四台PC处在同一个局域网之中,在配置VLAN之前能够彼此ping通。配置的目的是将PC1和PC3划分到VLAN10中,PC2和PC4划分到VLAN20中。
在配置之前需要进入系统视角。
在两个交换机上都需要分别创建VLAN10和VLAN20:
vlan vlan-id
通过vlan命令创建vlan,vlan-id为指定的id。


按照不同端口类型的功能,两个交换机与PC连接的端口都配置为access。
1.配置接口类型
port link-type access
2.配置端口的默认VLAN
port default vlan vlan-id


两个交换机相互连接的端口可能要通过多个vlan,因此设置为Trunk接口。
1.配置接口类型
port link-type trunk
2.接口加入允许通过的vlan
port trunk allow-pass vlan vlan-id
3.配置trunk接口的默认vlan(一般默认为1)
port trunk pvid vlan vlan-id


经过上面的配置之后,通过测试可以发现只有在同一vlan下的主机才能相互ping通了,实现了广播域的分割。

在进入MPLS相关配置之前要先按照拓扑图中的信息配置好设备IP。
1.在R1上配置到达4.4.4.0/24的静态路由,下一跳为 R2;
2.在R4上配置到达1.1.1.0/24的静态路由,下一跳为 R3;
3.R2和R3上根据标签进行转发,无需配置路由。






R1配置:
static-lsp ingress 1to4 destination 4.4.4.0 24 nexthop 12.1.1.2 out-label 112

R2配置:
static-lsp transit 1to4 incoming-interface g0/0/0 in-label 112 nexthop 23.1.1.3 out-label 123

R3配置:
static-lsp transit 1to4 incoming-interface g0/0/0 in-label 123 nexthop 34.1.1.3 out-label 134

R4配置:
static-lsp egress 1to4 incoming-interface g0/0/0 in-label 134

注意三种类型的LSR的配置方式的区别。
R4配置:
static-lsp ingress 4to1 destination 1.1.1.0 24 nexthop 34.1.1.3 out-label 143
R3配置:
static-lsp transit 4to1 incoming-interface g0/0/1 in-label 143 nexthop 23.1.1.2 out-label 132
R2配置:
static-lsp transit 4to1 incoming-interface g0/0/1 in-label 132 nexthop 12.1.1.1 out-label 121
R1配置:
static-lsp egress 4to1 incoming-interface g0/0/0 in-label 121
在LSR上执行下面的命令查看LSP:
display mpls lsp




验证:在PC1上ping PC2,如果能ping通,则配置成功。