下面我们来对配置DHCP的内容进行一下阐述。对于其过程的步骤以及方法,命令和代码都进行了细致的阐述。
对于DHCP来说,它是一个非常强大的协议。在网络中,它的地位非常重要,可以集中管理IP的调配。那么对于这个协议的相关内容,我们今天主要讲解一下配置DHCP的知识。
网络环境:一台3550EMI交换机,划分三个vlan,vlan2 为服务器所在网络,命名为server,IP地址段为192.168.2.0,子网掩码:255.255.255.0,网关:192.168.2.1,域服务器为windows 2000 advance server,同时兼作DNS服务器,IP地址为192.168.2.10,vlan3为客户机1所在网络,IP地址段为192.168.3.0,子网掩码:255.255.255.0,网关:192.168.3.1命名为work01,vlan4为客户机2所在网络,命名为work02,IP地址段为192.168.4.0,子网掩码:255.255.255.0,网关:192.168.4.1,3550作DHCP服务器,端口1-8划到VLAN 2,端口9-16划分到VLAN 3,端口17-24划分到VLAN 4.
DHCP服务器实现功能:各VLAN保留2-10的IP地址不分配置,例如:192.168.2.0的网段,保留192.168.2.2至192.168.2.10的IP地址段不分配.
安全要求:VLAN 3和VLAN 4 不允许互相访问,但都可以访问服务器所在的VLAN 2,默认访问控制列表的规则是拒绝所有包。
配置DHCP命令及步骤如下:
第一步:创建VLAN:
- Switch>en
- Switch#VlanDatabase
- Switch(Vlan)>Vlan2Nameserver
- Switch(Vlan)>Vlan3Namework01
- Switch(vlan)>Vlan4Namework02
第二步:设置VLAN IP地址:
- Switch#ConfigT
- Switch(Config)>IntVlan2
- Switch(Config-vlan)IpAddress192.168.2.1255.255.255.0
- Switch(Config-vlan)NoShut
- Switch(Config-vlan)>IntVlan3
- Switch(Config-vlan)IpAddress192.168.3.1255.255.255.0
- Switch(Config-vlan)NoShut
- Switch(Config-vlan)>IntVlan4
- Switch(Config-vlan)IpAddress192.168.4.1255.255.255.0
- Switch(Config-vlan)NoShut
- Switch(Config-vlan)Exit
- /*注意:由于此时没有将端口分配置到VLAN2,3,4,所以各VLAN会DOWN掉,待将端口分配到各VLAN后,VLAN会起来*/
第三步:设置端口全局参数
- Switch(Config)InterfaceRangeFa0/1-24
- Switch(Config-if-range)SwitchportModeAccess
- Switch(Config-if-range)Spanning-treePortfast
- 第四步:将端口添加到VLAN2,3,4中
- /*将端口1-8添加到VLAN2*/
- Switch(Config)InterfaceRangeFa0/1-8
- Switch(Config-if-range)SwitchportAccessVlan2
- /*将端口9-16添加到VLAN3*/
- Switch(Config)InterfaceRangeFa0/9-16
- Switch(Config-if-range)SwitchportAccessVlan3
- /*将端口17-24添加到VLAN4*/
- Switch(Config)InterfaceRangeFa0/17-24
- Switch(Config-if-range)SwitchportAccessVlan4
- Switch(Config-if-range)Exit
- /*经过这一步后,各VLAN会起来*/
第五步:用3550配置DHCP服务器
- /*VLAN2可用地址池和相应参数的配置,有几个VLAN要设几个地址池*/
- Switch(Config)IpDhcpPoolTest01
- /*设置可分配的子网*/
- Switch(Config-pool)Network192.168.2.0255.255.255.0
- /*设置DNS服务器*/
- Switch(Config-pool)Dns-server192.168.2.10
- /*设置该子网的网关*/
- Switch(Config-pool)Default-router192.168.2.1
- /*配置VLAN3所用的地址池和相应参数*/
- Switch(Config)IpDhcpPoolTest02
- Switch(Config-pool)Network192.168.3.0255.255.255.0
- Switch(Config-pool)Dns-server192.168.2.10
- Switch(Config-pool)Default-router192.168.3.1
- /*配置VLAN4所用的地址池和相应参数*/
- Switch(Config)IpDhcpPoolTest03
- Switch(Config-pool)Network192.168.4.0255.255.255.0
- Switch(Config-pool)Dns-server192.168.2.10
- Switch(Config-pool)Default-router192.168.4.1
第六步:配置DHCP保留不分配的地址
- Switch(Config)IpDhcpExcluded-address192.168.2.2192.168.2.10
- Switch(Config)IpDhcpExcluded-address192.168.3.2192.168.3.10
- Switch(Config)IpDhcpExcluded-address192.168.4.2192.168.4.10
第七步:启用路由
- /*路由启用后,各VLAN间主机可互相访问*/
- Switch(Config)IpRouting
第八步:配置访问控制列表
- Switch(Config)access-list103permitip192.168.2.00.0.0.255192.168.3.00.0.0.255
- Switch(Config)access-list103permitip192.168.3.00.0.0.255192.168.2.00.0.0.255
- Switch(Config)access-list103permitudpanyanyeqbootpc
- Switch(Config)access-list103permitudpanyanyeqtftp
- Switch(Config)access-list103permitudpanyeqbootpcany
- Switch(Config)access-list103permitudpanyeqtftpany
- Switch(Config)access-list104permitip192.168.2.00.0.0.255192.168.4.00.0.0.255
- Switch(Config)access-list104permitip192.168.4.00.0.0.255192.168.2.00.0.0.255
- Switch(Config)access-list104permitudpanyeqtftpany
- Switch(Config)access-list104permitudpanyeqbootpcany
- Switch(Config)access-list104permitudpanyeqbootpcany
- Switch(Config)access-list104permitudpanyeqtftpany
第九步:应用访问控制列表
- /*将访问控制列表应用到VLAN3和VLAN4,VLAN2不需要*/
- Switch(Config)IntVlan3
- Switch(Config-vlan)ipaccess-group103out
- Switch(Config-vlan)IntVlan4
- Switch(Config-vlan)ipaccess-group104out
第十步:结束并保存配置
- Switch(Config-vlan)End
- Switch#CopyRunStart
知优网 » 配置DHCP代码详解(dhcp配置详细步骤)