三層交換機配置DHCP解決方案解決方案:
一,如果不用交換機的DHCP功能而是利用PC的DHCP功能! 1.在交換機上配置DHCP服務器: ip dhcp-server 192.168.0.69 2.在交換機中為每個VLAN設置同樣的DHCP服務器的IP地址: interface Vlan11 ip address 192.168.1.254 255.255.255.0 ip helper-address 192.168.0.69 DHCP Server IP interface Vlan12 ip address 192.168.2.254 255.255.255.0 ip helper-address 192.168.0.69 DHCP Server IP 3.在DHCP服務器上設置網絡地址分別為192.168.1.0、192.168.2.0的作用域,并將這些作用域的“路 由器”選項設置為對應VLAN的接口IP地址。 二 利用三層交換機自帶的DHCP功能實現(xiàn)多VLAN的IP地址自動分配 (一) 配置方法一 1.同時為多個VLAN的客戶機分配地址 2.VLAN內有部分地址采用手工分配的方式 3.為客戶指定網關、Wins服務器等 4.VLAN 2的地址租用有效期限為1天,其它為3天 5.按MAC地址為特定用戶分配指定的IP地址 最終配置如下: ip dhcp excluded-address 10.1.1.1 10.1.1.19 //不用于動態(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 //動態(tài)分配的地址段 domain-name client.com //為客戶機配置域后綴 dns-server 10.1.1.1 10.1.1.2 //為客戶機配置dns服務器 netbios-name-server 10.1.1.5 10.1.1.6 //為客戶機配置wins服務器 netbios-node-type h-node //為客戶機配置節(jié)點模式(影響名稱解釋的順利,如h-node=先通過wins服務 器解釋...) 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 //為客戶機配置默認網關 ! 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地址為...的機器分配...地址 host 10.1.1.21 255.255.255.0 client-identifier 010050.bade.6384 //client-identifier=01加上客戶機網卡地址 ! ip dhcp pool vlan1_tom host 10.1.1.50 255.255.255.0 client-identifier 010010.3ab1.eac8 相關的DHCP調試命令: no service dhcp //停止DHCP服務[默認為啟用DHCP服務] sh ip dhcp binding //顯示地址分配情況 show ip dhcp conflict //顯示地址沖突情況 debug ip dhcp server {events | packets | linkage} //觀察DHCP服務器工作情況 如果DHCP客戶機分配不到IP地址,常見的原因有兩個。第一種情況是沒有把連接客戶機的端口設置為 Portfast方式。MS客戶機開機后檢查網卡連接正常,Link是UP的,就開始發(fā)送DHCPDISCOVER請求,而此時 交換機端口正在經歷生成樹計算,一般需要30-50秒才能進入轉發(fā)狀態(tài)。MS客戶機沒有收到DHCP SERVER的 響應就會給網卡設置一個169.169.X.X的IP地址。解決的方法是把交換機端口設置為Portfast方式: CatOS(4000/5000/6000): set spantree portfast mod_num/port_num enable; IOS(2900/3500): interface ... ; spanning-tree portfast (二) 配置方法二 一臺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服務器實現(xiàn)功能: 各VLAN保留2-10的IP地址不分配置,例如:192.168.2.0的網段,保留192.168.2.2至192.168.2.10的IP地址 段不分配. 安全要求: VLAN 3和VLAN 4 不允許互相訪問,但都可以訪問服務器所在的VLAN 2, 默認訪問控制列表的規(guī)則是拒絕所有包. 配置命令及步驟如下: 第一步:創(chuàng)建VLAN: Switch>en Switch#Vlan Database Switch(Vlan)>Vlan 2 Name server Switch(Vlan)>Vlan 3 Name work01 Switch(vlan)>Vlan 4 Name work02 第二步:設置VLAN IP地址: Switch#Config T Switch(Config)>Int Vlan 2 Switch(Config-vlan)Ip Address 192.168.2.1 255.255.255.0 Switch(Config-vlan)No Shut Switch(Config-vlan)>Int Vlan 3 Switch(Config-vlan)Ip Address 192.168.3.1 255.255.255.0 Switch(Config-vlan)No Shut Switch(Config-vlan)>Int Vlan 4 Switch(Config-vlan)Ip Address 192.168.4.1 255.255.255.0 Switch(Config-vlan)No Shut Switch(Config-vlan)Exit /*注意:由于此時沒有將端口分配置到VLAN2,3,4,所以各VLAN會DOWN掉,待將端口分配到各VLAN后,V LAN會起來*/ 第三步:設置端口全局參數(shù) Switch(Config)Interface Range Fa 0/1 - 24 Switch(Config-if-range)Switchport Mode Access Switch(Config-if-range)Spanning-tree Portfast 第四步:將端口添加到VLAN2,3,4中 /*將端口1-8添加到VLAN 2*/ Switch(Config)Interface Range Fa 0/1 - 8 Switch(Config-if-range)Switchport Access Vlan 2 /*將端口9-16添加到VLAN 3*/ Switch(Config)Interface Range Fa 0/9 - 16 Switch(Config-if-range)Switchport Access Vlan 3 /*將端口17-24添加到VLAN 4*/ Switch(Config)Interface Range Fa 0/17 - 24 Switch(Config-if-range)Switchport Access Vlan 4 Switch(Config-if-range)Exit /*經過這一步后,各VLAN會起來*/ 第五步:配置3550作為DHCP服務器 /*VLAN 2可用地址池和相應參數(shù)的配置,有幾個VLAN要設幾個地址池*/ Switch(Config)Ip Dhcp Pool Test01 /*設置可分配的子網*/ Switch(Config-pool)Network 192.168.2.0 255.255.255.0 /*設置DNS服務器*/ Switch(Config-pool)Dns-server 192.168.2.10 /*設置該子網的網關*/ Switch(Config-pool)Default-router 192.168.2.1 /*配置VLAN 3所用的地址池和相應參數(shù)*/ Switch(Config)Ip Dhcp Pool Test02 Switch(Config-pool)Network 192.168.3.0 255.255.255.0 Switch(Config-pool)Dns-server 192.168.2.10 Switch(Config-pool)Default-router 192.168.3.1 /*配置VLAN 4所用的地址池和相應參數(shù)*/ Switch(Config)Ip Dhcp Pool Test03 Switch(Config-pool)Network 192.168.4.0 255.255.255.0 Switch(Config-pool)Dns-server 192.168.2.10 Switch(Config-pool)Default-router 192.168.4.1 第六步:設置DHCP保留不分配的地址 Switch(Config)Ip Dhcp Excluded-address 192.168.2.2 192.168.2.10 Switch(Config)Ip Dhcp Excluded-address 192.168.3.2 192.168.3.10 Switch(Config)Ip Dhcp Excluded-address 192.168.4.2 192.168.4.10 第七步:啟用路由 /*路由啟用后,各VLAN間主機可互相訪問*/ Switch(Config)Ip Routing 第八步:配置訪問控制列表 Switch(Config)access-list 103 permit ip 192.168.2.0 0.0.0.255 192.168.3.0 0.0.0.255 Switch(Config)access-list 103 permit ip 192.168.3.0 0.0.0.255 192.168.2.0 0.0.0.255 Switch(Config)access-list 103 permit udp any any eq bootpc Switch(Config)access-list 103 permit udp any any eq tftp Switch(Config)access-list 103 permit udp any eq bootpc any Switch(Config)access-list 103 permit udp any eq tftp any Switch(Config)access-list 104 permit ip 192.168.2.0 0.0.0.255 192.168.4.0 0.0.0.255 Switch(Config)access-list 104 permit ip 192.168.4.0 0.0.0.255 192.168.2.0 0.0.0.255 Switch(Config)access-list 104 permit udp any eq tftp any Switch(Config)access-list 104 permit udp any eq bootpc any Switch(Config)access-list 104 permit udp any eq bootpc any Switch(Config)access-list 104 permit udp any eq tftp any 第九步:應用訪問控制列表 /*將訪問控制列表應用到VLAN 3和VLAN 4,VLAN 2不需要*/ Switch(Config)Int Vlan 3 Switch(Config-vlan)ip access-group 103 out Switch(Config-vlan)Int Vlan 4 Switch(Config-vlan)ip access-group 104 out 第十步:結束并保存配置 Switch(Config-vlan)End Switch#Copy Run Start |
|
|