拓扑
第一步
搭建拓扑图(图中的AR1为DHCP服务端)
第二步
划分网段在LSW1里建立VLAN10 、VLAN20、VLAN30、VLAN40网段。
VLAN地址如下:
VLAN10 202.102.192.22/24
VLAN20 202.102.192.191.1/24
VLAN30 202.102.192.189.1/24
VLAN40 202.102.192.188.1/24
第三步
实现VLAN间通讯,PC先设固定IP地址测试。
LSW1上面做一条默认路由 ip router-static 0.0.0.0 0.0.0.0 202.102.192.22
AR1 里面做三条静态路由
ip route-static 202.102.188.0 255.255.255.0 202.102.192.11
ip route-static 202.102.189.0 255.255.255.0 202.102.192.11
ip route-static 202.102.191.0 255.255.255.0 202.102.192.11
**** 第四步****
VLAN间通了之后开始在AR1里面做IP地址池
ip pool vlan20
gateway-list 202.102.191.1
network 202.102.191.0 mask 255.255.255.0
dns-list 11.11.11.11
ip pool vlan30
gateway-list 202.102.189.1
network 202.102.189.0 mask 255.255.255.0
dns-list 22.22.22.22
ip pool vlan40
gateway-list 202.102.188.1
network 202.102.188.0 mask 255.255.255.0
dns-list 33.33.33.33
第五步:
在AR1 G0/0/0端口上输入DHCP选择目标
dhcp select global
第六步:
在LSW1三条VLAN上做中继
interface Vlanif20
ip address 202.102.191.1 255.255.255.0
dhcp select relay
dhcp relay server-ip 202.102.192.22
interface Vlanif30
ip address 202.102.189.1 255.255.255.0
dhcp select relay
dhcp relay server-ip 202.102.192.22
interface Vlanif40
ip address 202.102.188.1 255.255.255.0
dhcp select relay
dhcp relay server-ip 202.102.192.22
第七步:
在PC上启用DHCP获取地址并在之前开启抓包,这是三条ARP请求包
PC1、pc2、pc3获取到的地址信息
具体命令如下
AR1
dhcp enable ##开启DHCP
##G0/0/0下联核心交换机
interface GigabitEthernet0/0/0
ip address 202.102.192.22 255.255.255.0
dhcp select global ##DHCP选择的目标
ip pool vlan20
gateway-list 202.102.191.1 ##网关
network 202.102.191.0 mask 255.255.255.0 ##地址池掩码
dns-list 11.11.11.11 ##DNS
ip pool vlan30
gateway-list 202.102.189.1
network 202.102.189.0 mask 255.255.255.0
dns-list 22.22.22.22
ip pool vlan40
gateway-list 202.102.188.1
network 202.102.188.0 mask 255.255.255.0
dns-list 33.33.33.33
###路由器要去往的网段需要配置静态路由回包
ip route-static 202.102.188.0 255.255.255.0 202.102.192.11
ip route-static 202.102.189.0 255.255.255.0 202.102.192.11
ip route-static 202.102.191.0 255.255.255.0 202.102.192.11
LSW1
dhcp enable
interface Vlanif20
ip address 202.102.191.1 255.255.255.0
dhcp select relay ##选择DHCP中继
dhcp relay server-ip 202.102.192.22 ##服务器地址
interface Vlanif30
ip address 202.102.189.1 255.255.255.0
dhcp select relay
dhcp relay server-ip 202.102.192.22
interface Vlanif40
ip address 202.102.188.1 255.255.255.0
dhcp select relay
dhcp relay server-ip 202.102.192.22
interface GigabitEthernet0/0/1 #上联路由器
port link-type access
port default vlan 10
interface GigabitEthernet0/0/2*#下联交换机TRUNK口*
port link-type trunk
port trunk allow-pass vlan 2 to 4094
interface GigabitEthernet0/0/5 #pc3接口
port link-type access
port default vlan 20
ip route-static 0.0.0.0 0.0.0.0 202.102.192.22 #配置默认路由否则找不到去往AR1的路由;
LSW2*
vlan batch 30 40
interface Ethernet0/0/1 #pc1接口
port link-type access
port default vlan 30
interface Ethernet0/0/2 #pc2接口
port link-type access
port default vlan 40
interface GigabitEthernet0/0/2 #上联交换机TRUNK口
port link-type trunk
port trunk allow-pass vlan 2 to 4094
QQ:481715271