实验要求:
1、使用DHCP分配四台pc的IP地址
2、实现全网可达
实验预览图:
实验分析:
1、
先对二层交换机进行配置,创建vlan2、 3,再对每个端口进行配置,连接pc的端口使用协议access,连接交换机的端口使用协议trunk。
2、
接着对三层交换机进行配置,同样先创建vlan2、3,再创建vlanif1、2,对vlanif2、3配置IP,同时创建两个地址池2、3,并进行地址范围和网关配置,在主视图开启dhcp服务后再分别进入两个vlanif口调用全局地址池,最后在pc端开启dhcp服务。
3、
在两个三层交换机分别创建vlan4,同时创建vlanif4口,添加地址,开启ospf协议,进入区域0,对两台三层交换机相邻端口进行宣发,再对往下的vlanif2、3口添加的网关进行宣发
实验过程:
对二层交换机进行配置:
SW3:
[sw3]vlan 2
[sw3]vlan 3
[sw3]interface GigabitEthernet 0/0/2
[sw3-GigabitEthernet0/0/2]port link-type access
[sw3-GigabitEthernet0/0/2]port default vlan 2
[sw3]interface GigabitEthernet 0/0/3
[sw3-GigabitEthernet0/0/3]port link-type access
[sw3-GigabitEthernet0/0/3]port default vlan 3
[sw3]interface GigabitEthernet 0/0/1
[sw3-GigabitEthernet0/0/1]port link-type trunk
[sw3-GigabitEthernet0/0/1]port trunk allow-pass vlan 2 3
SW4:
[sw4]vlan batch 2 3
[sw4]interface GigabitEthernet 0/0/1
[sw4-GigabitEthernet0/0/1]port link-type access
[sw4-GigabitEthernet0/0/1]port default vlan 2
[sw4]interface GigabitEthernet 0/0/2
[sw4-GigabitEthernet0/0/2]port link-type access
[sw4-GigabitEthernet0/0/2]port default vlan 3
[sw4]interface GigabitEthernet 0/0/3
[sw4-GigabitEthernet0/0/3]port link-type trunk
[sw4-GigabitEthernet0/0/3]port trunk allow-pass vlan 2 3
对三层交换机进行配置:
配置DHCP
SW1:
[sw1]vlan batch 2 3
[sw1]interface GigabitEthernet 0/0/1
[sw1-GigabitEthernet0/0/1]port link-type trunk
[sw1-GigabitEthernet0/0/1]port trunk allow-pass vlan 2 3
[sw1]interface Vlanif 2
[sw1-Vlanif2]ip address 192.168.1.1 24
[sw1]interface Vlanif 3
[sw1-Vlanif3]ip address 192.168.2.1 24
[sw1]dhcp enable
[sw1]ip pool 2
[sw1-ip-pool-2]network 192.168.1.0 mask 24
[sw1-ip-pool-2]gateway-list 192.168.1.1
[sw1]ip pool 3
[sw1-ip-pool-3]network 192.168.2.0 mask 24
[sw1-ip-pool-3]gateway-list 192.168.2.1
[sw1]interface Vlanif 2
[sw1-Vlanif2]dhcp select global
[sw1]interface Vlanif 3
[sw1-Vlanif3]dhcp select global
在PC端启动DHCP服务,查看配置:
PC1:
PC2:
SW2:
[sw2]vlan batch 2 3
[sw2]interface GigabitEthernet 0/0/1
[sw2-GigabitEthernet0/0/1]port link-type trunk
[sw2-GigabitEthernet0/0/1]port trunk allow-pass vlan 2 3
[sw2]interface Vlanif 2
[sw2-Vlanif2]ip address 192.168.3.1 24
[sw2]interface Vlanif 3
[sw2-Vlanif3]ip address 192.168.4.1 24
[sw2]dhcp enable
[sw2]ip pool 2
[sw2-ip-pool-2]network 192.168.3.0 mask 24
[sw2-ip-pool-2]gateway-list 192.168.3.1
[sw2]ip pool 3
[sw2-ip-pool-3]network 192.168.4.0 mask 24
[sw2-ip-pool-3]gateway-list 192.168.4.1
[sw2]interface Vlanif 2
[sw2-Vlanif2]dhcp select global
[sw2]interface Vlanif 3
[sw2-Vlanif3]dhcp select global
在PC端启动DHCP服务,查看配置:
PC3:
PC4:
对三层交换机配置OSPF:
SW1:
[sw1]vlan 4
[sw1]interface Vlanif 4
[sw1-Vlanif4]ip address 192.168.5.1 24
[sw1]interface GigabitEthernet 0/0/2
[sw1-GigabitEthernet0/0/2]port link-type trunk
[sw1-GigabitEthernet0/0/2]port trunk allow-pass vlan 4
[sw1]ospf 1
[sw1-ospf-1]area 0
[sw1-ospf-1-area-0.0.0.0]network 192.168.5.1 0.0.0.0
[sw1-ospf-1-area-0.0.0.0]network 192.168.1.1 0.0.0.0
[sw1-ospf-1-area-0.0.0.0]network 192.168.2.1 0.0.0.0
SW2:
[sw2]vlan 4
[sw2]interface Vlanif 4
[sw2-Vlanif4]ip address 192.168.5.2 24
[sw2]interface GigabitEthernet 0/0/2
[sw2-GigabitEthernet0/0/2]port link-type trunk
[sw2-GigabitEthernet0/0/2]port trunk allow-pass vlan 4
[sw2]ospf 1
[sw2-ospf-1]area 0
[sw2-ospf-1-area-0.0.0.0]network 192.168.5.2 0.0.0.0
[sw2-ospf-1-area-0.0.0.0]network 192.168.3.1 0.0.0.0
[sw2-ospf-1-area-0.0.0.0]network 192.168.4.1 0.0.0.0