MPLS VPN配置 拓扑图 步骤一. 基本配置与IP编址 给所有路由器配置IP地址和掩码。 system-view [R1]interface Serial 1/0/0 [R1-Serial1/0/0]ip address 10.1.12.1 24 [R1-Serial1/0/0]quit [R1]interface Serial 3/0/0 [R1-Serial3/0/0]ip address 10.1.14.1 24 [R1-Serial3/0/0]quit [R1]interface LoopBack 0 [R1-LoopBack0]ip address 1.1.1.1 32 system-view [R2]interface Serial 1/0/0 [R2-Serial1/0/0]ip address 10.1.12.2 24 [R2-Serial1/0/0]quit [R2]interface Serial 2/0/0 [R2-Serial2/0/0]ip address 10.1.23.2 24 [R1-Serial2/0/0]quit [R2]interface LoopBack 0 [R2-LoopBack0]ip address 2.2.2.2 32 system-view [R3]interface Serial 2/0/0 [R3-Serial2/0/0]ip address 10.1.23.3 24 [R3-Serial2/0/0]quit [R3]interface Serial 3/0/0 [R3-Serial3/0/0]ip address 10.1.35.3 24 [R3-Serial3/0/0]quit [R3]interface LoopBack 0 [R3-LoopBack0]ip address 3.3.3.3 32 system-view [R4]interface Serial 1/0/0 [R4-Serial1/0/0]ip address 10.1.14.4 24 [R4-Serial1/0/0]quit [R4]interface LoopBack 0 [R4-LoopBack0]ip address 192.168.1.1 24 system-view [R5]interface Serial 1/0/0 [R5-Serial1/0/0]ip address 10.1.35.5 24 [R5-Serial1/0/0]quit [R5]interface LoopBack 0 [R5-LoopBack0]ip address 192.168.2.1 24 配置完成后,请自行测试直连链路的连通性。 步骤二. 配置运营商网络单区域OSPF 配置10.0.12.0/24、10.0.23.0/24两个网段以及运营商网络设备的LoopBack0接口属于OSPF Area0。 [R1]router id 1.1.1.1 [R1]ospf 1 [R1-ospf-1]area 0 [R1-ospf-1-area-0.0.0.0]network 10.1.12.0 0.0.0.255 [R1-ospf-1-area-0.0.0.0]network 1.1.1.1 0.0.0.0 [R2]router id 2.2.2.2 [R2]ospf 1 [R2-ospf-1]area 0 [R2-ospf-1-area-0.0.0.0]network 10.1.12.0 0.0.0.255 [R2-ospf-1-area-0.0.0.0]network 10.1.23.0 0.0.0.255 [R2-ospf-1-area-0.0.0.0]network 2.2.2.2 0.0.0.0 [R3]router id 3.3.3.3 [R3]ospf 1 [R3-ospf-1]area 0 [R3-ospf-1-area-0.0.0.0]network 10.1.23.0 0.0.0.255 [R3-ospf-1-area-0.0.0.0]network 3.3.3.3 0.0.0.0 配置完成后,分别在R1,R2与R3上查看OSPF邻居关系的建立情况。 步骤三. 配置运营商网络边缘设备的VPN实例 在R1与R3上分别为客户A网络与客户B网络配置VPN实例。分配客户A网络的VPN实例为VPN1,RD值为1:1,Export Target与Import Target为1:2;分配给客户B网络的VPN实例为VPN2,RD值为2:2,Export Target与Import Target为1:2。 [R1]ip vpn-instance VPN1 [R1-vpn-instance-VPN1]route-distinguisher 1:1 [R1-vpn-instance-VPN1-af-ipv4]vpn-target 1:2 both [R1-vpn-instance-VPN1-af-ipv4]quit [R1-vpn-instance-VPN1]quit [R1]interface Serial 3/0/0 [R1-Serial3/0/0]ip binding vpn-instance VPN1 Info: All IPv4 related configurations on this interface are removed! Info: All IPv6 related configurations on this interface are removed! [R1-Serial3/0/0] ip address 10.1.14.1 24 [R3]ip vpn-instance VPN2 [R3-vpn-instance-VPN2]route-distinguisher 2:2 [R3-vpn-instance-VPN2-af-ipv4]vpn-target 1:2 both [R3-vpn-instance-VPN2-af-ipv4]quit [R3-vpn-instance-VPN2]quit [R3]interface Serial 3/0/0 [R3-Serial3/0/0]ip binding vpn-instance VPN2 Info: All IPv4 related configurations on this interface are removed! Info: All IPv6 related configurations on this interface are removed! [R3-Serial3/0/0]ip address 10.1.35.3 24 配置完成后,分别在R1与R3上查看配置的VPN实例。 步骤四. 配置客户网络边缘设备与运营商网络边缘设备使用BGP协议传递路由 客户A网络的AS号为14,运营商网络的AS号为123,客户B网络的AS号为35。客户网络边缘设备与运营商网络边缘设备建立BGP的邻居关系,使客户私网路由通过BGP协议通告给运营商网络边缘设备。 [R4]bgp 14 [R4-bgp]peer 10.1.14.1 as-number 123 [R4-bgp]network 192.168.1.0 24 [R1]bgp 123 [R1-bgp]ipv4-family vpn-instance VPN1 [R1-bgp-VPN1]peer 10.1.14.4 as-number 14 [R3]bgp 123 [R3-bgp]ipv4-family vpn-instance VPN2 [R3-bgp-VPN2]peer 10.1.35.5 as-number 35 [R5]bgp 35 [R5-bgp]peer 10.1.35.3 as-number 123 [R5-bgp]network 192.168.2.0 24 配置完成后,分别在R1与R4,R3与R5上查看BGP邻居关系的建立情况。 分别在R1与R3上查看VPN路由表学到的客户网络的私网路由。 步骤五. 配置运营商网络设备使用MP-BGP协议传递客户的私网路由 在R1与R3之间采用MP-BGP协议传递客户的私网路由。 [R1]bgp 123 [R1-bgp]peer 3.3.3.3 as-number 123 [R1-bgp]peer 3.3.3.3 connect-interface LoopBack 0 [R1-bgp]ipv4-family vpnv4 unicast [R1-bgp-af-vpnv4]peer 3.3.3.3 enable [R3]bgp 123 [R3-bgp]peer 1.1.1.1 as-number 123 [R3-bgp]peer 1.1.1.1 connect-interface LoopBack 0 [R3-bgp]ipv4-family vpnv4 unicast [R3-bgp-af-vpnv4]peer 1.1.1.1 enable 配置完成后,分别在R1与R3上查看MP-BGP邻居关系的建立情况。 步骤六. 配置运营商网络设备使用MPLS LDP协议转发客户的私网数据 在运营商网络的所有设备上开启MPLS LDP协议,使用标签转发客户网络的私网数据。 R1]mpls lsr-id 1.1.1.1 [R1]mpls [R1-mpls]mpls ldp [R1-mpls-ldp]quit [R1]interface Serial 1/0/0 [R1-Serial1/0/0]mpls [R1-Serial1/0/0]mpls ldp [R2]mpls lsr-id 2.2.2.2 [R2]mpls [R2-mpls]mpls ldp [R2-mpls-ldp]quit [R2]interface s1/0/0 [R2-Serial1/0/0]mpls [R2-Serial1/0/0]mpls ldp [R2-Serial1/0/0]quit [R2]interface s2/0/0 [R2-Serial2/0/0]mpls [R2-Serial2/0/0]mpls ldp [R3]mpls lsr-id 3.3.3.3 [R3]mpls [R3-mpls]mpls ldp [R3-mpls-ldp]quit [R3]interface Serial 2/0/0 [R3-Serial2/0/0]mpls [R3-Serial2/0/0]mpls ldp 配置完成后,分别在R1,R2与R3上查看MPLS LDP邻居关系的建立情况。 步骤七. 在客户网络边缘设备上检查A网络与B网络的连通性 分别在R4与R5上使用LoopBack0模拟客户网络的用户,使用Ping命令检查A网络与B网络的连通性。 分别在R4与R5上查看路由表学习到的对端客户网络的私网路由。