ÔÚ»ªÎªÉ豸ÖÐÅäÖÃHub&Spoke(ÖáÐÄ·½Ê½ÍØÆË) ÏÂÔØ±¾ÎÄ

ÔÚ»ªÎªÉ豸ÖÐÅäÖÃHub&Spoke

ËùÊôÀà±ð£ºÍøÂç¼¼Êõ

ÔÚ»ªÎªÉ豸ÖÐÅäÖÃHub&Spoke Èç¹ûÏ£ÍûÔÚVPNÖÐÉèÖÃÖÐÐÄ·ÃÎÊ¿ØÖÆÉ豸£¬ÆäËüÓû§µÄ»¥·Ã¶¼Í¨¹ýÖÐÐÄ·ÃÎÊ¿ØÖÆÉ豸½øÐУ¬¿ÉÒÔʹÓÃHub&Spoke×éÍø·½°¸£¬Ê¹µÃSpokeÕ¾µãÖ®¼äµÄͨÐÅͨ¹ýHubÕ¾µã½øÐС£ÆäÖУ¬ÖÐÐÄ·ÃÎÊ¿ØÖÆÉ豸ËùÔÚÕ¾µã³ÆÎªHubÕ¾µã£¬ÆäËûÓû§Õ¾µã³ÆÎªSpokeÕ¾µã¡£HubÕ¾µã²à½ÓÈëVPN¹Ç¸ÉÍøµÄÉ豸½ÐHub-CE£»SpokeÕ¾µã²à½ÓÈëVPN¹Ç¸ÉÍøµÄÉ豸½ÐSpoke-CE¡£VPN¹Ç¸ÉÍø²à½ÓÈëHubÕ¾µãµÄÉ豸½ÐHub-PE£¬½ÓÈëSpokeÕ¾µãµÄÉ豸½ÐSpoke-PE¡£ ÿ¸öSpoke-PEÉÏÅäÖÃÒ»¸öIPv6 VPNʵÀý£»Hub-PEÐèÅäÖÃÁ½¸öIPv6 VPNʵÀý£¨ÀýÈ磬vpn-inºÍvpn-out£©£ºvpn-inÓÃÓÚ½ÓÊÕ²¢Î¬»¤ËùÓÐSpoke-PE·¢²¼µÄVPN-IPv6·ÓÉ£»vpn-outÓÃÓÚά»¤HubÕ¾µã¼°ËùÓÐSpokeÕ¾µãµÄ·ÓÉ£¬²¢·¢²¼¸øËùÓÐSpoke-PE¡£Hub-PEÉÏÐèҪʹÓÃÁ½¸ö½Ó¿Ú»ò×Ó½Ó¿Ú£ºÒ»¸ö°ó¶¨vpn-in£¬ÁíÒ»¸ö°ó¶¨vpn-out¡£VPN-TargetµÄÅäÖùæÔòΪ£ºvpn-inµÄImport VPN-TargetÊôÐÔÁбí°üÀ¨ËùÓÐSpoke-PEµÄExport VPN-TargetÊôÐÔÖµ¡£vpn-outµÄExport

VPN-TargetÊôÐÔÁбí°üÀ¨ËùÓÐSpoke-PEµÄImport VPN-TargetÊôÐÔÖµ¡£vpn-outµÄExport VPN-TargetÊôÐÔÁбíÓëvpn-inµÄImport VPN-TargetÊôÐÔÁÐ±í²»ÄÜÓÐÏàͬÊôÐÔÖµ¡£vpn-outµÄImport VPN-TargetÊôÐÔÁбíÓëvpn-inµÄExport VPN-TargetÊôÐÔÁбíÒ²²»ÄÜÓÐÏàͬµÄÊôÐÔÖµ¡£½¨Òé²»ÅäÖÃvpn-inµÄExport VPN-TargetºÍvpn-outµÄImport VPN-Target¡£Ä¬ÈÏÇé¿öÏ£¬VPNʵÀýûÓÐExport VPN-TargetºÍImport VPN-TargetÊôÐÔ¡£Hub-PEÓëSpoke-PEÖ®¼ä½¨Á¢ËíµÀºÍIBGP¶ÔµÈÌå¹ØÏµ£»Spoke-PEÖ®¼ä²»½¨Á¢ËíµÀºÍIBGP¶ÔµÈÌå¹ØÏµ£¬²»½»»»VPN·ÓÉÐÅÏ¢¡£ ×¢ÒâVPN-TargetµÄÅäÖùæÔò¡£µ±Hub-CEÓëHub-PEÖ®¼äʹÓÃEBGPʱ£¬Hub-PEÉϱØÐëÊÖ¹¤ÅäÖÃÔÊÐí±¾µØAS±àºÅÖØ¸´£¨ÔÚBGP-VPNv4µØÖ·×åÊÓͼÏÂÅäÖÃÃüÁîpeer { ip-address group-name } allow-as-loop [ number ]£©¡£Èç¹ûSpoke-PEÓëSpoke-CEʹÓÃEBGP£¬ÔòHub-CEÓëHub-PE¿ÉÒÔʹÓÃEBGP»òĬÈÏ·ÓÉ£¬µ«²»ÄÜʹÓÃIGP¡£ÅäÖÃʵÀýÒ» ×éÍøÐèÇó ÈçÏÂͼ£¬Spoke-CEÖ®¼äµÄͨÐÅͨ¹ýÖÐÐÄÕ¾µãHub-CE¿ØÖÆ£¬¼´Spoke-CEÖ®¼äµÄÁ÷Á¿¾­¹ýHub-CEת·¢£¬¶ø²»ÊÇÖ»¾­¹ýHub-PEת·¢¡£ÒªÇóHub-CEÓëHub-PEÖ®¼ä£¬Spoke-PEÓëSpoke-CEÖ®¼ä¶¼Ê¹ÓÃEBGP½»»»Â·ÓÉÐÅÏ¢¡£ÊÊÓòúÆ·ºÍ°æ±¾ ²ÉÓÃNEϵÁзÓÉÆ÷£¬°æ±¾Îª£¨VRP5.30£©¼°ºóÐø°æ±¾¡£ËµÃ÷PE·ÓÉÆ÷ÍÆ¼ö²ÉÓÃNE80E¡¢NE40E¡¢NE80¡¢NE40¡¢NE20E¡¢NE20¡¢NE16E»òNE08E¡£CE·ÓÉÆ÷ÍÆ¼ö²ÉÓÃNE80¡¢NE40¡¢NE20E¡¢NE20¡¢NE16E¡¢NE08E»òNE05¡£ÅäÖò½Öè ²½Öè 1 ÔڹǸÉÍøÉÏÅäÖÃIGPЭÒ飬ʵÏֹǸÉÍøHub-PEºÍSpoke-PEµÄ»¥Í¨±¾ÀýÖвÉÓÃOSPF£¬¾ßÌåÅäÖùý³ÌÂÔ¡£ÅäÖÃÍê³Éºó£¬PEÖ®¼äÓ¦Äܽ¨Á¢OSPFÁÚ¾Ó¹ØÏµ£¬Ö´ÐÐdisplay ospf peerÃüÁî¿ÉÒÔ¿´µ½ÁÚ¾Ó״̬ΪFull¡£Ö´ÐÐdisplay ip routing-tableÃüÁî¿ÉÒÔ¿´µ½PEÖ®¼äѧϰµ½¶Ô·½µÄLoopback·ÓÉ¡£²½Öè 2 ÔڹǸÉÍøÉÏÅäÖÃMPLS»ù±¾ÄÜÁ¦ºÍMPLS LDP£¬½¨Á¢LDP LSP¾ßÌåÅäÖùý³ÌÂÔ¡£ÅäÖÃÍê³Éºó£¬Hub-PEºÍSpoke-PEÖ®¼äÓ¦¸Ã½¨Á¢ÆðLDP¶ÔµÈÌå¹ØÏµ£¬ÔÚ¸÷·ÓÉÆ÷ÉÏÖ´ÐÐdisplay mpls ldp sessionÃüÁî¿ÉÒÔ¿´µ½ÏÔʾ½á¹ûÖÐSession StateÏîΪ¡°Operational¡±¡£²½Öè 3 ÔÚ¸÷PE·ÓÉÆ÷ÉÏÅäÖÃVPNʵÀý£¬½«CE½ÓÈëPE˵Ã÷×¢ÒâHub-PEÓëSpoke-PEÉϵÄVPN TargetÊôÐÔÉèÖá£Hub-PEµÄÁ½¸öVPNʵÀýµÄVPN-target·Ö±ðΪÁ½¸öSpoke-PE·¢²¼µÄVPN-target£¬ÇÒ·¢²¼µÄVPN-targetÓë½ÓÊÕµÄVPN-target²»Í¬¡£Spoke-PEµÄVPNʵÀýÒýÈëµÄVPN-targetΪHub-PE·¢²¼µÄVPN-target¡£

# ÅäÖÃSpoke-PE1¡£

[Spoke-PE1] ip vpn-instance vpna

[Spoke-PE1-vpn-instance-vpna] route-distinguisher 100:1

[Spoke-PE1-vpn-instance-vpna] vpn-target 100:1 export-extcommunity [Spoke-PE1-vpn-instance-vpna] vpn-target 200:1 import-extcommunity

[Spoke-PE1-vpn-instance-vpna] quit[Spoke-PE1] interface gigabitethernet 1/0/0 [Spoke-PE1-GigabitEthernet1/0/0] ip binding vpn-instance vpna [Spoke-PE1-GigabitEthernet1/0/0] ip address 100.1.1.2 24

[Spoke-PE1-GigabitEthernet1/0/0] quit #ÅäÖÃSpoke-PE2¡£

[Spoke-PE2] ip vpn-instance vpna

[Spoke-PE2-vpn-instance-vpna] route-distinguisher 100:3

[Spoke-PE2-vpn-instance-vpna] vpn-target 100:1 export-extcommunity [Spoke-PE2-vpn-instance-vpna] vpn-target 200:1 import-extcommunity

[Spoke-PE2-vpn-instance-vpna] quit[Spoke-PE2] interface gigabitethernet 1/0/0 [Spoke-PE2-GigabitEthernet1/0/0] ip binding vpn-instance vpna [Spoke-PE2-GigabitEthernet1/0/0] ip address 120.1.1.2 24 [Spoke-PE2-GigabitEthernet1/0/0] quit # ÅäÖÃHub-PE¡£

[Hub-PE] ip vpn-instance vpn_in

[Hub-PE-vpn-instance-vpn_in] route-distinguisher 100:21

[Hub-PE-vpn-instance-vpn_in] vpn-target 100:1 import-extcommunity [Hub-PE-vpn-instance-vpn_in] quit[Hub-PE] ip vpn-instance vpn_out [Hub-PE-vpn-instance-vpn_out] route-distinguisher 100:22

[Hub-PE-vpn-instance-vpn_out] vpn-target 200:1 export-extcommunity

[Hub-PE-vpn-instance-vpn_out] quit[Hub-PE] interface gigabitethernet 3/0/0 [Hub-PE-GigabitEthernet3/0/0] ip binding vpn-instance vpn_in [Hub-PE-GigabitEthernet3/0/0] ip address 110.1.1.2 24

[Hub-PE-GigabitEthernet3/0/0] quit[Hub-PE] interface gigabitethernet 4/0/0 [Hub-PE-GigabitEthernet4/0/0] ip binding vpn-instance vpn_out [Hub-PE-GigabitEthernet4/0/0] ip address 110.2.1.2 24 [Hub-PE-GigabitEthernet4/0/0] quit#

°´Í¼1-1ÅäÖø÷CEµÄ½Ó¿ÚIPµØÖ·£¬ÅäÖùý³ÌÂÔ¡£ÅäÖÃÍê³Éºó£¬ÔÚPE·ÓÉÆ÷ÉÏÖ´ÐÐdisplay ip vpn-instance verboseÃüÁî¿ÉÒÔ¿´µ½VPNʵÀýµÄÅäÖÃÇé¿ö¡£¸÷PEÄÜÓÃÃüÁîping -vpn-instance vpn-name ip-address pingͨ×Ô¼º½ÓÈëµÄCE¡£ËµÃ÷µ±PEÉÏÓжà¸ö°ó¶¨ÁËͬһ¸öVPNµÄ½Ó¿Ú£¬ÔòʹÓÃping -vpn-instance ÃüÁîping¶Ô¶ËPE½ÓÈëµÄCEʱ£¬ÒªÖ¸¶¨Ô´IPµØÖ·£¬¼´ÒªÖ¸¶¨ping -vpn-instance vpn-instance-name -a source-ip-address dest-ip-addressÃüÁîÖеIJÎÊý-a source-ip-address£¬·ñÔò¿ÉÄÜping²»Í¨¡£²½Öè 4 ÔÚPEÓëCEÖ®¼ä½¨Á¢EBGP¶ÔµÈÌå¹ØÏµ£¬ÒýÈëVPN·ÓÉ˵Ã÷Hub-PEÉÏÐèÒªÅäÖÃÔÊÐíASºÅÖØ¸´Ò»´Î£¬ÒÔ½ÓÊÕHub-CE·¢²¼µÄ·ÓÉ¡£

# ÅäÖÃSpoke-CE1¡£ [Spoke-CE1] bgp 65410

[Spoke-CE1-bgp] peer 100.1.1.2 as-number 100 [Spoke-CE1-bgp] import-route direct [Spoke-CE1-bgp] quit # ÅäÖÃSpoke-PE1¡£ [Spoke-PE1] bgp 100

[Spoke-PE1-bgp] ipv4-family vpn-instance vpna [Spoke-PE1-bgp-vpna] peer 100.1.1.1 as-number 65410 [Spoke-PE1-bgp-vpna] import-route direct [Spoke-PE1-bgp-vpna] quit[Spoke-PE1-bgp] quit# ÅäÖÃSpoke-CE2¡£ [Spoke-CE2] bgp 65420

[Spoke-CE2-bgp] peer 120.1.1.2 as-number 100 [Spoke-CE2-bgp] import-route direct [Spoke-CE2-bgp] quit# ÅäÖÃSpoke-PE2¡£ [Spoke-PE2] bgp 100

[Spoke-PE2-bgp] ipv4-family vpn-instance vpna [Spoke-PE2-bgp-vpna] peer 120.1.1.1 as-number 65420 [Spoke-PE2-bgp-vpna] import-route direct [Spoke-PE2-bgp-vpna] quit [Spoke-PE2-bgp] quit# ÅäÖÃHub-CE¡£ [Hub-CE] bgp 65430

[Hub-CE-bgp] peer 110.1.1.2 as-number 100 [Hub-CE-bgp] peer 110.2.1.2 as-number 100 [Hub-CE-bgp] import-route direct [Hub-CE-bgp] quit# ÅäÖÃHub-PE¡£ [Hub-PE] bgp 100

[Hub-PE-bgp] ipv4-family vpn-instance vpn_in [Hub-PE-bgp-vpn_in] peer 110.1.1.1 as-number 65430 [Hub-PE-bgp-vpn_in] import-route direct [Hub-PE-bgp-vpn_in] quit

[Hub-PE-bgp] ipv4-family vpn-instance vpn_out [Hub-PE-bgp-vpn_out] peer 110.2.1.1 as-number 65430 [Hub-PE-bgp-vpn_out] peer 110.2.1.1 allow-as-loop 1 [Hub-PE-bgp-vpn_out] import-route direct [Hub-PE-bgp-vpn_out] quit [Hub-PE-bgp] quit

ÅäÖÃÍê³Éºó£¬ÔÚ¸÷PE·ÓÉÆ÷ÉÏÖ´ÐÐdisplay bgp vpnv4 all peerÃüÁ¿ÉÒÔ¿´µ½PEÓëCEÖ®¼äµÄBGP¶ÔµÈÌå¹ØÏµÒѽ¨Á¢£¬²¢´ïµ½Established״̬¡£²½Öè 5 ÔÚPEÖ®¼ä½¨Á¢MP-IBGP¶ÔµÈÌå¹ØÏµËµÃ÷Spoke-PEÉϲ»ÐèÒªÅäÖÃÔÊÐíASºÅÖØ¸´Ò»´Î£¬ÒòΪ·ÓÉÆ÷½ÓÊÕIBGP¶ÔµÈÌå·¢²¼µÄ·ÓÉʱ²¢²»¼ì²éÆäÖеÄAS-PATHÊôÐÔ¡£

# ÅäÖÃSpoke-PE1¡£ [Spoke-PE1] bgp 100

[Spoke-PE1-bgp] peer 2.2.2.9 as-number 100

[Spoke-PE1-bgp] peer 2.2.2.9 connect-interface loopback 1 [Spoke-PE1-bgp] ipv4-family vpnv4

[Spoke-PE1-bgp-af-vpnv4] peer 2.2.2.9 enable [Spoke-PE1-bgp-af-vpnv4] quit # ÅäÖÃSpoke-PE2¡£ [Spoke-PE2] bgp 100

[Spoke-PE2-bgp] peer 2.2.2.9 as-number 100

[Spoke-PE2-bgp] peer 2.2.2.9 connect-interface loopback 1 [Spoke-PE2-bgp] ipv4-family vpnv4

[Spoke-PE2-bgp-af-vpnv4] peer 2.2.2.9 enable [Spoke-PE2-bgp-af-vpnv4] quit# ÅäÖÃHub-PE¡£ [Hub-PE] bgp 100

[Hub-PE-bgp] peer 1.1.1.9 as-number 100

[Hub-PE-bgp] peer 1.1.1.9 connect-interface loopback 1 [Hub-PE-bgp] peer 3.3.3.9 as-number 100

[Hub-PE-bgp] peer 3.3.3.9 connect-interface loopback 1 [Hub-PE-bgp] ipv4-family vpnv4

[Hub-PE-bgp-af-vpnv4] peer 1.1.1.9 enable [Hub-PE-bgp-af-vpnv4] peer 3.3.3.9 enable [Hub-PE-bgp-af-vpnv4] quit

ÅäÖÃÍê³Éºó£¬ÔÚ¸÷PE·ÓÉÆ÷ÉÏÖ´ÐÐdisplay bgp peer»òdisplay bgp vpnv4 all peerÃüÁ¿ÉÒÔ¿´µ½PEÖ®¼äµÄBGP¶ÔµÈÌå¹ØÏµÒѽ¨Á¢£¬²¢´ïµ½Established״̬¡£ÑéÖ¤½á¹û Íê³ÉÉÏÊöÅäÖúó£¬Spoke-CEÖ®¼ä¿ÉÒÔÏ໥Pingͨ£¬Ê¹ÓÃTracert¿ÉÒÔ¿´µ½Spoke-CEÖ®¼äµÄÁ÷Á¿¾­¹ýHub-CEת·¢£¬Ò²¿ÉÒÔͨ¹ýPing½á¹ûÖеÄTTLÖµÍÆËãSpoke-CEÖ®¼ä¾­¹ýµÄת·¢É豸ÊýÄ¿¡£ ÒÔSpoke-CE1µÄÏÔʾΪÀý£º

[Spoke-CE1] ping 120.1.1.1 PING 120.1.1.1: 56 data bytes, press CTRL_C to break Reply from 120.1.1.1: bytes=56 Sequence=1 ttl=250 time=80 ms Reply from 120.1.1.1: bytes=56 Sequence=2 ttl=250 time=129 ms Reply from 120.1.1.1: bytes=56 Sequence=3 ttl=250 time=132 ms Reply from 120.1.1.1: bytes=56 Sequence=4 ttl=250 time=92 ms Reply from 120.1.1.1: bytes=56 Sequence=5 ttl=250 time=126 ms --- 120.1.1.1 ping statistics --- 5 packet(s) transmitted 5 packet(s) received 0.00% packet loss round-trip min/avg/max = 80/111/132 ms

[Spoke-CE1] tracert 120.1.1.1traceroute to 120.1.1.1(120.1.1.1) 30 hops max,40 bytes packet1 100.1.1.2 24 ms 19 ms 11 ms2 110.2.1.2 87 ms 60 ms 58 ms3 110.2.1.1 59 ms 27 ms 53 ms4 110.1.1.2 41 ms 34 ms 56 ms5 120.1.1.2 90 ms 66 ms 75 ms6 120.1.1.1 143 ms 96 ms 90 ms

ÔÚSpoke-CEÉÏÖ´ÐÐdisplay bgp routing-tableÃüÁ¿ÉÒÔ¿´µ½È¥Íù¶Ô¶ËSpoke-CEµÄBGP·ÓɵÄAS·¾¶ÖдæÔÚÖØ¸´µÄASºÅ¡£ ÒÔSpoke-CE1µÄÏÔʾΪÀý£º

[Spoke-CE1] display bgp routing-tableTotal Number of Routes: 6BGP Local router ID is 100.1.1.1Status codes: * - valid, > - best, d - damped, h - history, i - internal, s - suppressed, S - Stale Origin : i - IGP, e - EGP, ? - incomplete Network NextHop MED LocPrf PrefVal Path/Ogn*> 100.1.1.0/24 0.0.0.0 0 0 ?* 100.1.1.2 0 0 100?*> 100.1.1.1/32 0.0.0.0 0 0 ?*> 110.1.1.0/24 100.1.1.2 0 100 65430?*> 110.2.1.0/24 100.1.1.2 0 100?*> 120.1.1.0/24 100.1.1.2 0 100 65430 100?

ÅäÖÃÎļþ Hub-CEµÄÅäÖÃÎļþ#sysname Hub-CE#interface GigabitEthernet1/0/0ip address 110.1.1.1 255.255.255.0#interface GigabitEthernet2/0/0ip address 110.2.1.1 255.255.255.0#bgp 65430peer 110.1.1.2 as-number 100peer 110.2.1.2 as-number 100#ipv4-family unicast undo synchronization import-route direct peer 110.2.1.2 enable peer 110.1.1.2 enable#return

Hub-PEµÄÅäÖÃÎļþ#sysname Hub-PE#ip vpn-instance vpn_inroute-distinguisher 100:21vpn-target 100:1 import-extcommunity#ip vpn-instance vpn_outroute-distinguisher 100:22vpn-target 200:1 export-extcommunity#mpls lsr-id 2.2.2.9mpls lsp-trigger all#mpls ldp#interface GigabitEthernet3/0/0ip binding vpn-instance vpn_inip address 110.1.1.2 255.255.255.0#interface

GigabitEthernet4/0/0ip binding vpn-instance vpn_outip address 110.2.1.2 255.255.255.0#interface Pos1/0/0link-protocol pppip address 10.1.1.2

255.255.255.0mplsmpls ldp#interface Pos2/0/0link-protocol pppip address 11.1.1.2 255.255.255.0mplsmpls ldp#interface LoopBack1ip address 2.2.2.9

255.255.255.255#bgp 100peer 1.1.1.9 as-number 100peer 3.3.3.9 as-number 100peer 1.1.1.9 connect-interface LoopBack1peer 3.3.3.9 connect-interface

LoopBack1#ipv4-family unicast undo synchronization peer 1.1.1.9 enable peer 3.3.3.9 enable#ipv4-family vpnv4 policy vpn-target peer 1.1.1.9 enable peer 3.3.3.9 enable#ipv4-family vpn-instance vpn_in peer 110.1.1.1 as-number 65430 import-route direct#ipv4-family vpn-instance vpn_out peer 110.2.1.1 as-number 65430 peer 110.2.1.1 allow-as-loop import-route direct#ospf 1area 0.0.0.0 network 2.2.2.9 0.0.0.0 network 10.1.1.0 0.0.0.255 network 11.1.1.0 0.0.0.255#return

Spoke-CE1µÄÅäÖÃÎļþ#sysname Spoke-CE1#interface GigabitEthernet1/0/0ip address 100.1.1.1 255.255.255.0#interface NULL0#bgp 65410peer 100.1.1.2 as-number 100#ipv4-family unicast undo synchronization import-route direct peer 100.1.1.2 enable#return

Spoke-PE1µÄÅäÖÃÎļþ#sysname Spoke-PE1#ip vpn-instance vpnaroute-distinguisher 100:1vpn-target 100:1 export-extcommunityvpn-target 200:1

import-extcommunity#mpls lsr-id 1.1.1.9mpls lsp-trigger all#mpls ldp#interface GigabitEthernet1/0/0ip binding vpn-instance vpnaip address 100.1.1.2 255.255.255.0#interface Pos2/0/0link-protocol pppip address 10.1.1.1 255.255.255.0mplsmpls ldp#interface LoopBack1ip address 1.1.1.9

255.255.255.255#bgp 100peer 2.2.2.9 as-number 100peer 2.2.2.9 connect-interface LoopBack1#ipv4-family unicast undo synchronization peer 2.2.2.9 enable#ipv4-family vpnv4 policy vpn-target peer 2.2.2.9 enable#ipv4-family vpn-instance vpna peer 100.1.1.1 as-number 65410 import-route direct#ospf 1area 0.0.0.0 network 10.1.1.0 0.0.0.255 network 1.1.1.9 0.0.0.0#return

Spoke-PE2µÄÅäÖÃÎļþ#sysname Spoke-PE2#ip vpn-instance vpnaroute-distinguisher 100:3vpn-target 100:1 export-extcommunityvpn-target 200:1

import-extcommunity#mpls lsr-id 3.3.3.9mpls lsp-trigger all#mpls ldp#interface GigabitEthernet1/0/0ip binding vpn-instance vpnaip address 120.1.1.2 255.255.255.0#interface Pos2/0/0link-protocol pppip address 11.1.1.1

255.255.255.0mplsmpls ldp#interface LoopBack1ip address 3.3.3.9

255.255.255.255#bgp 100peer 2.2.2.9 as-number 100peer 2.2.2.9 connect-interface LoopBack1#ipv4-family unicast undo synchronization peer 2.2.2.9 enable#ipv4-family vpnv4 policy vpn-target peer 2.2.2.9 enable#ipv4-family vpn-instance vpna peer

120.1.1.1 as-number 65420 import-route direct#ospf 1area 0.0.0.0 network 3.3.3.9 0.0.0.0 network 11.1.1.0 0.0.0.255#return

Spoke-CE2µÄÅäÖÃÎļþ#sysname Spoke-CE2#interface GigabitEthernet1/0/0ip address 120.1.1.1 255.255.255.0#bgp 65420peer 120.1.1.2 as-number 100#ipv4-family unicast undo synchronization import-route direct peer 120.1.1.2 enable#Return

ÅäÖÃʵÀý¶þ ×éÍøÐèÇó ÈçÉÏÀýÖеÄͼ£¬Spoke-CEÖ®¼äµÄͨÐÅͨ¹ýÖÐÐÄÕ¾µãHub-CE¿ØÖÆ£¬¼´Spoke-CEÖ®¼äµÄÁ÷Á¿¾­¹ýHub-CEת·¢£¬¶ø²»ÊÇÖ»¾­¹ýHub-PEת·¢¡£ÒªÇóHub-CEÓëHub-PEÖ®¼äʹÓÃĬÈÏ·ÓÉ£¬Spoke-PEÓëSpoke-CEÖ®¼äʹÓÃEBGP½»»»Â·ÓÉÐÅÏ¢¡£ÊÊÓòúÆ·ºÍ°æ±¾ CEÉ豸ʹÓÃNE05¡¢NE08E»òNE16E£»PEÉ豸ʹÓÃNE20¡¢NE40N¡¢E40E»òNE80E¡£ÅäÖò½Öè ²½Öè 1 ÔڹǸÉÍøÉÏÅäÖÃIGPЭÒ飬ʵÏֹǸÉÍøHub-PEºÍSpoke-PEµÄ»¥Í¨±¾ÀýÖвÉÓÃOSPF£¬¾ßÌåÅäÖùý³ÌÂÔ¡£ÅäÖÃÍê³Éºó£¬PEÖ®¼äÓ¦Äܽ¨Á¢OSPFÁÚ¾Ó¹ØÏµ£¬Ö´ÐÐdisplay ospf peerÃüÁî¿ÉÒÔ¿´µ½ÁÚ¾Ó״̬ΪFull¡£Ö´ÐÐdisplay ip routing-tableÃüÁî¿ÉÒÔ¿´µ½PEÖ®¼äѧϰµ½¶Ô·½µÄLoopback·ÓÉ¡£²½Öè 2 ÔڹǸÉÍøÉÏÅäÖÃMPLS»ù±¾ÄÜÁ¦ºÍMPLS LDP£¬½¨Á¢LDP LSP¾ßÌåÅäÖùý³ÌÂÔ¡£ÅäÖÃÍê³Éºó£¬Hub-PEºÍSpoke-PEÖ®¼äÓ¦¸Ã½¨Á¢ÆðLDP¶ÔµÈÌå¹ØÏµ£¬ÔÚ¸÷·ÓÉÆ÷ÉÏÖ´ÐÐdisplay mpls ldp sessionÃüÁî¿ÉÒÔ¿´µ½ÏÔʾ½á¹ûÖÐSession StateÏîΪ¡°Operational¡±¡£²½Öè 3 ÔÚ¸÷PE·ÓÉÆ÷ÉÏÅäÖÃVPNʵÀý£¬½«CE½ÓÈëPE˵Ã÷×¢ÒâHub-PEÓëSpoke-PEÉϵÄVPN TargetÊôÐÔÉèÖá£Hub-PEµÄÁ½¸öVPNʵÀýµÄVPN-target·Ö±ðΪÁ½¸öSpoke-PE·¢²¼µÄVPN-target£¬ÇÒ·¢²¼µÄVPN-targetÓë½ÓÊÕµÄVPN-target²»Í¬¡£Spoke-PEµÄVPNʵÀýÒýÈëµÄVPN-targetΪHub-PE·¢²¼µÄVPN-target¡£

# ÅäÖÃSpoke-PE1¡£

[Spoke-PE1] ip vpn-instance vpna

[Spoke-PE1-vpn-instance-vpna] route-distinguisher 100:1

[Spoke-PE1-vpn-instance-vpna] vpn-target 100:1 export-extcommunity [Spoke-PE1-vpn-instance-vpna] vpn-target 200:1 import-extcommunity [Spoke-PE1-vpn-instance-vpna] quit

[Spoke-PE1] interface gigabitethernet 1/0/0

[Spoke-PE1-GigabitEthernet1/0/0] ip binding vpn-instance vpna [Spoke-PE1-GigabitEthernet1/0/0] ip address 100.1.1.2 24 [Spoke-PE1-GigabitEthernet1/0/0] quit # ÅäÖÃSpoke-PE2¡£

[Spoke-PE2] ip vpn-instance vpna

[Spoke-PE2-vpn-instance-vpna] route-distinguisher 100:3

[Spoke-PE2-vpn-instance-vpna] vpn-target 100:1 export-extcommunity [Spoke-PE2-vpn-instance-vpna] vpn-target 200:1 import-extcommunity [Spoke-PE2-vpn-instance-vpna] quit

[Spoke-PE2] interface gigabitethernet 1/0/0

[Spoke-PE2-GigabitEthernet1/0/0] ip binding vpn-instance vpna [Spoke-PE2-GigabitEthernet1/0/0] ip address 120.1.1.2 24

[Spoke-PE2-GigabitEthernet1/0/0] quit# ÅäÖÃHub-PE¡£[Hub-PE] ip vpn-instance vpn_in

[Hub-PE-vpn-instance-vpn_in] route-distinguisher 100:21

[Hub-PE-vpn-instance-vpn_in] vpn-target 100:1 import-extcommunity [Hub-PE-vpn-instance-vpn_in] quit [Hub-PE] ip vpn-instance vpn_out

[Hub-PE-vpn-instance-vpn_out] route-distinguisher 100:22

[Hub-PE-vpn-instance-vpn_out] vpn-target 200:1 export-extcommunity [Hub-PE-vpn-instance-vpn_out] quit [Hub-PE] interface gigabitethernet 3/0/0

[Hub-PE-GigabitEthernet3/0/0] ip binding vpn-instance vpn_in [Hub-PE-GigabitEthernet3/0/0] ip address 110.1.1.2 24 [Hub-PE-GigabitEthernet3/0/0] quit [Hub-PE] interface gigabitethernet 4/0/0

[Hub-PE-GigabitEthernet4/0/0] ip binding vpn-instance vpn_out [Hub-PE-GigabitEthernet4/0/0] ip address 110.2.1.2 24

[Hub-PE-GigabitEthernet4/0/0] quit#

°´ÉÏͼÅäÖø÷CEµÄ½Ó¿ÚIPµØÖ·£¬ÅäÖùý³ÌÂÔ¡£ÅäÖÃÍê³Éºó£¬ÔÚPE·ÓÉÆ÷ÉÏÖ´ÐÐdisplay ip vpn-instance verboseÃüÁî¿ÉÒÔ¿´µ½VPNʵÀýµÄÅäÖÃÇé¿ö¡£¸÷PEÄÜÓÃÃüÁîping -vpn-instance vpn-name ip-address pingͨ×Ô¼º½ÓÈëµÄCE¡£ËµÃ÷µ±PEÉÏÓжà¸ö°ó¶¨ÁËͬһ¸öVPNµÄ½Ó¿Ú£¬ÔòʹÓÃping -vpn-instance ÃüÁîping¶Ô¶ËPE½ÓÈëµÄCEʱ£¬ÒªÖ¸¶¨Ô´IPµØÖ·£¬¼´ÒªÖ¸¶¨ping -vpn-instance vpn-instance-name -a source-ip-address dest-ip-addressÃüÁîÖеIJÎÊý-a source-ip-address£¬·ñÔò¿ÉÄÜping²»Í¨¡£²½Öè 4 ÔÚPEÖ®¼ä½¨Á¢MP-IBGP¶ÔµÈÌå¹ØÏµËµÃ÷Spoke-PEÉϲ»ÐèÒªÅäÖÃÔÊÐíASºÅÖØ¸´Ò»´Î£¬ÒòΪ·ÓÉÆ÷½ÓÊÕIBGP¶ÔµÈÌå·¢²¼µÄ·ÓÉʱ²¢²»¼ì²éÆäÖеÄAS-PATHÊôÐÔ¡£

# ÅäÖÃSpoke-PE1¡£ [Spoke-PE1] bgp 100

[Spoke-PE1-bgp] peer 2.2.2.9 as-number 100

[Spoke-PE1-bgp] peer 2.2.2.9 connect-interface loopback 1 [Spoke-PE1-bgp] ipv4-family vpnv4

[Spoke-PE1-bgp-af-vpnv4] peer 2.2.2.9 enable [Spoke-PE1-bgp-af-vpnv4] quit # ÅäÖÃSpoke-PE2¡£ [Spoke-PE2] bgp 100

[Spoke-PE2-bgp] peer 2.2.2.9 as-number 100

[Spoke-PE2-bgp] peer 2.2.2.9 connect-interface loopback 1 [Spoke-PE2-bgp] ipv4-family vpnv4

[Spoke-PE2-bgp-af-vpnv4] peer 2.2.2.9 enable [Spoke-PE2-bgp-af-vpnv4] quit # ÅäÖÃHub-PE¡£ Hub-PE] bgp 100

[Hub-PE-bgp] peer 1.1.1.9 as-number 100

[Hub-PE-bgp] peer 1.1.1.9 connect-interface loopback 1 [Hub-PE-bgp] peer 3.3.3.9 as-number 100

[Hub-PE-bgp] peer 3.3.3.9 connect-interface loopback 1 [Hub-PE-bgp] ipv4-family vpnv4

[Hub-PE-bgp-af-vpnv4] peer 1.1.1.9 enable [Hub-PE-bgp-af-vpnv4] peer 3.3.3.9 enable [Hub-PE-bgp-af-vpnv4] quit

ÅäÖÃÍê³Éºó£¬ÔÚ¸÷PE·ÓÉÆ÷ÉÏÖ´ÐÐdisplay bgp peer»òdisplay bgp vpnv4 all peerÃüÁ¿ÉÒÔ¿´µ½PEÖ®¼äµÄBGP¶ÔµÈÌå¹ØÏµÒѽ¨Á¢£¬²¢´ïµ½Established״̬¡£²½Öè 5 ÔÚSpoke-PEÓëSpoke-CEÖ®¼ä½¨Á¢EBGP¶ÔµÈÌå¹ØÏµ£¬ÒýÈëVPN·ÓÉ

# ÅäÖÃSpoke-CE1¡£ [Spoke-CE1] bgp 65410

[Spoke-CE1-bgp] peer 100.1.1.2 as-number 100 [Spoke-CE1-bgp] import-route direct [Spoke-CE1-bgp] quit # ÅäÖÃSpoke-PE1¡£ [Spoke-PE1] bgp 100

[Spoke-PE1-bgp] ipv4-family vpn-instance vpna [Spoke-PE1-bgp-vpna] peer 100.1.1.1 as-number 65410 [Spoke-PE1-bgp-vpna] import-route direct [Spoke-PE1-bgp-vpna] quit[Spoke-PE1-bgp] quit # ÅäÖÃSpoke-CE2¡£ [Spoke-CE2] bgp 65420

[Spoke-CE2-bgp] peer 120.1.1.2 as-number 100

[Spoke-CE2-bgp] import-route direct [Spoke-CE2-bgp] quit # ÅäÖÃSpoke-PE2¡£ [Spoke-PE2] bgp 100

[Spoke-PE2-bgp] ipv4-family vpn-instance vpna [Spoke-PE2-bgp-vpna] peer 120.1.1.1 as-number 65420 [Spoke-PE2-bgp-vpna] import-route direct [Spoke-PE2-bgp-vpna] quit [Spoke-PE2-bgp] quit

ÅäÖÃÍê³Éºó£¬ÔÚ¸÷Spoke-PE·ÓÉÆ÷ÉÏÖ´ÐÐdisplay bgp vpnv4 all peerÃüÁ¿ÉÒÔ¿´µ½Spoke-PEÓëÆä½ÓÈëµÄSpoke-CEÖ®¼äµÄEBGP¶ÔµÈÌå¹ØÏµÒѽ¨Á¢£¬²¢´ïµ½Established״̬¡£

²½Öè 6 ÔÚHub-PEÓëHub-CEÉÏÅäÖÃĬÈÏ·ÓÉ

# ÅäÖÃHub-CE¡£

[Hub-CE] ip route-static 0.0.0.0 0 110.2.1.2 # ÅäÖÃHub-PE¡£

# Ϊvpn_outÅäÖÃĬÈÏ·ÓÉ£¬ÏÂÒ»ÌøÎªHub-CE¡£

[Hub-PE] ip route-static vpn-instance vpn_out 0.0.0.0 0 110.2.1.1 # ͨ¹ýMP-IBGP·¢²¼¸ÃĬÈÏ·ÓÉ¡£ [Hub-PE] bgp 100

[Hub-PE-bgp] ipv4-family vpn-instance vpn_out [Hub-PE-bgp-vpn_out] network 0.0.0.0 0 # ͨ¹ýMP-IBGP·¢²¼Ö±Á¬Â·ÓÉ¡£

[Hub-PE-bgp-vpn_out] import-route direct [Hub-PE-bgp-vpn_out] quit

[Hub-PE-bgp] quit

ÑéÖ¤½á¹û Íê³ÉÉÏÊöÅäÖúó£¬ÔÚSpoke-PEÉÏÖ´ÐÐÃüÁîdisplay bgp vpnv4 all routing-table²é¿´BGP VPN-IPv4·ÓÉ£¬¿ÉÒÔ·¢ÏÖHub-PEÉÏvpn_outµÄĬÈÏ·ÓÉÒÑ·¢²¼¸ø¸÷Spoke-PE¡£Spoke-CEÖ®¼ä¿ÉÒÔÏ໥Pingͨ£¬Ê¹ÓÃTracert¿ÉÒÔ¿´µ½Spoke-CEÖ®¼äµÄÁ÷Á¿¾­¹ýHub-CEת·¢£¬Ò²¿ÉÒÔͨ¹ýPing½á¹ûÖеÄTTLÖµÍÆËãSpoke-CEÖ®¼ä¾­¹ýµÄת·¢É豸ÊýÄ¿¡£ÔÚSpoke-CEÉÏÖ´ÐÐdisplay bgp ip routing-tableÃüÁ¿ÉÒÔ¿´µ½¶Ô¶ËSpoke-PEͨ¹ýBGP·¢²¼¹ýÀ´µÄĬÈÏ·ÓÉ¡£Ö´ÐÐdisplay ip routing-tableÃüÁ¿É¿´µ½ÓÐĬÈÏ·ÓÉ£¬ÏÂÒ»ÌøÎª¶Ô¶ËSpoke-PE¡£

ÅäÖÃÎļþ Hub-CEµÄÅäÖÃÎļþ

#sysname Hub-CE

#interface GigabitEthernet1/0/0ip address 110.1.1.1 255.255.255.0

#interface GigabitEthernet2/0/0ip address 110.2.1.1 255.255.255.0#ip route-static 0.0.0.0 0 110.2.1.2 #return

Hub-PEµÄÅäÖÃÎļþ #sysname Hub-PE

#ip vpn-instance vpn_inroute-distinguisher 100:21vpn-target 100:1 import-extcommunity

#ip vpn-instance vpn_outroute-distinguisher 100:22vpn-target 200:1 export-extcommunity

#mpls lsr-id 2.2.2.9mpls lsp-trigger all #mpls ldp

#interface GigabitEthernet3/0/0ip binding vpn-instance vpn_inip address 110.1.1.2 255.255.255.0#interface GigabitEthernet4/0/0ip binding vpn-instance vpn_outip address 110.2.1.2 255.255.255.0

#interface Pos1/0/0link-protocol pppip address 10.1.1.2 255.255.255.0mplsmpls ldp #interface Pos2/0/0link-protocol pppip address 11.1.1.2 255.255.255.0mplsmpls ldp#interface LoopBack1ip address 2.2.2.9 255.255.255.255

#bgp 100peer 1.1.1.9 as-number 100peer 3.3.3.9 as-number 100peer 1.1.1.9 connect-interface LoopBack1peer 3.3.3.9 connect-interface LoopBack1

#ipv4-family unicast undo synchronization peer 1.1.1.9 enable peer 3.3.3.9 enable #ipv4-family vpnv4 policy vpn-target peer 1.1.1.9 enable peer 3.3.3.9 enable #ipv4-family vpn-instance vpn_out network 0.0.0.0 0 import-route direct #ospf 1area 0.0.0.0 network 2.2.2.9 0.0.0.0 network 10.1.1.0 0.0.0.255 network 11.1.1.0 0.0.0.255

#ip route-static vpn-instance vpn_out 0.0.0.0 0 110.2.1.1 #return

Spoke-CE1µÄÅäÖÃÎļþ #sysname Spoke-CE1

#interface GigabitEthernet1/0/0ip address 100.1.1.1 255.255.255.0 #interface NULL0

#bgp 65410peer 100.1.1.2 as-number 100

#ipv4-family unicast undo synchronization import-route direct peer 100.1.1.2 enable #return

Spoke-PE1µÄÅäÖÃÎļþ #sysname Spoke-PE1

#ip vpn-instance vpnaroute-distinguisher 100:1vpn-target 100:1 export-extcommunityvpn-target 200:1 import-extcommunity #mpls lsr-id 1.1.1.9mpls lsp-trigger all

#mpls ldp#interface GigabitEthernet1/0/0ip binding vpn-instance vpnaip address 100.1.1.2 255.255.255.0#interface Pos2/0/0link-protocol pppip address 10.1.1.1 255.255.255.0mplsmpls ldp

#interface LoopBack1ip address 1.1.1.9 255.255.255.255#bgp 100peer 2.2.2.9 as-number 100peer 2.2.2.9 connect-interface LoopBack1

#ipv4-family unicast undo synchronization peer 2.2.2.9 enable #ipv4-family vpnv4 policy vpn-target peer 2.2.2.9 enable

#ipv4-family vpn-instance vpna peer 100.1.1.1 as-number 65410 import-route direct #ospf 1area 0.0.0.0 network 10.1.1.0 0.0.0.255 network 1.1.1.9 0.0.0.0 #return

Spoke-PE2µÄÅäÖÃÎļþ #sysname Spoke-PE2

#ip vpn-instance vpnaroute-distinguisher 100:3vpn-target 100:1 export-extcommunityvpn-target 200:1 import-extcommunity #mpls lsr-id 3.3.3.9mpls lsp-trigger all #mpls ldp

#interface GigabitEthernet1/0/0ip binding vpn-instance vpnaip address 120.1.1.2 255.255.255.0#interface Pos2/0/0link-protocol pppip address 11.1.1.1 255.255.255.0mplsmpls ldp

#interface LoopBack1ip address 3.3.3.9 255.255.255.255

#bgp 100peer 2.2.2.9 as-number 100peer 2.2.2.9 connect-interface LoopBack1 #ipv4-family unicast undo synchronization peer 2.2.2.9 enable #ipv4-family vpnv4 policy vpn-target peer 2.2.2.9 enable

#ipv4-family vpn-instance vpna peer 120.1.1.1 as-number 65420 import-route direct #ospf 1area 0.0.0.0 network 3.3.3.9 0.0.0.0 network 11.1.1.0 0.0.0.255 #return

Spoke-CE2µÄÅäÖÃÎļþ #sysname Spoke-CE2

#interface GigabitEthernet1/0/0ip address 120.1.1.1 255.255.255.0 #bgp 65420peer 120.1.1.2 as-number 100

#ipv4-family unicast undo synchronization import-route direct peer 120.1.1.2 enable #return