预配
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
完成