实验拓扑图如下:
R7只配置了IP地址,PC1手动配置静态即可
[R7]interface g0/0/0
[R7-GigabitEthernet0/0/0]ip address 11.1.1.1 24
[R7-GigabitEthernet0/0/0]qu
[R7]interface g0/0/1
[R7-GigabitEthernet0/0/1]ip address 10.1.1.2 24
[R7-GigabitEthernet0/0/1]qu
[R6]interface LoopBack 0
[R6-LoopBack0]ip address 6.6.6.6 32
[R6]interface g0/0/0
[R6-GigabitEthernet0/0/0]ip address 10.1.1.2 24
[R6-GigabitEthernet0/0/0]qu
[R6]interface g0/0/1
[R6-GigabitEthernet0/0/1]ip address 172.16.0.2 24
[R6-GigabitEthernet0/0/1]qu
[R1]interface LoopBack 0
[R1-LoopBack0]ip address 1.1.1.1 32
[R1-LoopBack0]qu
[R1]interface g0/0/0
[R1-GigabitEthernet0/0/0]ip address 172.16.64.3 24
[R1-GigabitEthernet0/0/0]qu
[R1]interface g0/0/1
[R1-GigabitEthernet0/0/1]ip address 172.16.0.1 24
[R1-GigabitEthernet0/0/1]qu
[R2]interface LoopBack 0
[R2-LoopBack0]ip address 2.2.2.2 32
[R2-LoopBack0]qu
[R2]interface g0/0/0
[R2-GigabitEthernet0/0/0]ip address 172.16.64.1 24
[R2-GigabitEthernet0/0/0]qu
[R2]interface g0/0/1
[R2-GigabitEthernet0/0/1]ip address 172.16.128.2 24
[R2-GigabitEthernet0/0/1]qu
[R3]interface LoopBack 0
[R3-LoopBack0]ip address 3.3.3.3 32
[R3-LoopBack0]qu
[R3]interface g0/0/0
[R3-GigabitEthernet0/0/0]ip address 172.16.64.2 24
[R3-GigabitEthernet0/0/0]qu
[R3]interface g0/0/1
[R3-GigabitEthernet0/0/1]ip address 172.16.192.2 24
[R3-GigabitEthernet0/0/1]qu
R4下的PC自动获取IP,所以需要在交换机创建划分vlan。
[R4]interface LoopBack 0
[R4-LoopBack0]ip address 4.4.4.4 32
[R4-LoopBack0]qu
[R4]interface g0/0/0
[R4-GigabitEthernet0/0/0]ip address 172.16.192.1 24
[R4-GigabitEthernet0/0/0]qu[Huawei]vlan 2 //交换机LSW3上的配置
[Huawei-vlan2]qu
[Huawei]vlan 3
[Huawei-vlan3]qu
[Huawei]interface e0/0/2
[Huawei-Ethernet0/0/2]port link-type access
[Huawei-Ethernet0/0/2]port default vlan 2
[Huawei-Ethernet0/0/2]qu
[Huawei]interface e0/0/2
[Huawei-Ethernet0/0/3]port link-type access
[Huawei-Ethernet0/0/3]port default vlan 3
[Huawei-Ethernet0/0/3]qu
[Huawei]interface e0/0/1
[Huawei-Ethernet0/0/1]port link-type trunk
[Huawei-Ethernet0/0/1]port trunk allow-pass vlan all
[Huawei-Ethernet0/0/1][R4]dhcp enable //R4上的配置
[R4]interface g0/0/1.1
[R4-GigabitEthernet0/0/1.1]dot1q termination vid 2
[R4-GigabitEthernet0/0/1.1]ip address 192.168.3.1 24
[R4-GigabitEthernet0/0/1.1]qu
[R4]interface g0/0/1.2
[R4-GigabitEthernet0/0/1.2]dot1q termination vid 3
[R4-GigabitEthernet0/0/1.2]ip address 192.168.4.1 24
[R4-GigabitEthernet0/0/1.2]qu
[R4]ip pool 1
[R4-ip-pool-1]network 192.168.3.0 mask 255.255.255.0
[R4-ip-pool-1]gateway-list 192.168.3.1
[R4-ip-pool-1]dns-list 8.8.8.8
[R4-ip-pool-1]qu
[R4]ip pool 2
[R4-ip-pool-2]network 192.168.4.0 mask 255.255.255.0
[R4-ip-pool-2]gateway-list 192.168.4.1
[R4-ip-pool-2]dns-list 8.8.8.8
[R4-ip-pool-2]qu
[R4]interface g0/0/1.1
[R4-GigabitEthernet0/0/1.1]dhcp select global
[R4-GigabitEthernet0/0/1.1]arp broadcast enable
[R4-GigabitEthernet0/0/1.1]qu
[R4]interface g0/0/1.2
[R4-GigabitEthernet0/0/1.2]dhcp select global
[R4-GigabitEthernet0/0/1.2]arp broadcast enable
[R4-GigabitEthernet0/0/1.2]qu
R5下的PC自动获取IP,所以也需要在交换机创建划分vlan。
[R5]interface LoopBack 0
[R5-LoopBack0]ip address 5.5.5.5 32
[R5-LoopBack0]qu
[R5]interface g0/0/0
[R5-GigabitEthernet0/0/0]ip address 172.16.2.2 24
[R5-GigabitEthernet0/0/0]qu
[Huawei]vlan 2 //交换机LSW1上的配置
[Huawei-vlan2]qu
[Huawei]vlan 3
[Huawei-vlan3]qu
[Huawei]interface e0/0/2
[Huawei-Ethernet0/0/2]port link-type access
[Huawei-Ethernet0/0/2]port default vlan 2
[Huawei-Ethernet0/0/2]qu
[Huawei]interface e0/0/3
[Huawei-Ethernet0/0/3]port link-type access
[Huawei-Ethernet0/0/3]port default vlan 3
[Huawei]interface e0/0/1
[Huawei-Ethernet0/0/1]port link-type trunk
[Huawei-Ethernet0/0/1]port trunk allow-pass vlan all[R5]dhcp enable //在R5上的配置
[R5]interface g0/0/1.1
[R5-GigabitEthernet0/0/1.1]dot1q termination vid 2
[R5-GigabitEthernet0/0/1.1]ip address 192.168.1.1 24
[R5-GigabitEthernet0/0/1.1]qu
[R5]interface g0/0/1.2
[R5-GigabitEthernet0/0/1.2]dot1q termination vid 3
[R5-GigabitEthernet0/0/1.2]ip address 192.168.2.1 24
[R5-GigabitEthernet0/0/1.2]qu
[R5]ip pool 1
[R5-ip-pool-1]network 192.168.1.0 mask 255.255.255.0
[R5-ip-pool-1]gateway-list 192.168.1.1
[R5-ip-pool-1]dns-list 8.8.8.8
[R5-ip-pool-1]qu
[R5]ip pool 2
[R5-ip-pool-2]network 192.168.2.0 mask 255.255.255.0
[R5-ip-pool-2]gateway-list 192.168.2.1
[R5-ip-pool-2]dns-list 8.8.8.8
[R5-ip-pool-2]qu
[R5]interface g0/0/1.1
[R5-GigabitEthernet0/0/1.1]dhcp select global
[R5-GigabitEthernet0/0/1.1]arp broadcast enable
[R5-GigabitEthernet0/0/1.1]qu
[R5]interface g0/0/1.2
[R5-GigabitEthernet0/0/1.2]dhcp select global
[R5-GigabitEthernet0/0/1.2]arp broadcast enable
[R5-GigabitEthernet0/0/1.2]qu
[R6]ospf 100 router-id 1.1.1.1
[R6-ospf-100]default-route-advertise always
[R6-ospf-100]area 1
[R6-ospf-100-area-0.0.0.1]authentication-mode simple cipher 123
[R6-ospf-100-area-0.0.0.1]authentication-mode md5
[R6-ospf-100-area-0.0.0.1]network 0.0.0.0 255.255.255.255
[R6]interface g0/0/1
[R6-GigabitEthernet0/0/1]ospf timer hello 5
[R6-GigabitEthernet0/0/1]
[R1]ospf 100 router-id 2.2.2.2
[R1-ospf-100]area 1
[R1-ospf-100-area-0.0.0.1]authentication-mode simple cipher 123
[R1-ospf-100-area-0.0.0.1]authentication-mode md5
[R1-ospf-100-area-0.0.0.1]network 172.16.0.2 255.255.255.0
[R1-ospf-100-area-0.0.0.1]qu
[R1-ospf-100]area 0
[R1-ospf-100-area-0.0.0.0]authentication-mode simple cipher 123
[R1-ospf-100-area-0.0.0.0]authentication-mode md5
[R1-ospf-100-area-0.0.0.0]network 1.1.1.1 255.255.255.255
[R1-ospf-100-area-0.0.0.0]network 172.16.64.3 255.255.255.0
[R1]interface g0/0/0
[R1-GigabitEthernet0/0/0]ospf timer hello 5
[R1-GigabitEthernet0/0/0]qu
[R1]interface g0/0/1
[R1-GigabitEthernet0/0/1]ospf timer hello 5
[R1-GigabitEthernet0/0/1]
[R2]ospf 100 router-id 3.3.3.3
[R2-ospf-100]area 0
[R2-ospf-100-area-0.0.0.0]authentication-mode simple cipher 123
[R2-ospf-100-area-0.0.0.0]authentication-mode md5
[R2-ospf-100-area-0.0.0.0]network 2.2.2.2 255.255.255.255
[R2-ospf-100-area-0.0.0.0]network 172.16.64.1 255.255.255.0
[R2-ospf-100]area 2
[R2-ospf-100-area-0.0.0.2]authentication-mode simple cipher 123
[R2-ospf-100-area-0.0.0.2]authentication-mode md5
[R2-ospf-100-area-0.0.0.2]network 172.16.128.2 255.255.255.0
[R2]interface g0/0/0
[R2-GigabitEthernet0/0/0]ospf timer hello 5
[R2-GigabitEthernet0/0/0]qu
[R2]interface g0/0/1
[R2-GigabitEthernet0/0/1]ospf timer hello 5
[R2-GigabitEthernet0/0/1]
[R3]ospf 100 router-id 5.5.5.5
[R3-ospf-100]area 0
[R3-ospf-100-area-0.0.0.0]authentication-mode simple cipher 123
[R3-ospf-100-area-0.0.0.0]authentication-mode md5
[R3-ospf-100-area-0.0.0.0]network 3.3.3.3 255.255.255.255
[R3-ospf-100-area-0.0.0.0]network 172.16.64.2 255.255.255.255
[R3-ospf-100-area-0.0.0.0]qu
[R3-ospf-100]area 3
[R3-ospf-100-area-0.0.0.3]authentication-mode simple cipher 123
[R3-ospf-100-area-0.0.0.3]authentication-mode md5
[R3-ospf-100-area-0.0.0.3]network 172.16.192.2 255.255.255.255
[R3-ospf-100-area-0.0.0.3]
[R3]interface g0/0/0
[R3-GigabitEthernet0/0/0]ospf timer hello 5
[R3-GigabitEthernet0/0/0]
[R3]interface
[R3]interface g0/0/1
[R3-GigabitEthernet0/0/1]ospf timer hello 5
[R3-GigabitEthernet0/0/1]
[R4]ospf 100 router-id 4.4.4.4
[R4-ospf-100]area 3
[R4-ospf-100-area-0.0.0.3]authentication-mode simple cipher 123
[R4-ospf-100-area-0.0.0.3]authentication-mode md5
[R4-ospf-100-area-0.0.0.3]network 0.0.0.0 255.255.255.255
[R4-ospf-100-area-0.0.0.3]
[R4]interface g0/0/0
[R4-GigabitEthernet0/0/0]ospf timer hello 5
[R4-GigabitEthernet0/0/0]
[R5]ospf 100 router-id 5.5.5.5
[R5-ospf-100]area 2
[R5-ospf-100-area-0.0.0.2]authentication-mode simple cipher 123
[R5-ospf-100-area-0.0.0.2]authentication-mode md5
[R5-ospf-100-area-0.0.0.2]network 0.0.0.0 255.255.255.255
[R5]interface g0/0/0
[R5-GigabitEthernet0/0/0]ospf timer hello 5
[R6]interface g0/0/1
[R6-GigabitEthernet0/0/1]ospf dr-priority 0[R2]interface g0/0/0
[R2-GigabitEthernet0/0/0]ospf dr-priority 0[R3]interface g0/0/0
[R3-GigabitEthernet0/0/0]ospf dr-priority 0
[r4]ip route-static 0.0.0.0 0 10.1.1.2
[r4-ospf-100]default-route-advertise[r4]acl 2001
[r4-acl-basic-2001]rule permit source any
[r4-acl-basic-2001]qu
[r4]interface g0/0/1
[r4-GigabitEthernet0/0/1]nat outbound 2001
pc5不能ping通pc3
[R3]acl 3000
[R3-acl-adv-3000]rule deny icmp source 192.168.4.254 0.0.0.0 destination 192.168.2.254 0.0.0.0 icmp-type echo
[R3-acl-adv-3000]rule permit ip source any destination any
[R3-acl-adv-3000]qu
[R3]interface g0/0/1
[R3-GigabitEthernet0/0/1]traffic-filter inbound acl 3000
实验结果如图所示: