1.IP地址配置
R1
[R1]interface GigabitEthernet 0/0/0
[R1-GigabitEthernet0/0/0]ip address 15.0.0.1 24
[R1-GigabitEthernet0/0/0]quit
[R1]interface GigabitEthernet 0/0/1
[R1-GigabitEthernet0/0/1]ip address 65.0.0.1 24
[R1-GigabitEthernet0/0/1]quit
[R1]interface GigabitEthernet 0/0/2
[R1-GigabitEthernet0/0/2]ip address 192.168.1.1 24
R2
[R2]interface GigabitEthernet 0/0/0
[R2-GigabitEthernet0/0/0]ip address 25.0.0.1 24
[R2-GigabitEthernet0/0/0]quit
[R2]interface GigabitEthernet 0/0/1
[R2-GigabitEthernet0/0/1]ip address 192.168.2.1 24
R3
[R3]interface GigabitEthernet 0/0/0
[R3-GigabitEthernet0/0/0]ip address 35.0.0.1 24
[R3-GigabitEthernet0/0/0]quit
[R3]interface GigabitEthernet 0/0/1
[R3-GigabitEthernet0/0/1]ip address 192.168.3.1 24
R4
[R4]interface GigabitEthernet 0/0/0
[R4-GigabitEthernet0/0/0]ip address 45.0.0.1 24
[R4-GigabitEthernet0/0/0]quit
[R4]interface GigabitEthernet 0/0/1
[R4-GigabitEthernet0/0/1]ip address 192.168.4.1 24
R5
[R5]interface GigabitEthernet 0/0/0
[R5-GigabitEthernet0/0/0]ip address 55.0.0.1 24
[R5-GigabitEthernet0/0/0]quit
[R5]interface GigabitEthernet 0/0/1
[R5-GigabitEthernet0/0/1]ip address 192.168.5.1 24
R6
[R6]interface GigabitEthernet 0/0/0
[R6-GigabitEthernet0/0/0]ip address 15.0.0.2 24
[R6-GigabitEthernet0/0/0]quit
[R6]interface GigabitEthernet 0/0/1
[R6-GigabitEthernet0/0/1]ip address 65.0.0.2 24
[R6-GigabitEthernet0/0/1]quit
[R6]interface GigabitEthernet 0/0/2
[R6-GigabitEthernet0/0/2]ip address 25.0.0.2 24
[R6-GigabitEthernet0/0/2]quit
[R6]interface GigabitEthernet 3/0/0
[R6-GigabitEthernet3/0/0]ip address 35.0.0.2 24
[R6-GigabitEthernet3/0/0]quit
[R6]interface GigabitEthernet 2/0/0
[R6-GigabitEthernet2/0/0]ip address 55.0.0.2 24
[R6-GigabitEthernet2/0/0]quit
[R6]interface GigabitEthernet 4/0/0
[R6-GigabitEthernet4/0/0]ip address 45.0.0.2 24
[R6-GigabitEthernet4/0/0]quit
[R6]interface LoopBack 0
[R6-LoopBack0]ip address 6.6.6.6 24
2.配置缺省
R1
[R1]ip route-static 0.0.0.0 0 15.0.0.2
[R1]ip route-static 0.0.0.0 0 65.0.0.2
R2
[R2]ip route-static 0.0.0.0 0 25.0.0.2
R3
[R3]ip route-static 0.0.0.0 0 35.0.0.2
R4
[R4]ip route-static 0.0.0.0 0 45.0.0.2
R5
[R5]ip route-static 0.0.0.0 0 55.0.0.2
3.配置NAT网路地址转换
R1
[R1]acl 2000
[R1-acl-basic-2000]rule 1 permit source any
[R1-acl-basic-2000]quit
[R1]interface GigabitEthernet 0/0/0
[R1-GigabitEthernet0/0/0]nat outbound 2000
R2
[R2]acl 2000
[R2-acl-basic-2000]rule 1 permit source any
[R2-acl-basic-2000]quit
[R2]interface GigabitEthernet 0/0/0
[R2-GigabitEthernet0/0/0]nat outbound 2000
R3
[R3]acl 2000
[R3-acl-basic-2000]rule 1 permit source any
[R3-acl-basic-2000]quit
[R3]interface GigabitEthernet 0/0/0
[R3-GigabitEthernet0/0/0]nat outbound 2000
R4
[R4]acl 2000
[R4-acl-basic-2000]rule 1 permit source any
[R4-acl-basic-2000]quit
[R4]interface GigabitEthernet 0/0/0
[R4-GigabitEthernet0/0/0]nat outbound 2000
R5
[R5]acl 2000
[R5-acl-basic-2000]rule 1 permit source any
[R5-acl-basic-2000]quit
[R5]interface GigabitEthernet 0/0/0
[R5-GigabitEthernet0/0/0]nat outbound 2000
4.R1-2-3构建一个星型结构的MGRE结构,其中R1为中心点地址
R1
[R1]interface Tunnel 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 15.0.0.1
[R1-Tunnel0/0/1]nhrp network-id 101
[R1-Tunnel0/0/1]nhrp entry multicast dynamic 开启为广播
R2
[R2]interface Tunnel 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 GigabitEthernet 0/0/0
[R2-Tunnel0/0/1]nhrp network-id 101
[R2-Tunnel0/0/1]nhrp entry 20.1.1.1 15.0.0.1 register
R3
[R3]interface Tunnel 0/0/1
[R3-Tunnel0/0/1]ip address 20.1.1.3 24
[R3-Tunnel0/0/1]tunnel-protocol gre p2mp
[R2-Tunnel0/0/1]source GigabitEthernet 0/0/0
[R3-Tunnel0/0/1]nhrp network-id 101
[R3-Tunnel0/0/1]nhrp entry 20.1.1.1 15.0.0.1 register
5.R1-5-6 构建另一个全连网状的MGRE网络,其中R1/5均为中心区域
R1
[R1]interface Tunnel 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 65.0.0.1
[R1-Tunnel0/0/0]nhrp network-id 100
[R1-Tunnel0/0/0]nhrp entry 10.1.1.3 55.0.0.1 register
[R1-Tunnel0/0/0]nhrp entry multicast dynamic
R4
[R4]interface Tunnel 0/0/0
[R4-Tunnel0/0/0]ip address 10.1.1.2 24
[R4-Tunnel0/0/0]tunnel-protocol gre p2mp
[R4-Tunnel0/0/0]source GigabitEthernet 0/0/0
[R4-Tunnel0/0/0]nhrp network-id 100
[R4-Tunnel0/0/0]nhrp entry 10.1.1.1 65.0.0.1 register
[R4-Tunnel0/0/0]nhrp entry 10.1.1.3 55.0.0.1 register
R5
[R5]interface Tunnel 0/0/0
[R5-Tunnel0/0/0]ip address 10.1.1.3 24
[R5-Tunnel0/0/0]tunnel-protocol gre p2mp
[R5-Tunnel0/0/0]nhrp network-id 100
[R5-Tunnel0/0/0]nhrp entry 10.1.1.1 65.0.0.1 register
[R5-Tunnel0/0/0]nhrp entry multicast dynamic
6.更改网络类型
因为MGRE默认是P2P对等网络,要用OSPF必须改成broadcast网络
R1
[R1]interface Tunnel 0/0/0
[R1-Tunnel0/0/0]ospf network-type broadcast
[R1-Tunnel0/0/0]quit
[R1]interface Tunnel 0/0/1
[R1-Tunnel0/0/1]ospf network-type broadcast
R2
[R2]interface Tunnel 0/0/1
[R2-Tunnel0/0/1]ospf network-type broadcast
R3
[R3]interface Tunnel 0/0/1
[R3-Tunnel0/0/1]ospf network-type broadcast
R4
[R4]interface Tunnel 0/0/0
[R4-Tunnel0/0/0]ospf network-type broadcast
R5
[R4]interface Tunnel 0/0/0
[R4-Tunnel0/0/0]ospf network-type broadcast
7.配置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 20.1.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 192.168.1.0 0.0.0.255
R2
[R2]ospf 1 router-id 2.2.2.2
[R2-ospf-1]area 0
[R2-ospf-1-area-0.0.0.0]network 20.1.1.0 0.0.0.255
[R2-ospf-1-area-0.0.0.0]network 192.168.2.0 0.0.0.255
R3
[R3]ospf 1 router-id 3.3.3.3
[R3-ospf-1]area 0
[R3-ospf-1-area-0.0.0.0]network 20.1.1.0 0.0.0.255
[R3-ospf-1-area-0.0.0.0]network 192.168.3.0 0.0.0.255
R4
[R4]ospf 1 router-id 4.4.4.4
[R4-ospf-1]area 0
[R4-ospf-1-area-0.0.0.0]network 10.1.1.0 0.0.0.255
[R4-ospf-1-area-0.0.0.0]network 192.168.4.0 0.0.0.255
R5
[R5]ospf 1 router-id 5.5.5.5
[R5-ospf-1]area 0
[R5-ospf-1-area-0.0.0.0]network 10.1.1.0 0.0.0.255
[R5-ospf-1-area-0.0.0.0]network 192.168.5.0 0.0.0.255
7.让R1为DR
R2
[R2]interface t0/0/1
[R2-Tunnel0/0/1]ospf dr-priority 0
R3
[R3]interface t0/0/1
[R3-Tunnel0/0/1]ospf dr-priority 0
R4
[R4interface t0/0/0
[R4-Tunnel0/0/0]ospf dr-priority 0
R5
[R5]interface t0/0/0
[R5-Tunnel0/0/0]ospf dr-priority 0
8.测试
PC1 2 3 4 5 ping R6环回