拓扑如下:

 

MPLS 排错之LDP邻居无法建立(原创)_MPLS

 

192.168.1.1/24与192.168.2.1/24同属于vrf vpna

CEI上的主要配置如下:

interface Loopback0
ip address 192.168.1.1 255.255.255.0

 

interface Serial1/1
 ip address 10.10.11.1 255.255.255.252
 serial restart-delay 0

 

ip route 0.0.0.0 0.0.0.0 10.10.11.2

 

CE2的主要配置如下:

interface Loopback0
 ip address 192.168.2.1 255.255.255.0

interface Serial1/0
 ip address 10.10.22.1 255.255.255.252
 serial restart-delay 0

ip route 0.0.0.0 0.0.0.0 10.10.22.2

 

PE1与PE2的主要配置如下:

PE1:

 

ip vrf vpna
 rd 64512:0
 route-target export 64512:0
 route-target import 64512:0   // 定义×××,名字为vpna 并设定其路由标识符,并指定哪些路由可以被输入或输出 vpna

 

ip cef   //开启CEF
no tag-switching ip propagate-ttl  //禁止通告TTL,在×××网络中隐藏骨干网路由


interface Loopback0
 ip address 2.2.2.2 255.255.255.255 //定义环回口,用来建立BGP邻居,以及建立LDP/TDP邻居,作为LDP/TDP-ID来使用

interface Serial1/0
 ip vrf forwarding vpna  //将指定接口绑定到vpna,通过S1/0的数据将属于vpna
 ip address 10.10.11.2 255.255.255.252
 serial restart-delay 0
 clock rate 64000
!
interface Serial1/1
 ip address 200.0.12.1 255.255.255.252
 mpls label protocol ldp  //指定MPLS标签交换的协议为LDP,思科默认为TDP
 tag-switching ip   //在与P路由器相连的所有接口启用MPLS,使用MPLS ip 命令
 serial restart-delay 0
 clock rate 64000

 

router ospf 100   //启用OSPF路由,为BGP建立邻居关系打好通道
 router-id 2.2.2.2 //指定router-id 如不指定使用最大的环回口IP,如果环回口IP掩码设为24位,会导致LDP邻居无法建立
 log-adjacency-changes
 network 2.2.2.2 0.0.0.0 area 0 //通告环回口
 network 200.0.12.0 0.0.0.3 area 0
!
router bgp 64512  //启用BGP
 no synchronization  //默认是关闭同步的
 bgp router-id 2.2.2.2   //最好手工指定为环回口的IP
 bgp log-neighbor-changes
 neighbor 4.4.4.4 remote-as 64512  //与PE2建立邻居

 neighbor 4.4.4.4 update-source Loopback0 //并指定更新源
 no auto-summary  //默认是自动汇总的,有些IOS例外,所以先要关闭同步,再关闭汇总 


 address-family vpnv4  //定义vpnv4地址簇
 neighbor 4.4.4.4 activate //在该簇激活邻居
 neighbor 4.4.4.4 send-community extended  // 发送community 扩展,即RD
 exit-address-family
 !
 address-family ipv4 vrf vpna  //定义ipv4 vrf vpna 地址簇
 redistribute connected   // 将直连网段发布到vpna中
 redistribute static      // 将静太路由发布到vpna中
 no auto-summary     // 关闭汇总
 no synchronization   // 关闭同步
 exit-address-family
!
ip classless
ip route vrf vpna 192.168.1.0 255.255.255.0 10.10.11.1  //指定vrf vpna 路由,此路由会把重发布到BGP中,发送到PE2

PE2配置与上面一样,只需要更换相关参数即可。

P路由器上只需要启用OSPF即可

interface Loopback0
 ip address 3.3.3.3 255.255.255.255 //如果先配置环回口后配置LDP,那么一定要把环回口在OSPF中通告出去,不然LDP邻居无法建立,如果反过来,即可以不用发布,LDP/TDP会使用接口IP为Peer IP。(这就是因为这个原来,配置都配好了,检查了很多东西都正常就是LDP邻居无法建立。)

interface Serial1/0
 ip address 200.0.12.2 255.255.255.252
 mpls label protocol ldp
 tag-switching ip
 serial restart-delay 0
!
interface Serial1/1
 ip address 200.0.21.2 255.255.255.252
 mpls label protocol ldp
 tag-switching ip
 serial restart-delay 0

 

router ospf 100
 log-adjacency-changes
 network 3.3.3.3 0.0.0.0 area 0
 network 200.0.12.0 0.0.0.3 area 0
 network 200.0.21.0 0.0.0.3 area 0