A-A+

cisco路由器的MPLS和VPN的配置思路、方法和脚本

2015年11月18日 站长资讯 暂无评论

下面以几个cisco7206路由器的组网实验来讲解mpls和vpn的配置方法,并且说明思路和列出所有的配置脚本。主要给大家介绍路由器设备的互联、地址的规划、VPN的规划和IGP路由协议。

一般资料介绍跨域MPLS/VPN OPTION_B时,采用两个AS,为加深理解,本例采用三个AS,其中中间AS300为传送AS,不启MPLS标签交换,只通过MP—EBGP传送VPNV4的私网路由。实验中模拟路由器均采用Cisco 7206。

数据规划:

1、设备互联:

Router1 S1/0 <----> Router2 S1/0

Router2 F0/0 <----> Router3 F0/0

Router3 S1/1 <----> Router4 S1/1

Router4 F0/0 <----> Router5 F0/0

Router5 S1/1 <----> Router6 S1/1

2、地址规划:设备互连地址10.10.XY.X/24(R1中X=1,R1与R2互联Y=2,其余类推)。

Loopback 0 地址为:X.X.X.X/32

VPN地址:

R1中Vpna:172.16.1.1/24

Vpnb: 192.168.1.1/24

R6中Vpna:172.16.2.1/24

Vpnb: 192.168.2.1/24

3、VPN规划:在R1和R6中采用loopback 11 /loopback22模拟VPNA和VPNB,简化了PE—CE间配置。

VPNA: RD 100:10

ROUTE-TARGET 100:10

VPNB:RD 100:20

ROUTE-TARGET 100:20

4、IGP路由协议:AS120采用OSPF,AS456采用ISIS。

配置基本思路:

1、在完成IGP等基本配置后,在所有PE设备和P设备上启用IP CEF。

2、在所有PE设备和P设备上启用MPLS IP。

3、AS120/AS456中PE和ASBR建立BGP邻居关系。

4、PE中创建VPN,并在PE—CE间接口使能VRF FORWARDING。

5、PE中BGP IPV4 VRF 地址族中发布VPN路由。

6、AS120/AS456中PE和ASBR建立BGP VPNV4邻居关系,交换VPN路由信息。

7、AS120/AS456中ASBR分别和传送区域AS300中ASBR建立VPNV4邻居关系,传送VPNV4路由。(注意:AS300中的R3与R1或R6之间并没有IPV4的路由,在由R2和R4向R3发送VPN路由时,必须把收到的R1和R6 的VPN路由的下一跳强制指向自己,使用next-hop self命令,否则R3会认为该路由不可达,从而丢弃。)
8、要允许的ASBR接受所有的VPNV4前缀,必须禁用缺省的ARF。可以通过在所有的VPNV4 ASBR上配置no bgp default route-target filter来完成。

配置脚本如下:

  1. R1#show run  
  2. Building configuration...  
  3. Current configuration : 1985 bytes  
  4. !  
  5. version 12.0  
  6. service timestamps debug uptime  
  7. service timestamps log uptime  
  8. no service password-encryption  
  9. !  
  10. hostname R1  
  11. !  
  12. boot-start-marker  
  13. boot-end-marker  
  14. !  
  15. !  
  16. ip subnet-zero  
  17. !  
  18. !  
  19. ip cef  
  20. ip vrf vpna  
  21.  rd 100:10  
  22.  route-target export 100:10  
  23.  route-target import 100:10  
  24. !  
  25. ip vrf vpnb  
  26.  rd 100:20  
  27.  route-target export 100:20  
  28.  route-target import 100:20  
  29. !  
  30. mpls label range 100 199  
  31. mpls label protocol ldp  
  32. tag-switching tdp router-id Loopback0 force  
  33. !  
  34. !  
  35. !  
  36. interface Loopback0  
  37.  ip address 1.1.1.1 255.255.255.255   
  38.  no ip directed-broadcast  
  39. !  
  40. interface Loopback11  
  41.  ip vrf forwarding vpna  
  42.  ip address 172.16.1.1 255.255.255.0  
  43.  no ip directed-broadcast  
  44. !  
  45. interface Loopback22  
  46.  ip vrf forwarding vpnb  
  47.  ip address 192.168.1.1 255.255.255.0  
  48.  no ip directed-broadcast  
  49. !  
  50. interface FastEthernet0/0  
  51.  no ip address  
  52.  no ip directed-broadcast  
  53.  shutdown  
  54. !  
  55. interface Serial1/0  
  56.  ip address 10.10.12.1 255.255.255.0  
  57.  no ip directed-broadcast  
  58.  tag-switching ip  
  59. !  
  60. interface Serial1/1  
  61.  no ip address  
  62.  no ip directed-broadcast  
  63.  shutdown  
  64. !  
  65. interface Serial1/2  
  66.  no ip address  
  67.  no ip directed-broadcast  
  68.  shutdown  
  69. !  
  70. interface Serial1/3  
  71.  no ip address  
  72.  no ip directed-broadcast  
  73.  shutdown  
  74. !  
  75. router ospf 1   
  76.  log-adjacency-changes  
  77.  passive-interface Loopback0  
  78.  network 1.1.1.1 0.0.0.0 area 0  
  79.  network 10.10.12.0 0.0.0.255 area 0  
  80. !  
  81. router bgp 120  
  82.  no synchronization  
  83.  bgp router-id 1.1.1.1  
  84.  bgp log-neighbor-changes  
  85.  neighbor 2.2.2.2 remote-as 120  
  86.  neighbor 2.2.2.2 update-source Loopback0  
  87.  neighbor 2.2.2.2 send-label explicit-null  
  88.  no auto-summary  
  89.  !  
  90.  address-family vpnv4  
  91.  neighbor 2.2.2.2 activate  
  92.  neighbor 2.2.2.2 send-community extended  
  93.  exit-address-family  
  94.  !          
  95.  address-family ipv4 vrf vpnb  
  96.  redistribute connected  
  97.  no auto-summary  
  98.  no synchronization  
  99.  exit-address-family  
  100.  !  
  101.  address-family ipv4 vrf vpna  
  102.  redistribute connected  
  103.  no auto-summary  
  104.  no synchronization  
  105.   
  106.   
  107.  exit-address-family  
  108. !  
  109. ip classless  
  110. !  
  111. !  
  112. !  
  113. control-plane  
  114. !  
  115. !  
  116. line con 0  
  117.  stopbits 1  
  118. line aux 0  
  119.  stopbits 1  
  120. line vty 0 4  
  121.  login  
  122. !  
  123. no cns aaa enable  
  124. end  
  125. R1#  
  126. R2>en  
  127. R2#show run  
  128. Building configuration...  
  129. Current configuration : 1540 bytes  
  130. !  
  131. version 12.0  
  132. service timestamps debug uptime  
  133. service timestamps log uptime  
  134. no service password-encryption  
  135. !  
  136. hostname R2  
  137. !  
  138. boot-start-marker  
  139. boot-end-marker  
  140. !  
  141. !  
  142. ip subnet-zero  
  143. !  
  144. !  
  145. ip cef  
  146. mpls label range 200 299  
  147. mpls label protocol ldp  
  148. tag-switching tdp router-id Loopback0 force  
  149. !  
  150. !  
  151. !           
  152. interface Loopback0  
  153.  ip address 2.2.2.2 255.255.255.255  
  154.  no ip directed-broadcast  
  155. !  
  156. interface FastEthernet0/0  
  157.  ip address 10.10.23.2 255.255.255.0  
  158.  no ip directed-broadcast  
  159.  mpls bgp forwarding  
  160. !  
  161. interface Serial1/0  
  162.  ip address 10.10.12.2 255.255.255.0  
  163.  no ip directed-broadcast  
  164.  tag-switching ip  
  165.   
  166.   
  167. !  
  168. interface Serial1/1  
  169.  no ip address  
  170.  no ip directed-broadcast  
  171.  shutdown  
  172. !  
  173. interface Serial1/2  
  174.  no ip address  
  175.  no ip directed-broadcast  
  176.  shutdown   
  177. !  
  178. interface Serial1/3  
  179.  no ip address  
  180.  no ip directed-broadcast  
  181.  shutdown  
  182. !  
  183. router ospf 1  
  184.  log-adjacency-changes  
  185.  passive-interface Loopback0  
  186.  network 2.2.2.2 0.0.0.0 area 0  
  187.  network 10.10.12.0 0.0.0.255 area 0  
  188. !  
  189. router bgp 120  
  190.  no synchronization  
  191.  bgp router-id 2.2.2.2  
  192.  no bgp default route-target filter  
  193.  bgp log-neighbor-changes  
  194.  neighbor 1.1.1.1 remote-as 120  
  195.  neighbor 1.1.1.1 update-source Loopback0  
  196.  neighbor 10.10.23.3 remote-as 300  
  197.  no auto-summary  
  198.  !  
  199.  address-family vpnv4  
  200.  neighbor 1.1.1.1 activate  
  201.  neighbor 1.1.1.1 send-community extended   
  202.  neighbor 1.1.1.1 next-hop-self  
  203.  neighbor 10.10.23.3 activate  
  204.  neighbor 10.10.23.3 send-community extended  
  205.  exit-address-family  
  206. !  
  207. ip classless  
  208. !  
  209. !  
  210. !  
  211. control-plane  
  212. !  
  213. !  
  214. line con 0  
  215.  stopbits 1  
  216. line aux 0  
  217.  stopbits 1  
  218. line vty 0 4  
  219.  login  
  220. !  
  221. no cns aaa enable  
  222. end         
  223. R2#  
  224. R3#show run  
  225. Building configuration...  
  226. Current configuration : 1245 bytes  
  227. !  
  228. version 12.0  
  229. service timestamps debug uptime  
  230. service timestamps log uptime  
  231. no service password-encryption  
  232. !  
  233. hostname R3  
  234. !  
  235. boot-start-marker  
  236. boot-end-marker  
  237. !  
  238. !  
  239. ip subnet-zero  
  240. !  
  241. !  
  242. ip cef  
  243. no tag-switching ip  
  244. !  
  245. !  
  246. !  
  247. interface Loopback0  
  248.  ip address 3.3.3.3 255.255.255.255  
  249.  no ip directed-broadcast   
  250. !  
  251. interface FastEthernet0/0  
  252.  ip address 10.10.23.3 255.255.255.0  
  253.  no ip directed-broadcast  
  254.  mpls bgp forwarding  
  255. !  
  256. interface Serial1/0  
  257.  no ip address  
  258.  no ip directed-broadcast  
  259.  shutdown  
  260. !  
  261. interface Serial1/1  
  262.  ip address 10.10.34.3 255.255.255.0  
  263.  no ip directed-broadcast  
  264.  mpls bgp forwarding  
  265. !  
  266. interface Serial1/2  
  267.  no ip address  
  268.  no ip directed-broadcast  
  269.  shutdown  
  270. !  
  271. interface Serial1/3  
  272.  no ip address  
  273.  no ip directed-broadcast  
  274.  shutdown  
  275. !  
  276. router bgp 300  
  277.  no synchronization  
  278.  no bgp default route-target filter  
  279.  bgp log-neighbor-changes  
  280.  neighbor 10.10.23.2 remote-as 120  
  281.  neighbor 10.10.34.4 remote-as 456  
  282.  no auto-summary  
  283.  !  
  284.  address-family vpnv4  
  285.  neighbor 10.10.23.2 activate   
  286.  neighbor 10.10.23.2 send-community extended  
  287.  neighbor 10.10.34.4 activate  
  288.  neighbor 10.10.34.4 send-community extended  
  289.  exit-address-family  
  290. !  
  291. ip classless  
  292. !  
  293. !  
  294. !           
  295. control-plane  
  296. !  
  297. !  
  298. line con 0  
  299.  stopbits 1  
  300. line aux 0  
  301.  stopbits 1  
  302. line vty 0 4  
  303.  login  
  304. !  
  305. no cns aaa enable  
  306. end  
  307. R3#  
  308. R4#show run  
  309. Building configuration...  
  310. Current configuration : 1517 bytes  
  311. !  
  312. version 12.0  
  313. service timestamps debug uptime  
  314. service timestamps log uptime  
  315. no service password-encryption  
  316. !  
  317. hostname R4  
  318. !  
  319. boot-start-marker  
  320. boot-end-marker  
  321. !  
  322. !  
  323. ip subnet-zero  
  324. !  
  325. !  
  326. ip cef  
  327. mpls label range 400 499  
  328. mpls label protocol ldp  
  329. tag-switching tdp router-id Loopback0 force  
  330. !   
  331. !  
  332. !           
  333. interface Loopback0  
  334.  ip address 4.4.4.4 255.255.255.255  
  335.  no ip directed-broadcast  
  336. !  
  337. interface FastEthernet0/0  
  338.  ip address 10.10.45.4 255.255.255.0  
  339.  no ip directed-broadcast  
  340.  tag-switching ip  
  341. !  
  342. interface Serial1/0  
  343.  no ip address  
  344.  no ip directed-broadcast  
  345.  shutdown  
  346. !  
  347. interface Serial1/1  
  348.  ip address 10.10.34.4 255.255.255.0  
  349.  no ip directed-broadcast  
  350.  mpls bgp forwarding  
  351. !  
  352. interface Serial1/2  
  353.  no ip address  
  354.  no ip directed-broadcast  
  355.  shutdown   
  356. !  
  357. interface Serial1/3  
  358.  no ip address  
  359.  no ip directed-broadcast  
  360.  shutdown  
  361. !  
  362. router ospf 1  
  363.  log-adjacency-changes  
  364.  passive-interface Loopback0  
  365.  network 4.4.4.4 0.0.0.0 area 0  
  366.  network 10.10.45.0 0.0.0.255 area 0   
  367. !  
  368. router bgp 456  
  369.  no synchronization  
  370.  no bgp default route-target filter  
  371.  bgp log-neighbor-changes  
  372.  neighbor 6.6.6.6 remote-as 456  
  373.  neighbor 6.6.6.6 update-source Loopback0  
  374.  neighbor 10.10.34.3 remote-as 300  
  375.  no auto-summary  
  376.  !  
  377.  address-family vpnv4  
  378.  neighbor 6.6.6.6 activate  
  379.  neighbor 6.6.6.6 send-community extended  
  380.  neighbor 6.6.6.6 next-hop-self  
  381.  neighbor 10.10.34.3 activate  
  382.  neighbor 10.10.34.3 send-community extended  
  383.  exit-address-family  
  384. !  
  385. ip classless  
  386. !  
  387. !  
  388. !  
  389. control-plane  
  390. !  
  391. !  
  392. line con 0  
  393.  stopbits 1  
  394. line aux 0  
  395.  stopbits 1  
  396. line vty 0 4  
  397.  login  
  398. !  
  399. no cns aaa enable  
  400. end  
  401.             
  402. R4#   
  403. R5#show run  
  404. Building configuration...   
  405. Current configuration : 1098 bytes  
  406. !  
  407. version 12.0  
  408. service timestamps debug uptime  
  409. service timestamps log uptime  
  410. no service password-encryption  
  411. !  
  412. hostname R5  
  413. !  
  414. boot-start-marker  
  415. boot-end-marker  
  416. !  
  417. !  
  418. ip subnet-zero  
  419. !  
  420. !  
  421. ip cef  
  422. mpls label range 500 599  
  423. mpls label protocol ldp  
  424. tag-switching tdp router-id Loopback0  
  425. !  
  426. !  
  427. !           
  428. interface Loopback0  
  429.  ip address 5.5.5.5 255.255.255.255  
  430.  no ip directed-broadcast  
  431. !  
  432. interface FastEthernet0/0  
  433.  ip address 10.10.45.5 255.255.255.0  
  434.  no ip directed-broadcast  
  435.  tag-switching ip  
  436. !  
  437. interface Serial1/0  
  438.  no ip address  
  439.  no ip directed-broadcast  
  440.  shutdown  
  441. !  
  442. interface Serial1/1  
  443.  ip address 10.10.56.5 255.255.255.0  
  444.  no ip directed-broadcast   
  445.  tag-switching ip  
  446. !  
  447. interface Serial1/2  
  448.  no ip address  
  449.  no ip directed-broadcast  
  450.  shutdown   
  451. !  
  452. interface Serial1/3  
  453.  no ip address  
  454.  no ip directed-broadcast  
  455.  shutdown  
  456. !  
  457. router ospf 1  
  458.  log-adjacency-changes  
  459.  passive-interface Loopback0  
  460.  network 5.5.5.5 0.0.0.0 area 0  
  461.  network 10.10.45.0 0.0.0.255 area 0  
  462.  network 10.10.56.0 0.0.0.255 area 0  
  463. !  
  464. ip classless  
  465. !  
  466. !  
  467. !  
  468. control-plane  
  469. !  
  470. !  
  471. line con 0  
  472.  stopbits 1  
  473. line aux 0  
  474.  stopbits 1  
  475. line vty 0 4  
  476.  login  
  477. !  
  478. no cns aaa enable  
  479. end  
  480. R5#         
  481. R6#show run  
  482. Building configuration...  
  483. Current configuration : 1962 bytes  
  484. !  
  485. version 12.0  
  486. service timestamps debug uptime  
  487. service timestamps log uptime   
  488. no service password-encryption  
  489. !  
  490. hostname R6  
  491. !  
  492. boot-start-marker  
  493. boot-end-marker  
  494. !  
  495. !  
  496. ip subnet-zero  
  497. !  
  498. !  
  499. ip cef  
  500. ip vrf vpna  
  501.  rd 100:10  
  502.  route-target export 100:10  
  503.  route-target import 100:10  
  504. !  
  505. ip vrf vpnb  
  506.  rd 100:20  
  507.  route-target export 100:20  
  508.  route-target import 100:20  
  509. !  
  510. mpls label range 600 699  
  511. mpls label protocol ldp  
  512. tag-switching tdp router-id Loopback0 force  
  513. !  
  514. !  
  515. !  
  516. interface Loopback0  
  517.  ip address 6.6.6.6 255.255.255.255  
  518.  no ip directed-broadcast  
  519. !  
  520. interface Loopback11  
  521.  ip vrf forwarding vpna  
  522.  ip address 172.16.2.1 255.255.255.0  
  523.  no ip directed-broadcast  
  524. !  
  525. interface Loopback22  
  526.  ip vrf forwarding vpnb  
  527.  ip address 192.168.2.1 255.255.255.0  
  528.  no ip directed-broadcast   
  529. !  
  530. interface FastEthernet0/0  
  531.  no ip address  
  532.  no ip directed-broadcast  
  533.  shutdown  
  534. !  
  535. interface Serial1/0  
  536.  no ip address  
  537.  no ip directed-broadcast  
  538.  shutdown  
  539. !  
  540. interface Serial1/1  
  541.  ip address 10.10.56.6 255.255.255.0  
  542.  no ip directed-broadcast  
  543.  tag-switching ip  
  544. !  
  545. interface Serial1/2  
  546.  no ip address  
  547.  no ip directed-broadcast  
  548.  shutdown  
  549. !  
  550. interface Serial1/3  
  551.  no ip address  
  552.  no ip directed-broadcast  
  553.  shutdown  
  554. !  
  555. router ospf 1  
  556.  log-adjacency-changes  
  557.  passive-interface Loopback0  
  558.  network 6.6.6.6 0.0.0.0 area 0  
  559.  network 10.10.56.0 0.0.0.255 area 0  
  560. !  
  561. router bgp 456  
  562.  no synchronization  
  563.  bgp log-neighbor-changes  
  564.  neighbor 4.4.4.4 remote-as 456  
  565.  neighbor 4.4.4.4 update-source Loopback0   
  566.  neighbor 4.4.4.4 send-label explicit-null  
  567.  no auto-summary  
  568.  !  
  569.  address-family vpnv4  
  570.  neighbor 4.4.4.4 activate  
  571.  neighbor 4.4.4.4 send-community extended  
  572.  exit-address-family  
  573.  !  
  574.  address-family ipv4 vrf vpnb  
  575.  redistribute connected  
  576.  no auto-summary  
  577.  no synchronization  
  578.  exit-address-family  
  579.  !  
  580.  address-family ipv4 vrf vpna  
  581.  redistribute connected  
  582.  no auto-summary  
  583.  no synchronization  
  584.  exit-address-family  
  585. !  
  586. ip classless  
  587. !  
  588. !  
  589. !  
  590. control-plane  
  591. !  
  592. !  
  593. line con 0  
  594.  stopbits 1  
  595. line aux 0  
  596.  stopbits 1  
  597. line vty 0 4  
  598.  login  
  599. !  
  600. no cns aaa enable  
  601. end  
  602. R6#            show run  
  603. Building configuration...  
  604. Current configuration : 1962 bytes   
  605. !  
  606. version 12.0  
  607. service timestamps debug uptime  
  608. service timestamps log uptime  
  609. no service password-encryption  
  610. !  
  611. hostname R6  
  612. !  
  613. boot-start-marker  
  614. boot-end-marker  
  615. !  
  616. !  
  617. ip subnet-zero  
  618. !  
  619. !  
  620. ip cef  
  621. ip vrf vpna  
  622.  rd 100:10  
  623.  route-target export 100:10  
  624.  route-target import 100:10  
  625. !  
  626. ip vrf vpnb  
  627.  rd 100:20  
  628.  route-target export 100:20  
  629.  route-target import 100:20  
  630. !  
  631. mpls label range 600 699  
  632. mpls label protocol ldp  
  633. tag-switching tdp router-id Loopback0 force  
  634. !  
  635. !  
  636. !  
  637. interface Loopback0  
  638.  ip address 6.6.6.6 255.255.255.255  
  639.  no ip directed-broadcast  
  640. !  
  641. interface Loopback11  
  642.  ip vrf forwarding vpna  
  643.  ip address 172.16.2.1 255.255.255.0  
  644.  no ip directed-broadcast  
  645. !  
  646. interface Loopback22  
  647.  ip vrf forwarding vpnb   
  648.  ip address 192.168.2.1 255.255.255.0  
  649.  no ip directed-broadcast  
  650. !  
  651. interface FastEthernet0/0  
  652.  no ip address  
  653.  no ip directed-broadcast  
  654.  shutdown  
  655. !  
  656. interface Serial1/0  
  657.  no ip address  
  658.  no ip directed-broadcast  
  659.  shutdown  
  660. !  
  661. interface Serial1/1  
  662.  ip address 10.10.56.6 255.255.255.0  
  663.  no ip directed-broadcast  
  664.  tag-switching ip  
  665. !  
  666. interface Serial1/2  
  667.  no ip address  
  668.  no ip directed-broadcast  
  669.  shutdown  
  670. !  
  671. interface Serial1/3  
  672.  no ip address  
  673.  no ip directed-broadcast  
  674.  shutdown  
  675. !  
  676. router ospf 1  
  677.  log-adjacency-changes  
  678.  passive-interface Loopback0  
  679.  network 6.6.6.6 0.0.0.0 area 0  
  680.  network 10.10.56.0 0.0.0.255 area 0  
  681. !  
  682. router bgp 456  
  683.  no synchronization  
  684.  bgp log-neighbor-changes   
  685.  neighbor 4.4.4.4 remote-as 456  
  686.  neighbor 4.4.4.4 update-source Loopback0  
  687.  neighbor 4.4.4.4 send-label explicit-null  
  688.  no auto-summary  
  689.  !  
  690.  address-family vpnv4  
  691.  neighbor 4.4.4.4 activate  
  692.  neighbor 4.4.4.4 send-community extended  
  693.  exit-address-family  
  694.  !  
  695.  address-family ipv4 vrf vpnb  
  696.  redistribute connected  
  697.  no auto-summary  
  698.  no synchronization  
  699.  exit-address-family  
  700.  !  
  701.  address-family ipv4 vrf vpna  
  702.  redistribute connected  
  703.  no auto-summary  
  704.  no synchronization  
  705.  exit-address-family  
  706. !  
  707. ip classless  
  708. !  
  709. !  
  710. !  
  711. control-plane  
  712. !  
  713. !  
  714. line con 0  
  715.  stopbits 1  
  716. line aux 0  
  717.  stopbits 1  
  718. line vty 0 4  
  719.  login  
  720. !  
  721. no cns aaa enable  
  722. end  
  723. R6#  
标签:

给我留言