R1(config)#interface loopback 0
R1(config-if-Loopback 0)#ip address 1.1.1.1 255.255.255.255R1(config)#interface gigabitEthernet 0/0
R1(config-if-GigabitEthernet 0/0)#no switchport
R1(config-if-GigabitEthernet 0/0)#ip address 192.168.4.2 24R1(config)#interface gigabitEthernet 0/1
R1(config-if-GigabitEthernet 0/1)#no switchport
R1(config-if-GigabitEthernet 0/1)#ip address 192.168.5.2 24
R2(config)#interface loopback 0
R2(config-if-Loopback 0)#ip address 2.2.2.2 255.255.255.255R2(config)#interface gigabitEthernet 0/1
R2(config-if-GigabitEthernet 0/1)#no switchport
R2(config-if-GigabitEthernet 0/1)#ip address 192.168.2.1 24R2(config)#interface gigabitEthernet 0/0
R2(config-if-GigabitEthernet 0/0)#no switchport
R2(config-if-GigabitEthernet 0/0)#ip address 192.168.4.1 24
R3(config)#interface loopback 0
R3(config-if-Loopback 0)#ip address 3.3.3.3 255.255.255.255R3(config)#interface gigabitEthernet 0/0
R3(config-if-GigabitEthernet 0/0)#no switchport
R3(config-if-GigabitEthernet 0/0)#ip address 192.168.5.1 24R3(config)#interface gigabitEthernet 0/1
R3(config-if-GigabitEthernet 0/1)#no switchport
R3(config-if-GigabitEthernet 0/1)#ip address 192.168.3.1 24
SW4(config)#interface loopback 0
SW4(config-if-Loopback 0)#ip address 4.4.4.4 255.255.255.255SW4(config)#interface gigabitEthernet 0/1
SW4(config-if-GigabitEthernet 0/1)#no switchport
SW4(config-if-GigabitEthernet 0/1)#ip address 192.168.2.2 24SW4(config)#interface gigabitEthernet 0/2
SW4(config-if-GigabitEthernet 0/2)#no switchport
SW4(config-if-GigabitEthernet 0/2)#ip address 192.168.3.2 24SW4(config)#interface gigabitEthernet 0/0
SW4(config-if-GigabitEthernet 0/0)#no switchport
SW4(config-if-GigabitEthernet 0/0)#ip address 192.168.1.1 24
SW5(config)#interface loopback 0
SW5(config-if-Loopback 0)#ip address 5.5.5.5 255.255.255.255SW5(config)#interface gigabitEthernet 0/1
SW5(config-if-GigabitEthernet 0/1)#no switchport
SW5(config-if-GigabitEthernet 0/1)#ip address 192.168.1.2 24SW5(config)#interface gigabitEthernet 0/2
SW5(config-if-GigabitEthernet 0/2)#no switchport
SW5(config-if-GigabitEthernet 0/2)#ip address 172.16.1.1 24SW5(config)#interface gigabitEthernet 0/3
SW5(config-if-GigabitEthernet 0/3)#no switchport
SW5(config-if-GigabitEthernet 0/3)#ip address 172.16.2.1 24
R1(config)#router ospf
R1(config-router)#router-id 1.1.1.1
Change router-id and update OSPF process! [yes/no]:y
R1(config-router)#network 1.1.1.1 0.0.0.0 area 0
R1(config-router)#network 192.168.4.2 0.0.0.255 area 0
R1(config-router)#network 192.168.5.2 0.0.0.255 area 0
R2(config)#router ospf
R2(config-router)#router-id 2.2.2.2
Change router-id and update OSPF process! [yes/no]:y
R2(config-router)#network 2.2.2.2 0.0.0.0 area 0
R2(config-router)#network 192.168.4.1 0.0.0.255 area 0
R2(config-router)#network 192.168.2.1 0.0.0.255 area 0
R3(config)#router ospf
R3(config-router)#router-id 3.3.3.3
Change router-id and update OSPF process! [yes/no]:y
R3(config-router)#network 3.3.3.3 0.0.0.0 area 0
R3(config-router)#network 192.168.5.1 0.0.0.255 area 0
R3(config-router)#network 192.168.3.1 0.0.0.255 area 0
SW4(config)#router ospf
SW4(config-router)#router-id 4.4.4.4
Change router-id and update OSPF process! [yes/no]:y
SW4(config-router)#network 4.4.4.4 0.0.0.0 area 0
SW4(config-router)#network 192.168.2.2 0.0.0.255 area 0
SW4(config-router)#network 192.168.3.2 0.0.0.255 area 0SW4(config-router)#network 192.168.1.1 0.0.0.255 area 1
SW5(config)#router ospf
SW5(config-router)#router-id 5.5.5.5
Change router-id and update OSPF process! [yes/no]:y
SW5(config-router)#network 5.5.5.5 0.0.0.0 area 0
SW5(config-router)#network 192.168.1.2 0.0.0.255 area 1
SW5(config-router)#network 172.16.1.1 0.0.0.255 area 1SW5(config-router)#network 172.16.2.1 0.0.0.255 area 1
SW4#configure terminal
SW4(config)#ip access-list standard 10
SW4(config-std-nacl)#10 permit 172.16.1.0 0.0.0.255
SW4(config-std-nacl)#exit
SW4(config)#ip access-list standard 20
SW4(config-std-nacl)#10 permit 172.16.2.0 0.0.0.255
SW4(config-std-nacl)#exit
SW4#configure terminal
SW4(config)#route-map ruijie permit 10
SW4(config-route-map)#match ip address 10
SW4(config-route-map)#set ip next-hop 192.168.2.1
SW4(config-route-map)#exit
SW4(config)#route-map ruijie permit 20
SW4(config-route-map)#match ip address 20
SW4(config-route-map)#set ip next-hop 192.168.3.1
SW4(config-route-map)#exit
SW4(config)#interface gigabitEthernet 0/0
SW4(config-GigabitEthernet 0/0)#ip policy route-map ruijie ----->应用策略路由
SW4(config-GigabitEthernet 0/0)#exit