在三層交換機配置DHCP的方法分享
發(fā)布時間:2012-09-20 15:37:19 作者:佚名
我要評論

通過本實驗掌握,如何在Cisco Catalyst 3550交換機來配置DHCP服務,實現(xiàn)對內(nèi)網(wǎng)主機分配IP地址,網(wǎng)關(guān),DNS,WINS,租期,域名等
通過本實驗掌握,如何在Cisco Catalyst 3550交換機來配置DHCP服務,實現(xiàn)對內(nèi)網(wǎng)主機分配IP地址,網(wǎng)關(guān),DNS,WINS,租期,域名等??赡苣阒笆窃趙indows Server服務器或者Cisco Router 部署過DHCP,但在工程項目中,根據(jù)需求,大多是在接入層或者匯聚層多層交換機來配置的,可以同時實現(xiàn)DHCP Snooping等技術(shù)。
實驗過程:
第一步:Catalyst 3550底層配置
Switch(config)#no ip do lo
Switch(config)#line con 0
Switch(config-line)#no exec-t
Switch(config-line)#logg syn
Switch(config-line)#host Switch_Dhcp
Switch_Dhcp(config)#int f0/1
Switch_Dhcp(config-if)#no sh
Switch_Dhcp(config-if)#spanning-tree portfast
//連接終端的接口下,開啟portfast特性,跳過生成樹的選舉,接口立即進入轉(zhuǎn)發(fā)狀態(tài)
%Warning: portfast should only be enabled on ports connected to a single
host. Connecting hubs, concentrators, switches, bridges, etc... to this
interface when portfast is enabled, can cause temporary bridging loops.
Use with CAUTION
%Portfast has been configured on FastEthernet0/1 but will only
have effect when the interface is in a non-trunking mode.
Switch_Dhcp(config-if)#end
第二步: 開啟DHCP服務,定義分配地址池范圍及掩碼,網(wǎng)關(guān),DNS,域名,租期等
//全局下開啟DHCP服務,該服務默認是關(guān)閉的
Switch_Dhcp(config)#service dhcp
//關(guān)閉DHCP分配沖突,日志記錄消息
Switch_Dhcp(config)#no ip dhcp conflict logging
//創(chuàng)建DHCP地址池,名稱為可以是任意字符
Switch_Dhcp(config)#ip dhcp pool cisco
//指定要通過DHCP分配的網(wǎng)段和掩碼,還有另外一種寫法(192.168.0.0 255.255.255.0)
Switch_Dhcp(dhcp-config)#network 192.168.0.0 /24
//指定分配的網(wǎng)關(guān)地址
Switch_Dhcp(dhcp-config)#default-router 192.168.0.1
//指定DHCP域名,域名可以為任意字符
Switch_Dhcp(dhcp-config)#domain-name www.cisco.com.cn
//指定PC通過DHCP分配到DNS地址,(這里指定的是當?shù)仉娦挪块T的真實地址,全國各地市不一樣的)
Switch_Dhcp(dhcp-config)#dns 218.30.19.40 61.134.1.4
//netbios服務器地址,可選的配置
Switch_Dhcp(dhcp-config)#netbios-name-server 192.168.0.10
//指定通過DHCP分配到地址,租期為永久
Switch_Dhcp(dhcp-config)#lease infinite
Switch_Dhcp(dhcp-config)#end
//指定不通過DHCP 地址池中分配的地址,也就是排除的地址。如果這些地址被分配給PC使用,就有可能造成網(wǎng)絡中IP地址沖突。如:192.168.0.1 是網(wǎng)關(guān)地址,該地址只能是分配所有PC做網(wǎng)關(guān)地址,不能做IP地址使用。所以要排除。
Switch_Dhcp(config)#ip dhcp excluded-address 192.168.0.1
Switch_Dhcp(config)# ip dhcp excluded-address 192.168.0.10
第三步:查看VLAN信息,并啟用SVI接口
Switch_Dhcp#show vlan brief
VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
1 default active Fa0/1, Fa0/2, Fa0/3, Fa0/4
Fa0/5, Fa0/6, Fa0/7, Fa0/8
Fa0/9, Fa0/10, Fa0/11, Fa0/12
Fa0/13, Fa0/15, Fa0/16, Fa0/17
Fa0/18, Fa0/19, Fa0/20, Fa0/21
Fa0/22, Fa0/23, Fa0/24, Gi0/1
Gi0/2
1002 fddi-default act/unsup
1003 token-ring-default act/unsup
1004 fddinet-default act/unsup
1005 trnet-default act/unsup
Switch_Dhcp#conf t
Enter configuration commands, one per line. End with CNTL/Z.
//進入管理VLAN1 下,啟用SVI功能
Switch_Dhcp(config)#int vlan 1
//配置VLAN的地址為192.168.0.1 掩碼為24位,默認情況下Cisco Catalyst交換機所有的物理接口都屬于VLAN1,此地址也就是PC網(wǎng)關(guān)地址。
Switch_Dhcp(config-if)#ip add 192.168.0.1 255.255.255.0
Switch_Dhcp(config-if)#no sh
Switch_Dhcp(config-if)#end
Switch_Dhcp#
00:09:07: %SYS-5-CONFIG_I: Configured from console by console
Switch_Dhcp#
00:09:08: %LINK-3-UPDOWN: Interface Vlan1, changed state to up
00:09:09: %LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan1, changed state to
第四步:查看當前交換機配置文件
//驗證DHCP的配置信息
Switch_Dhcp#sh run | begin ip dhcp
no ip dhcp conflict logging
ip dhcp excluded-address 192.168.0.1
ip dhcp excluded-address 192.168.0.10
!
ip dhcp pool cisco
network 192.168.0.0 255.255.255.0
default-router 192.168.0.1
domain-name www.cisco.com.cn
dns-server 218.30.19.40 61.134.1.4
netbios-name-server 192.168.0.10
lease infinite
interface Vlan1
ip address 192.168.0.1 255.255.255.0
第五步:此時將PC1的網(wǎng)線插入Catalyst 3550 的F0/1接口,并在PC上查看IP地址獲得信息。PC上的本地連接,TCP/IP 設置為自動獲得IP地址形式。
PC上查看方法:開始-運行-cmd-ipconfig/all
從以上信息可以得出,PC已經(jīng)能從DHCP服務器獲得IP地址等信息,實驗現(xiàn)象成功。
第六步:查看交換機DHCP 動態(tài)綁定,以及交換機DHCP Server狀態(tài)信息
//查看DHCP動態(tài)綁定信息,從這里可以看到PC,從DHCP地址池中的得到IP地址,以及PC的MAC地址等
Switch_Dhcp#show ip dhcp binding
IP address Client-ID/ Lease expiration Type
Hardware address
192.168.0.2 0100.16d3.249f.fd Infinite Automatic
//查看DHCP服務器工作狀態(tài)
Switch_Dhcp#show ip dhcp server statistics
Memory usage 5661
Address pools 1
Database agents 0
Automatic bindings 1
Manual bindings 0
Expired bindings 0
Malformed messages 0
Message Received
BOOTREQUEST 0
DHCPDISCOVER 2
DHCPREQUEST 3
DHCPDECLINE 0
DHCPRELEASE 0
DHCPINFORM 3
Message Sent
BOOTREPLY 0
DHCPOFFER 2
DHCPACK 6
DHCPNAK 0
Switch_Dhcp#
Switch_Dhcp#clear ip dhcp binding *
第七步:使用debug 調(diào)試命令查看PC申請IP地址過程(DHCP工作過程)
在PC上:開始-運行-cmd-ipconfig /release (釋放獲得IP地址)
重新申請IP地址ipconfig /renew
此時查看交換機日志信息
Switch_Dhcp#debug ip dhcp server events
01:13:12: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
Switch_Dhcp#
01:13:13: DHCPD: DHCPDISCOVER received from client 0100.16d3.249f.fd on interface Vlan1.
Switch_Dhcp#
01:13:20: DHCPD: assigned IP address 192.168.0.3 to client 0100.16d3.249f.fd.
01:13:20: DHCPD: Sending DHCPOFFER to client 0100.16d3.249f.fd (192.168.0.3).
01:13:20: DHCPD: broadcasting BOOTREPLY to client 0016.d324.9ffd.
01:13:20: DHCPD: DHCPREQUEST received from client 0100.16d3.249f.fd.
01:13:20: DHCPD: Sending DHCPACK to client 0100.16d3.249f.fd (192.168.0.3).
01:13:20: DHCPD: broadcasting BOOTREPLY to client 0016.d324.9ffd.
Switch_Dhcp#
01:13:23: DHCPD: DHCPINFORM received from client 0100.16d3.249f.fd (192.168.0.3).
01:13:23: DHCPD: Sending DHCPACK to client 0100.16d3.249f.fd (192.168.0.3).
01:13:23: DHCPD: unicasting BOOTREPLY to client 0016.d324.9ffd (192.168.0.3).
本文出自 “王萬利的博客” 博客

實驗過程:
第一步:Catalyst 3550底層配置
Switch(config)#no ip do lo
Switch(config)#line con 0
Switch(config-line)#no exec-t
Switch(config-line)#logg syn
Switch(config-line)#host Switch_Dhcp
Switch_Dhcp(config)#int f0/1
Switch_Dhcp(config-if)#no sh
Switch_Dhcp(config-if)#spanning-tree portfast
//連接終端的接口下,開啟portfast特性,跳過生成樹的選舉,接口立即進入轉(zhuǎn)發(fā)狀態(tài)
%Warning: portfast should only be enabled on ports connected to a single
host. Connecting hubs, concentrators, switches, bridges, etc... to this
interface when portfast is enabled, can cause temporary bridging loops.
Use with CAUTION
%Portfast has been configured on FastEthernet0/1 but will only
have effect when the interface is in a non-trunking mode.
Switch_Dhcp(config-if)#end
第二步: 開啟DHCP服務,定義分配地址池范圍及掩碼,網(wǎng)關(guān),DNS,域名,租期等
//全局下開啟DHCP服務,該服務默認是關(guān)閉的
Switch_Dhcp(config)#service dhcp
//關(guān)閉DHCP分配沖突,日志記錄消息
Switch_Dhcp(config)#no ip dhcp conflict logging
//創(chuàng)建DHCP地址池,名稱為可以是任意字符
Switch_Dhcp(config)#ip dhcp pool cisco
//指定要通過DHCP分配的網(wǎng)段和掩碼,還有另外一種寫法(192.168.0.0 255.255.255.0)
Switch_Dhcp(dhcp-config)#network 192.168.0.0 /24
//指定分配的網(wǎng)關(guān)地址
Switch_Dhcp(dhcp-config)#default-router 192.168.0.1
//指定DHCP域名,域名可以為任意字符
Switch_Dhcp(dhcp-config)#domain-name www.cisco.com.cn
//指定PC通過DHCP分配到DNS地址,(這里指定的是當?shù)仉娦挪块T的真實地址,全國各地市不一樣的)
Switch_Dhcp(dhcp-config)#dns 218.30.19.40 61.134.1.4
//netbios服務器地址,可選的配置
Switch_Dhcp(dhcp-config)#netbios-name-server 192.168.0.10
//指定通過DHCP分配到地址,租期為永久
Switch_Dhcp(dhcp-config)#lease infinite
Switch_Dhcp(dhcp-config)#end
//指定不通過DHCP 地址池中分配的地址,也就是排除的地址。如果這些地址被分配給PC使用,就有可能造成網(wǎng)絡中IP地址沖突。如:192.168.0.1 是網(wǎng)關(guān)地址,該地址只能是分配所有PC做網(wǎng)關(guān)地址,不能做IP地址使用。所以要排除。
Switch_Dhcp(config)#ip dhcp excluded-address 192.168.0.1
Switch_Dhcp(config)# ip dhcp excluded-address 192.168.0.10
第三步:查看VLAN信息,并啟用SVI接口
復制代碼
代碼如下:Switch_Dhcp#show vlan brief
VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
1 default active Fa0/1, Fa0/2, Fa0/3, Fa0/4
Fa0/5, Fa0/6, Fa0/7, Fa0/8
Fa0/9, Fa0/10, Fa0/11, Fa0/12
Fa0/13, Fa0/15, Fa0/16, Fa0/17
Fa0/18, Fa0/19, Fa0/20, Fa0/21
Fa0/22, Fa0/23, Fa0/24, Gi0/1
Gi0/2
1002 fddi-default act/unsup
1003 token-ring-default act/unsup
1004 fddinet-default act/unsup
1005 trnet-default act/unsup
Switch_Dhcp#conf t
Enter configuration commands, one per line. End with CNTL/Z.
//進入管理VLAN1 下,啟用SVI功能
Switch_Dhcp(config)#int vlan 1
//配置VLAN的地址為192.168.0.1 掩碼為24位,默認情況下Cisco Catalyst交換機所有的物理接口都屬于VLAN1,此地址也就是PC網(wǎng)關(guān)地址。
Switch_Dhcp(config-if)#ip add 192.168.0.1 255.255.255.0
Switch_Dhcp(config-if)#no sh
Switch_Dhcp(config-if)#end
Switch_Dhcp#
00:09:07: %SYS-5-CONFIG_I: Configured from console by console
Switch_Dhcp#
00:09:08: %LINK-3-UPDOWN: Interface Vlan1, changed state to up
00:09:09: %LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan1, changed state to
第四步:查看當前交換機配置文件
復制代碼
代碼如下://驗證DHCP的配置信息
Switch_Dhcp#sh run | begin ip dhcp
no ip dhcp conflict logging
ip dhcp excluded-address 192.168.0.1
ip dhcp excluded-address 192.168.0.10
!
ip dhcp pool cisco
network 192.168.0.0 255.255.255.0
default-router 192.168.0.1
domain-name www.cisco.com.cn
dns-server 218.30.19.40 61.134.1.4
netbios-name-server 192.168.0.10
lease infinite
interface Vlan1
ip address 192.168.0.1 255.255.255.0
第五步:此時將PC1的網(wǎng)線插入Catalyst 3550 的F0/1接口,并在PC上查看IP地址獲得信息。PC上的本地連接,TCP/IP 設置為自動獲得IP地址形式。
PC上查看方法:開始-運行-cmd-ipconfig/all

從以上信息可以得出,PC已經(jīng)能從DHCP服務器獲得IP地址等信息,實驗現(xiàn)象成功。
第六步:查看交換機DHCP 動態(tài)綁定,以及交換機DHCP Server狀態(tài)信息
復制代碼
代碼如下://查看DHCP動態(tài)綁定信息,從這里可以看到PC,從DHCP地址池中的得到IP地址,以及PC的MAC地址等
Switch_Dhcp#show ip dhcp binding
IP address Client-ID/ Lease expiration Type
Hardware address
192.168.0.2 0100.16d3.249f.fd Infinite Automatic
//查看DHCP服務器工作狀態(tài)
Switch_Dhcp#show ip dhcp server statistics
Memory usage 5661
Address pools 1
Database agents 0
Automatic bindings 1
Manual bindings 0
Expired bindings 0
Malformed messages 0
Message Received
BOOTREQUEST 0
DHCPDISCOVER 2
DHCPREQUEST 3
DHCPDECLINE 0
DHCPRELEASE 0
DHCPINFORM 3
Message Sent
BOOTREPLY 0
DHCPOFFER 2
DHCPACK 6
DHCPNAK 0
Switch_Dhcp#
Switch_Dhcp#clear ip dhcp binding *
第七步:使用debug 調(diào)試命令查看PC申請IP地址過程(DHCP工作過程)
在PC上:開始-運行-cmd-ipconfig /release (釋放獲得IP地址)
重新申請IP地址ipconfig /renew
此時查看交換機日志信息
復制代碼
代碼如下:Switch_Dhcp#debug ip dhcp server events
01:13:12: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
Switch_Dhcp#
01:13:13: DHCPD: DHCPDISCOVER received from client 0100.16d3.249f.fd on interface Vlan1.
Switch_Dhcp#
01:13:20: DHCPD: assigned IP address 192.168.0.3 to client 0100.16d3.249f.fd.
01:13:20: DHCPD: Sending DHCPOFFER to client 0100.16d3.249f.fd (192.168.0.3).
01:13:20: DHCPD: broadcasting BOOTREPLY to client 0016.d324.9ffd.
01:13:20: DHCPD: DHCPREQUEST received from client 0100.16d3.249f.fd.
01:13:20: DHCPD: Sending DHCPACK to client 0100.16d3.249f.fd (192.168.0.3).
01:13:20: DHCPD: broadcasting BOOTREPLY to client 0016.d324.9ffd.
Switch_Dhcp#
01:13:23: DHCPD: DHCPINFORM received from client 0100.16d3.249f.fd (192.168.0.3).
01:13:23: DHCPD: Sending DHCPACK to client 0100.16d3.249f.fd (192.168.0.3).
01:13:23: DHCPD: unicasting BOOTREPLY to client 0016.d324.9ffd (192.168.0.3).
本文出自 “王萬利的博客” 博客
相關(guān)文章
聯(lián)果LG510S-4T2XS怎么樣? 六口全萬兆輕網(wǎng)管交換機拆解
聯(lián)果LG510S4T2XS是一臺”4+2″的全萬兆網(wǎng)管交換機,即擁有四個10G電口和兩個10G光口,下面我們就來看看這款交換機的拆機測評2025-01-172.5G三層網(wǎng)管交換機! TPLINK TL-SE5420不完全拆機測評
TL-SE5420為TP-LINK全新開發(fā)推出的5系列2.5G三層網(wǎng)管交換機,采用新一代高性能硬件和軟件平臺,提供靈活的2.5G接入和高性價比的萬 兆上行端口,下面我們就來看看這款交換機2025-01-07最便宜的8口2.5G網(wǎng)管交換機! 水星SE109 Pro拆機測評
水星SE109 Pro價格很便宜,水星SE109 Pro,外觀、接口,和SE109一樣,區(qū)別Pro是網(wǎng)管型的,下面我們就來看看詳細拆機測評2025-01-032.5G交換機水星SE109值得購買嗎? 水星SE109開箱測評
由于廉價家用2.5G交換機大都采用的是公版方案,因此芯片性能上就不用再做過多比較,只需要考慮品牌和口碑,經(jīng)過多輪篩選最終選擇了水星SE109,下面我們就來看看開箱圖2025-01-03TP-LINK/水星和hasivo交換機怎么選? 三款網(wǎng)管交換機系統(tǒng)功能對比
今天選了三款都是”8+1″的2.5G網(wǎng)管交換機,分別是TP-LINK 水星和hasivo交換機,該怎么選呢?這些交換機功能上有什么區(qū)別?詳細請看下文介紹2025-01-03海思視訊hasivo S5800W-24GT-6SX-SE 網(wǎng)管交換機拆機測評
hasivo S5800W-24GT-6SX-SE 網(wǎng)管交換機拆機,它有24個2.5G口+6個萬兆口,這款交換機怎么樣呢?下面我們就來看看詳細測評2024-12-07交換機單線復用怎么設置? 弱電箱到客廳只有一根網(wǎng)線的解決方案
如何解決弱電箱到客廳只預埋一根線的尷尬局面?在有辦法再增加網(wǎng)線的情況下,就可以使用兮克輕管理交換機做單線復用,輕松解決弱電箱到客廳線路不夠的問題2024-11-18水星SE106 Pro值得購買嗎? 2.5G網(wǎng)管交換機水星SE106 Pro拆機測評
水星SE106Pro是一款高性能的交換機,搭載RTL8372N芯片,支持4個2.5G口和2個10G光口,這款交換機怎么樣呢?詳細請看下文測評2024-11-112.5G/萬兆交換機性價比清單推薦! 百元出頭就能搭建萬兆局域網(wǎng)
2.5G交換機價格降下來了,在選擇交換機和路由器的時候,很糾結(jié),我們搜集、推薦一下有哪些性價比2.5G/萬兆交換機,這些均在百元出頭,還帶萬兆口2024-08-26- 這款交換機現(xiàn)在價格是129元,很懂盆友不知道該不該購買,下面我們就來看看小米千兆交換機SW-108G詳細的拆機圖2024-07-26