华为Hub&Spoke实验

 预配

system-view

user-interface console 0

idle-timeout 0 0

quit

sysnam R

R1到R7的配置

R1:路由器1

mpls lsr-id 1.1.1.1

mpls

 mpls ldp

 quit

interface GigabitEthernet0/0/1

 ip address 17.1.1.1 255.255.255.0

 mpls

 mpls ldp

 quit

interface LoopBack0

 ip address 1.1.1.1 255.255.255.255

 quit

ospf 10 router-id 1.1.1.1

 area 0.0.0.0                            

  network 0.0.0.0 255.255.255.255

quit

quit

ip vpn-instance hub-to-spoke

  route-distinguisher 41:41

    vpn-target 41:41 export-extcommunity

    quit

  quit

ip vpn-instance spoke-to-hub

  route-distinguisher 14:14              

    vpn-target 25:25 36:36 import-extcommunity

     quit

  quit

interface GigabitEthernet0/0/0.14

 dot1q termination vid 14      

 arp broadcast enable         

 ip binding vpn-instance spoke-to-hub

 ip address 172.16.14.1 24

 quit

interface GigabitEthernet0/0/0.41

 dot1q termination vid 41      

 arp broadcast enable         

 ip binding vpn-instance hub-to-spoke

 ip address 172.16.41.1 24

 quit

bgp 10

 router-id 1.1.1.1

 undo default ipv4-unicast

 peer 7.7.7.7 as-number 10

 peer 7.7.7.7 connect-interface LoopBack0

 ipv4-family vpnv4 unicast

   peer 7.7.7.7 enable

   quit

 ipv4-family vpn-instance spoke-to-hub

   peer 172.16.14.4 as-number 4

   quit

ipv4-family vpn-instance hub-to-spoke

  peer 172.16.41.4 as-number 4

  quit

R2:路由器2

mpls lsr-id 2.2.2.2

mpls

 mpls ldp

 quit

interface GigabitEthernet0/0/0

 ip address 27.1.1.2 255.255.255.0

 mpls

 mpls ldp

 quit

interface LoopBack0

 ip address 2.2.2.2 255.255.255.255

 quit

ospf 10 router-id 2.2.2.2

 area 0.0.0.0                            

  network 0.0.0.0 255.255.255.255

quit

quit

ip vpn-instance spoke1

  route-distinguisher 25:25

    vpn-target 25:25 export-extcommunity

    vpn-target 41:41 import-extcommunity

    quit

  quit

interface GigabitEthernet0/0/1      

 ip binding vpn-instance spoke1

 ip address 172.16.25.2 24

 quit

bgp 10

 router-id 2.2.2.2

 undo default ipv4-unicast

 peer 7.7.7.7 as-number 10

 peer 7.7.7.7 connect-interface LoopBack0

 ipv4-family vpnv4 unicast

   peer 7.7.7.7 enable

   quit

 ipv4-family vpn-instance spoke1

   peer 172.16.25.5 as-number 5

   quit

R3:路由器3

mpls lsr-id 3.3.3.3

mpls

 mpls ldp

 quit

interface GigabitEthernet0/0/0

 ip address 37.1.1.3 255.255.255.0

 mpls

 mpls ldp

 quit

interface LoopBack0

 ip address 3.3.3.3 255.255.255.255

 quit

 ospf 10 router-id 3.3.3.3

 area 0.0.0.0                            

  network 0.0.0.0 255.255.255.255

quit

quit

ip vpn-instance spoke2

  route-distinguisher 36:36

    vpn-target 36:36 export-extcommunity

    vpn-target 41:41 import-extcommunity

    quit

  quit

interface GigabitEthernet0/0/1      

 ip binding vpn-instance spoke2

 ip address 172.16.36.3 24

 quit

bgp 10

 router-id 3.3.3.3

 undo default ipv4-unicast

 peer 7.7.7.7 as-number 10

 peer 7.7.7.7 connect-interface LoopBack0

 ipv4-family vpnv4 unicast

   peer 7.7.7.7 enable

   quit

 ipv4-family vpn-instance spoke2

   peer 172.16.36.6 as-number 6

   quit

R7:路由器7

mpls lsr-id 7.7.7.7

mpls

 mpls ldp

 quit

interface GigabitEthernet0/0/0

 ip address 17.1.1.7 255.255.255.0

 mpls

 mpls ldp

 quit

interface GigabitEthernet0/0/1

 ip address 27.1.1.7 255.255.255.0

 mpls

 mpls ldp

 quit

interface GigabitEthernet0/0/2

 ip address 37.1.1.7 255.255.255.0

 mpls

 mpls ldp

 quit

interface LoopBack0

 ip address 7.7.7.7 255.255.255.255

 quit

ospf 10 router-id 7.7.7.7

 area 0.0.0.0                            

  network 0.0.0.0 255.255.255.255

quit

 

 

Bgp 10

router-id 7.7.7.7

undo default ipv4-unicast

peer 1.1.1.1 as-number 10

peer 1.1.1.1 connect-interface LoopBack 0

peer 2.2.2.2 as-number 10

peer 2.2.2.2 connect-interface LoopBack 0

peer 3.3.3.3 as-number 10

peer 3.3.3.3 connect-interface LoopBack 0

ipv4-family vpnv4 unicast

peer 1.1.1.1 enable

peer 1.1.1.1 reflect-client

peer 2.2.2.2 enable

peer 2.2.2.2 reflect-client

peer 3.3.3.3 enable

peer 3.3.3.3 reflect-client

undo policy vpn-target   (关闭RT检查 )

 

 

R5:路由器5

interface GigabitEthernet0/0/0

  ip address 172.16.25.5 255.255.255.0

  quit

interface LoopBack0

  ip address 172.16.5.5 255.255.255.255

  quit

bgp 5

  router-id 5.5.5.5

  undo default ipv4-unicast

  peer 172.16.25.2 as-number 10

  ipv4-family unicast

    peer 172.16.25.2 enable

    import-route direct

R6:路由器6

interface GigabitEthernet0/0/0

  ip address 172.16.36.6 255.255.255.0

  quit

interface LoopBack0

   ip address 172.16.6.6 255.255.255.255

 quit

bgp 6

  router-id 6.6.6.6

  undo default ipv4-unicast

  peer 172.16.36.3 as-number 10

  ipv4-family unicast

    peer 172.16.36.3 enable

    import-route direct

R4:路由器4

interface GigabitEthernet0/0/1.14

  dot1q termination vid 14      

  arp broadcast enable         

  ip address 172.16.14.4 24

  quit

interface GigabitEthernet0/0/1.41

  dot1q termination vid 41    

  arp broadcast enable         

  ip address 172.16.41.4 24

  quit

interface LoopBack0

  ip address 172.16.4.4 255.255.255.255

  quit

bgp 4

  router-id 4.4.4.4

  undo default ipv4-unicast

  peer 172.16.14.1 as-number 10

  peer 172.16.41.1 as-number 10

  ipv4-family unicast

    peer 172.16.14.1 enable

    peer 172.16.41.1 enable

    import-route direct

    aggregate 172.16.0.0 255.255.0.0 detail-suppressed

    quit

 quit

 

 

 

 

 

Spoke通过Hub 访问internet

R1:

interface GigabitEthernet0/0/0.255

 dot1q termination vid 255

 arp broadcast enable         

ip address 14.255.255.1 24

quit

接口宣告到OSPF

R4:

interface GigabitEthernet0/0/1.255

 dot1q termination vid 255

 arp broadcast enable         

 ip address 14.255.255.4 24

quit

ip route-static 0.0.0.0 0 GigabitEthernet 0/0/1.255 14.255.255.1

acl number 2000

  rule 10 permit source 172.16.0.0 0.0.255.255

  quit

interface GigabitEthernet0/0/1.255

  nat outbound 2000

  quit

bgp 4

  ipv4-family unicast

    network 0.0.0.0 0.0.0.0

    quit

  quit

查看  display bgp routing-table peer 172.16.41.1 advertised-routes  

前最列表:

ip ip-prefix 14 index 10 permit 14.255.255.0 24

route-policy C deny node 10

  if-match ip-prefix 14

  quit

route-policy C permit node 20

  quit

bgp 4

  ipv4-family unicast

    undo import-route direct

    import-route direct route-policy C

 

 

 完成

 

  • 3
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

计算机网络与安全

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值