一:地址规划
PC地址
设备 | 地址 | 网关 |
PC1 | 192.168.1.2 24 | 192.168.1.1 24 |
PC2 | 192.168.2.2 24 | 192.168.2.1 24 |
PC3 | 192.168.3.2 24 | 192.168.3.1 24 |
PC4 | 192.168.4.2 24 | 192.168.4.1 24 |
PC5 | 192.168.5.2 24 | 192.168.5.1 24 |
设备地址如上图所示:
二:配置IP地址
R1
[R1]int g 0/0/0
[R1-GigabitEthernet0/0/0]ip address 192.168.1.1 24
[R1-GigabitEthernet0/0/0]int g 0/0/1
[R1-GigabitEthernet0/0/1]ip address 116.0.0.1 24
[R1-GigabitEthernet0/0/1]int g 0/0/2
[R1-GigabitEthernet0/0/2]ip address 14.0.0.1 24
R2
[R2]int g 0/0/0
[R2-GigabitEthernet0/0/0]ip address 192.168.2.1 24
[R2-GigabitEthernet0/0/0]int g 0/0/1
[R2-GigabitEthernet0/0/1]ip address 24.0.0.1 24
R3
[R3]int g 0/0/0
[R3-GigabitEthernet0/0/0]ip address 192.168.3.1 24
[R3-GigabitEthernet0/0/0]int g 0/0/1
[R3-GigabitEthernet0/0/1]ip address 34.0.0.1 24
R4
[R4]int g 0/0/0
[R4-GigabitEthernet0/0/0]ip address 116.0.0.2 24
[R4-GigabitEthernet0/0/0]int g 0/0/1
[R4-GigabitEthernet0/0/1]ip address 14.0.0.2 24
[R4-GigabitEthernet0/0/1]int g 0/0/2
[R4-GigabitEthernet0/0/2]ip address 24.0.0.2 24
[R4-GigabitEthernet0/0/2]int g 6/0/0
[R4-GigabitEthernet6/0/0]ip address 34.0.0.2 24
[R4-GigabitEthernet6/0/0]int g 6/0/1
[R4-GigabitEthernet6/0/1]ip address 64.0.0.2 24
[R4-GigabitEthernet6/0/1]int g 6/0/2
[R4-GigabitEthernet6/0/2]ip address 54.0.0.2 24
[R4-GigabitEthernet6/0/2]int lo 0
[R4-LoopBack0]ip address 2.2.2.1 24
R5
[R5]int g 0/0/0
[R5-GigabitEthernet0/0/0]ip address 192.168.4.1 24
[R5-GigabitEthernet0/0/0]int g 0/0/1
[R5-GigabitEthernet0/0/1]ip address 54.0.0.1 24
R6
[R6]int g 0/0/0
[R6-GigabitEthernet0/0/0]ip address 192.168.5.1 24
[R6-GigabitEthernet0/0/0]int g 0/0/1
[R6-GigabitEthernet0/0/1]ip address 64.0.0.1 24
三:配置缺省路由
[R1]ip route-static 0.0.0.0 0 14.0.0.2
[R1]ip route-static 0.0.0.0 0 116.0.0.2
[R2]ip route-static 0.0.0.0 0 24.0.0.2
[R3]ip route-static 0.0.0.0 0 34.0.0.2
[R5]ip route-static 0.0.0.0 0 54.0.0.2
[R6]ip route-static 0.0.0.0 0 64.0.0.2
四:配置NAT:
[R1]acl 2000
[R1-acl-basic-2000]rule 1 permit source any
[R1-acl-basic-2000]q
[R1]int g 0/0/1
[R1-GigabitEthernet0/0/1]nat outbound 2000
[R1-GigabitEthernet0/0/1]int g 0/0/2
[R1-GigabitEthernet0/0/2]nat outbound 2000
[R2]acl 2000
[R2-acl-basic-2000]rule 1 permit source any
[R2-acl-basic-2000]int g 0/0/1
[R2-GigabitEthernet0/0/1]nat outbound 2000
[R3]acl 2000
[R3-acl-basic-2000]rule 1 permit source any
[R3-acl-basic-2000]int g 0/0/1
[R3-GigabitEthernet0/0/1]nat outbound 2000
[R5]acl 2000
[R5-acl-basic-2000]rule 1 permit source any
[R5-acl-basic-2000]int g 0/0/1
[R5-GigabitEthernet0/0/1]nat outbound 2000
[R6]acl 2000
[R6-acl-basic-2000]rule 1 permit source any
[R6-acl-basic-2000]int g 0/0/1
[R6-GigabitEthernet0/0/1]nat outbound 2000
在PC1上ping 2.2.2.1可以全网通
五:R1/R2/R3构建星型拓扑结构
[R1]int t 0/0/1
[R1-Tunnel0/0/1]ip address 20.1.1.1 24
[R1-Tunnel0/0/1]tunnel-protocol gre p2mp
[R1-Tunnel0/0/1]source 116.0.0.1
[R1-Tunnel0/0/1]nhrp network-id 101
[R1-Tunnel0/0/1]nhrp entry multicast dynamic
[R2]int t 0/0/1
[R2-Tunnel0/0/1]ip address 20.1.1.2 24
[R2-Tunnel0/0/1]tunnel-protocol gre p2mp
[R2-Tunnel0/0/1]source g 0/0/1
[R2-Tunnel0/0/1]nhrp network-id 101
[R2-Tunnel0/0/1]nhrp entry 20.1.1.1 116.0.0.1register
[R3]int t 0/0/1
[R3-Tunnel0/0/1]ip address 20.1.1.3 24
[R3-Tunnel0/0/1]tunnel-protocol gre p2mp
[R3-Tunnel0/0/1]source g 0/0/1
[R3-Tunnel0/0/1]nhrp network-id 101
[R3-Tunnel0/0/1]nhrp entry 20.1.1.1 116.0.0.1 register
六:R1/R6/R5构建MGRE环境
[R1]int t 0/0/0
[R1-Tunnel0/0/0]ip address 10.1.1.1 24
[R1-Tunnel0/0/0]tunnel-protocol gre p2mp
[R1-Tunnel0/0/0]source 14.0.0.1
[R1-Tunnel0/0/0]nhrp network-id 100
[R1-Tunnel0/0/0]nhrp entry multicast dynamic
[R1-Tunnel0/0/0]nhrp entry 10.1.1.5 54.0.0.1 register
[R1-Tunnel0/0/0]nhrp entry 10.1.1.6 64.0.0.1 register
[R5]int t 0/0/0
[R5-Tunnel0/0/0]ip address 10.1.1.5 24
[R5-Tunnel0/0/0]tunnel-protocol gre p2mp
[R5-Tunnel0/0/0]source 54.0.0.1
[R5-Tunnel0/0/0]nhrp network-id 100
[R5-Tunnel0/0/0]nhrp entry multicast dynamic
[R5-Tunnel0/0/0]nhrp entry 10.1.1.1 14.0.0.1 register
[R5-Tunnel0/0/0]nhrp entry 10.1.1.6 64.0.0.1 register
[R6]int t 0/0/0
[R6-Tunnel0/0/0]ip address 10.1.1.6 24
[R6-Tunnel0/0/0]tunnel-protocol gre p2mp
[R6-Tunnel0/0/0]source 64.0.0.1
[R6-Tunnel0/0/0]nhrp network-id 100
[R6-Tunnel0/0/0]nhrp entry multicast dynamic
[R6-Tunnel0/0/0]nhrp entry 10.1.1.1 14.0.0.1 register
[R6-Tunnel0/0/0]nhrp entry 10.1.1.5 54.0.0.1 register
七:OSPF配置:以R1为例,其他相同
[R1]ospf 1 router-id 1.1.1.1
[R1-ospf-1]area 0
[R1-ospf-1-area-0.0.0.0]network 192.168.1.0 0.0.0.255
[R1-ospf-1-area-0.0.0.0]network 10.1.1.0 0.0.0.255
[R1-ospf-1-area-0.0.0.0]network 20.1.1.0 0.0.0.255
八:修改R1/R2/R3/R5/R6的通道接口为broadcast口,以R1为例:
[R1]int t 0/0/0
[R1-Tunnel0/0/0]ospf network-type broadcast
[R1-Tunnel0/0/0]q
[R1]int t0/0/1
[R1-Tunnel0/0/1]ospf network-type broadcast
九:测试