一、基于192.168.0.0 24进行子网划分,给拓扑中所有广播域配上一个网段,接口配置IP
配上网段之后的拓扑图
配置接口IP:
R1:
配置代码:
[R1]interface LoopBack 0
[R1-LoopBack0]ip add 192.168.0.1 30
[R1]interface LoopBack 1
[R1-LoopBack1]ip add 192.168.0.5 30
[R1]interface LoopBack 2
[R1-LoopBack2]ip add 192.168.0.9 30
[R1]interface g0/0/0
[R1-GigabitEthernet0/0/0]ip add 192.168.0.17 28
[R1-GigabitEthernet0/0/0]int g 0/0/1
[R1-GigabitEthernet0/0/1]ip add 192.168.0.97 28
R2:
配置代码:
[R2]interface g0/0/0
[R2-GigabitEthernet0/0/0]ip add 192.168.0.18 28
[R2-GigabitEthernet0/0/0]int g0/0/1
[R2-GigabitEthernet0/0/1]ip add 192.168.0.34 28
R3:
配置代码:
[R3]interface g0/0/0
[R3-GigabitEthernet0/0/0]ip add 192.168.0.33 28
[R3-GigabitEthernet0/0/0]int g0/0/1
[R3-GigabitEthernet0/0/1]ip add 192.168.0.81 28
[R3-GigabitEthernet0/0/1]int g0/0/2
[R3-GigabitEthernet0/0/2]ip add 192.168.0.49 28
[R3-GigabitEthernet0/0/2]int g4/0/0
[R3-GigabitEthernet4/0/0]ip add 192.168.0.65 28
R4:
配置代码:
[R4]interface g0/0/0
[R4-GigabitEthernet0/0/0]ip add 192.168.0.82 28
[R4-GigabitEthernet0/0/0]int g0/0/1
[R4-GigabitEthernet0/0/1]ip add 192.168.0.98 28
[R4]int g0/0/2.1
[R4-GigabitEthernet0/0/2.1]dot1q termination vid 2
[R4-GigabitEthernet0/0/2.1]ip add 192.168.0.113 28
[R4-GigabitEthernet0/0/2.1]arp broadcast enable
[R4]int g0/0/2.2
[R4-GigabitEthernet0/0/2.2]dot1q termination vid 3
[R4-GigabitEthernet0/0/2.2]ip add 192.168.0.129 28
[R4-GigabitEthernet0/0/2.2]arp broadcast enable
R5:
配置代码:
[R5]interface g0/0/0
[R5-GigabitEthernet0/0/0]ip add 192.168.0.50 28
[R5-GigabitEthernet0/0/0]int g0/0/1
[R5-GigabitEthernet0/0/1]ip add 192.168.0.66 28
二、R4配置DHCP
配置代码:
[R4]dhcp enable
[R4]ip pool aaa
[R4-ip-pool-aaa]network 192.168.0.112 mask 255.255.255.240
[R4-ip-pool-aaa]gateway-list 192.168.0.113
[R4-ip-pool-aaa]dns-list 8.8.8.8
[R4]ip pool bbb
[R4-ip-pool-bbb]network 192.168.0.128 mask 255.255.255.240
[R4-ip-pool-bbb]gateway-list 192.168.0.129
[R4-ip-pool-bbb]dns-list 8.8.8.8
[R4-GigabitEthernet0/0/2.1]dhcp select global
[R4-GigabitEthernet0/0/2.2]dhcp select global
配置VLAN:
LSW1:
配置代码:
[SW1]vlan batch 2 3
[SW1]int e0/0/1
[SW1-Ethernet0/0/1]port link-type trunk
[SW1-Ethernet0/0/1]port trunk allow-pass vlan all
[SW1]int e0/0/4
[SW1-Ethernet0/0/4]port link-type trunk
[SW1-Ethernet0/0/4]port trunk allow-pass vlan all
[SW1]int e0/0/2
[SW1-Ethernet0/0/2]port link-type access
[SW1-Ethernet0/0/2]port default vlan 2
[SW1-Ethernet0/0/2]int e0/0/3
[SW1-Ethernet0/0/3]port link-type access
[SW1-Ethernet0/0/3]port default vlan 3
LSW2:
配置代码:
[SW2]vlan batch 2 3
[SW2]int e0/0/1
[SW2-Ethernet0/0/1]port link-type trunk
[SW2-Ethernet0/0/1]port trunk allow-pass vlan all
[SW2-Ethernet0/0/1]int e0/0/2
[SW2-Ethernet0/0/2]port link-type access
[SW2-Ethernet0/0/2]port default vlan 2
[SW2-Ethernet0/0/2]int e0/0/3
[SW2-Ethernet0/0/3]port link-type access
[SW2-Ethernet0/0/3]port default vlan 3
查看DHCP是否获取到地址:
PC1:
PC2:
PC3:
PC4:
配置静态路由:
R1:
配置代码:
[R1]ip route-static 192.168.0.32 28 192.168.0.18
[R1]ip route-static 192.168.0.80 28 192.168.0.98
[R1]ip route-static 192.168.0.48 28 192.168.0.98
[R1]ip route-static 192.168.0.48 28 192.168.0.18
[R1]ip route-static 192.168.0.112 28 192.168.0.98
[R1]ip route-static 192.168.0.128 28 192.168.0.98
[R1]ip route-static 192.168.0.64 28 192.168.0.98
[R1]ip route-static 192.168.0.64 28 192.168.0.18
[R1]ip route-static 100.1.1.0 24 192.168.0.18
R2:
配置代码:
[R2]ip route-static 192.168.0.48 28 192.168.0.33
[R2]ip route-static 192.168.0.64 28 192.168.0.33
[R2]ip route-static 192.168.0.80 28 192.168.0.33
[R2]ip route-static 192.168.0.96 28 192.168.0.17
[R2]ip route-static 192.168.0.0 28 192.168.0.17
[R2]ip route-static 192.168.0.112 28 192.168.0.17
[R2]ip route-static 192.168.0.128 28 192.168.0.17
[R2]ip route-static 192.168.0.128 28 192.168.0.33
[R2]ip route-static 192.168.0.112 28 192.168.0.33
[R2]ip route-static 100.1.1.0 24 192.168.0.33
R3:
配置代码:
[R3]ip route-static 100.1.1.0 24 192.168.0.50
[R3]ip route-static 192.168.0.16 28 192.168.0.34
[R3]ip route-static 192.168.0.96 28 192.168.0.82
[R3]ip route-static 192.168.0.0 28 192.168.0.82
[R3]ip route-static 192.168.0.0 28 192.168.0.34
[R3]ip route-static 192.168.0.112 28 192.168.0.82
[R3]ip route-static 192.168.0.128 28 192.168.0.82
R5:
配置代码:
[R5]ip route-static 192.168.0.32 28 192.168.0.49
[R5]ip route-static 192.168.0.16 28 192.168.0.49
[R5]ip route-static 192.168.0.80 28 192.168.0.49
[R5]ip route-static 192.168.0.96 28 192.168.0.49
[R5]ip route-static 192.168.0.0 28 192.168.0.49
[R5]ip route-static 192.168.0.112 28 192.168.0.49
[R5]ip route-static 192.168.0.128 28 192.168.0.49
ISP:
配置代码:
[ISP]ip route-static 192.168.0.48 28 100.1.1.1
[ISP]ip route-static 192.168.0.64 28 100.1.1.1
[ISP]ip route-static 192.168.0.32 28 100.1.1.1
[ISP]ip route-static 192.168.0.80 28 100.1.1.1
[ISP]ip route-static 192.168.0.112 28 100.1.1.1
[ISP]ip route-static 192.168.0.128 28 100.1.1.1
[ISP]ip route-static 192.168.0.16 28 100.1.1.
[ISP]ip route-static 192.168.0.96 28 100.1.1.1
[ISP]ip route-static 192.168.0.0 28 100.1.1.1
防环,在R1上面汇总的IP指向NULL0:
R5指向一条缺省到ISP并配置acl和nat:
测试:
测试是否全网可达: