Cisco 3560 配置DHCP Relay实例
網(wǎng)絡(luò)環(huán)境:一臺(tái)3560交換機(jī),劃分三個(gè)vlan,vlan2為服務(wù)器所在網(wǎng)絡(luò),命名為server,IP地址段為192.168.2.0,子網(wǎng)掩碼:255.255.255.0,網(wǎng)關(guān):192.168.2.1,域服務(wù)器為windows2000advanceserver,同時(shí)兼作DHCP服務(wù)器,DNS服務(wù)器,IP地址為192.168.2.10,vlan3為客戶機(jī)1所在網(wǎng)絡(luò),IP地址段為192.168.3.0,子網(wǎng)掩碼:255.255.255.0,網(wǎng)關(guān):192.168.3.1命名為work01,vlan4為客戶機(jī)2所在網(wǎng)絡(luò),命名為work02,IP地址段為192.168.4.0,子網(wǎng)掩碼:255.255.255.0,網(wǎng)關(guān):192.168.4.1.
3560上端口1-8劃到VLAN2,端口9-16劃分到VLAN3,端口17-24劃分到VLAN4.
配置命令及步驟如下:
第一步:創(chuàng)建VLAN:
Switch>VlanDatabase
Switch(Vlan)>Vlan2Nameserver
Switch(Vlan)>Vlan3Namework01
Switch(vlan)>Vlan4Namework02
第二步:啟用DHCP中繼代理:
/*關(guān)鍵一步,若缺少以下兩條命令,在VLAN中使用“IPHELPER-ADDRESSDHCP服務(wù)器地址”指定DHCP服務(wù)器,客戶機(jī)仍然不能獲得IP地址*/
Switch>Enable
Switch#Configt
Switch(Config)ServiceDhcp
Switch(Config)Ip Dhcp Relay Information Option? (cisco3550需要配置,其他不需要)
第三步:設(shè)置VLANIP地址:
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
/*注意:由于此時(shí)沒有將端口分配置到VLAN2,3,4,所以各VLAN會(huì)DOWN掉,待將端口分配到各VLAN后,VLAN會(huì)起來*/
第四步:設(shè)置端口全局參數(shù)
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
/*經(jīng)過這一步后,各VLAN會(huì)起來*/
第六步:在VLAN3和4中設(shè)定DHCP服務(wù)器地址
/*VLAN2中不須指定DHCP服務(wù)器地址*/
Switch(Config)IntVlan3
Switch(Config-vlan)IpHelper-address192.168.2.10
Switch(Config)IntVlan4
Switch(Config-vlan)IpHelper-address192.168.2.10
第七步:啟用路由
/*路由啟用后,各VLAN間主機(jī)可互相訪問,若需進(jìn)一步控制訪問權(quán)限,則需應(yīng)用到訪問控制列表*/
Switch(Config)IpRouting
第八步:結(jié)束并保存配置
Switch(Config-vlan)End
Switch#CopyRunStart
怎樣配置以cisco 3560的DHCP
?
1.同時(shí)為多個(gè)VLAN的客戶機(jī)分配地址
2.VLAN內(nèi)有部分地址采用手工分配的方式
3.為客戶指定網(wǎng)關(guān)、Wins服務(wù)器等
4.VLAN 2的地址租用有效期限為1天,其它為3天
5.按MAC地址為特定用戶分配指定的IP地址
最終配置如下:
ip dhcp excluded-address 10.1.1.1 10.1.1.19 //不用于動(dòng)態(tài)地址分配的地址
ip dhcp excluded-address 10.1.1.240 10.1.1.254
ip dhcp excluded-address 10.1.2.1 10.1.2.19
!
ip dhcp pool global //global是pool name, 由用戶指定
network 10.1.0.0 255.255.0.0 //動(dòng)態(tài)分配的地址段
domain-name client.com //為客戶機(jī)配置域后綴
dns-server 10.1.1.1 10.1.1.2 //為客戶機(jī)配置dns服務(wù)器
netbios-name-server 10.1.1.5 10.1.1.6 //為客戶機(jī)配置wins服務(wù)器
netbios-node-type h-node //為客戶機(jī)配置節(jié)點(diǎn)模式(影響名稱解釋的順利,如h-node=先通過wins服務(wù)器解釋...)
lease 3 //地址租用期限: 3天
ip dhcp pool vlan1
network 10.1.1.0 255.255.255.0 //本pool是global的子pool, 將從global pool繼承domain-name等option
default-router 10.1.1.100 10.1.1.101 //為客戶機(jī)配置默認(rèn)網(wǎng)關(guān)
!
ip dhcp pool vlan2 //為另一VLAN配置的pool
network 10.1.2.0 255.255.255.0
default-router 10.1.2.100 10.1.2.101
lease 1
!
ip dhcp pool vlan1_john //總是為MAC地址為...的機(jī)器分配...地址
host 10.1.1.21 255.255.255.0
client-identifier 010050.bade.6384 //client-identifier=01加上客戶機(jī)網(wǎng)卡地址
!
ip dhcp pool vlan1_tom
host 10.1.1.50 255.255.255.0
client-identifier 010010.3ab1.eac8
相關(guān)的DHCP調(diào)試命令:
no service dhcp //停止DHCP服務(wù)[默認(rèn)為啟用DHCP服務(wù)]
sh ip dhcp binding //顯示地址分配情況
show ip dhcp conflict //顯示地址沖突情況
debug ip dhcp server {events | packets | linkage} //觀察DHCP服務(wù)器工作情況
如果DHCP客戶機(jī)分配不到IP地址,常見的原因有兩個(gè)。第一種情況是沒有把連接客戶機(jī)的端口設(shè)置為Portfast方式。MS客戶機(jī)開機(jī)后檢查網(wǎng)卡連接正常,Link是UP的,就開始發(fā)送DHCPDISCOVER請(qǐng)求,而此時(shí)交換機(jī)端口正在經(jīng)歷生成樹計(jì)算,一般需要30-50秒才能進(jìn)入轉(zhuǎn)發(fā)狀態(tài)。MS客戶機(jī)沒有收到DHCP SERVER的響應(yīng)就會(huì)給網(wǎng)卡設(shè)置一個(gè)169.169.X.X的IP地址。解決的方法是把交換機(jī)端口設(shè)置為Portfast方式:CatOS(4000/5000/6000): set spantree portfast mod_num/port_num enable; IOS(2900/3500): interface ... ; spanning-tree portfast。
另外一種情況是DHCP服務(wù)器和DHCP工作站不在同一個(gè)VLAN,這時(shí)候通常通過設(shè)置ip helper-address來解決:
interface vlan1
ip address 10.1.1.254 255.255.255.0 //假設(shè)DHCP服務(wù)器地址為10.1.1.8
interface Vlan2
ip address 10.1.2.254 255.255.255.0
ip helper-address 10.1.1.8 //假設(shè)這是DHCP客戶機(jī)所在的VLAN
轉(zhuǎn)載于:https://blog.51cto.com/roubin/1655576
總結(jié)
以上是生活随笔為你收集整理的Cisco 3560 配置DHCP Relay实例的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Nexys4DDR+OV7670实现so
- 下一篇: 基于Nexys4DDR的UART实验