一、DHCP实验
实验目的:实现pc自动获取ip,不同vlan的各pc之间可以互相通信。
实验拓扑图:
步骤一:配置二层交换机SW1。
######二层交换机
[SW1]vlan batch 10 20
[SW1]int e0/0/2
[SW1-Ethernet0/0/2]port link-type access
[SW1-Ethernet0/0/2]port default vlan 10
[SW1-Ethernet0/0/2]int e0/0/3
[SW1-Ethernet0/0/3]port link-type access
[SW1-Ethernet0/0/3]port default vlan 20
[SW1-Ethernet0/0/3]int e0/0/1
[SW1-Ethernet0/0/1]port link-type trunk
[SW1-Ethernet0/0/1]port trunk allow-pass vlan all
####检查配置信息
[SW1-Ethernet0/0/1]dis port vlan
Port Link Type PVID Trunk VLAN List
-------------------------------------------------------------------------------
Ethernet0/0/1 trunk 1 1-4094
Ethernet0/0/2 access 10 -
Ethernet0/0/3 access 20 -
Ethernet0/0/4 hybrid 1 -
Ethernet0/0/5 hybrid 1 -
Ethernet0/0/6 hybrid 1 -
Ethernet0/0/7 hybrid 1 -
步骤二:配置三层交换机SW2。
####配置三层交换机
[SW2]int g0/0/2
[SW2-GigabitEthernet0/0/2]port link-type trunk
[SW2-GigabitEthernet0/0/2]port trunk allow-pass vlan all
[SW2-GigabitEthernet0/0/2]int g0/0/1
[SW2-GigabitEthernet0/0/1]port link-type trunk
[SW2-GigabitEthernet0/0/1]port trunk allow-pass vlan all
####配置完成检查配置
[SW2-GigabitEthernet0/0/1]dis port vlan
Port Link Type PVID Trunk VLAN List
-------------------------------------------------------------------------------
GigabitEthernet0/0/1 trunk 1 1-4094
GigabitEthernet0/0/2 trunk 1 1-4094
GigabitEthernet0/0/3 hybrid 1 -
GigabitEthernet0/0/4 hybrid 1 -
GigabitEthernet0/0/5 hybrid 1 -
步骤三:配置路由器。
配置pc3的网关dhcp
[R]int g0/0/1
[R-GigabitEthernet0/0/1]ip address 192.168.1.254 24
[R-GigabitEthernet0/0/1]dhcp select interface
创建vlan,开启dhcp,创建地址池,设置逻辑接口。
[R]vlan batch 10 20
[R]dhcp enable
[R]ip pool dhcp1
[R-ip-pool-dhcp1]gateway-list 192.168.10.254
[R-ip-pool-dhcp1]network 192.168.10.0 mask 24
[R-ip-pool-dhcp1]int g0/0/0.1
[R-GigabitEthernet0/0/0.1]ip address 192.168.10.254 24
[R-GigabitEthernet0/0/0.1]dot1q termination vid 10
[R-GigabitEthernet0/0/0.1]arp broadcast enable
[R-GigabitEthernet0/0/0.1]dhcp select global
[R-GigabitEthernet0/0/0.1]int g0/0/0.2
[R-GigabitEthernet0/0/0.2]ip address 192.168.20.254 24
[R-GigabitEthernet0/0/0.2]dot1q termination vid 20
[R-GigabitEthernet0/0/0.2]arp broadcast enable
[R-GigabitEthernet0/0/0.2]dhcp select interface
配置完成检查配置情况
[R]dis ip interface brief
*down: administratively down
^down: standby
(l): loopback
(s): spoofing
The number of interface that is UP in Physical is 4
The number of interface that is DOWN in Physical is 2
The number of interface that is UP in Protocol is 3
The number of interface that is DOWN in Protocol is 3
Interface IP Address/Mask Physical Protocol
GigabitEthernet0/0/0 unassigned up down
GigabitEthernet0/0/0.1 192.168.10.254/24 up up
GigabitEthernet0/0/0.2 192.168.20.254/24 up up
GigabitEthernet0/0/1 192.168.1.254/24 down down
GigabitEthernet0/0/2 unassigned down down
NULL0 unassigned up up(s)
此时pc开启dhcp服务会自动获取ip。
查看各个pc的ip。
pc1:
pc2:
pc3:
步骤四:测试pc之间的通信。
pc3能与pc2和pc1通信。
pc2能与pc1和pc3通信。
pc1能与pc2和pc3通信。
实验成功。