DHCP端口設(shè)置命令剖析
作者:佚名
文章中,我們針對(duì)DHCP端口的一些配置內(nèi)容進(jìn)行了講解和介紹。希望本文所提供的代碼以及命令能夠給大家一些幫助。
在一些DHCP服務(wù)器的配置中,少不了端口的設(shè)置。這個(gè)也是對(duì)于路由器和交換機(jī)配置來說非常核心的問題了。用一臺(tái)cisco 3560來做DHCP服務(wù)器,有時(shí)候要啟多個(gè)DHCP來工作。那么我們應(yīng)該怎么做呢。
首先我們要把交換端口關(guān)閉掉,換成L3的接口。配置上IP地址。再來設(shè)置DHCP地址池。我們要讓端口f0/1上來的主機(jī)分配0網(wǎng)段的IP地址,讓f0/2上來的主機(jī)分配1網(wǎng)段,那么,我們就應(yīng)該配置好地址池后,在接口下用到ip help-address 來給客戶端的查詢指定一個(gè)服務(wù)地址。詳細(xì)見配置。以下配置在真實(shí)3560上得到通過。
- Switch#sh run 首先我們看下運(yùn)行中的配置清單
- Switch#sh running-config
- Building configuration...
- Current configuration : 1326 bytes
- !
- version 12.2
- no service pad
- service timestamps debug uptime
- service timestamps log uptime
- no service password-encryption
- !
- hostname Switch
- !
- !
- no aaa new-model
- system mtu routing 1500
- ip subnet-zero
- no ip domain-lookup
- !
- !
- !
- !
- !
- !
- !
- !
- !
- spanning-tree mode pvst
- spanning-tree extend system-id
- !
- vlan internal allocation policy ascending
- !
- !
- !
- !
- interface FastEthernet0/1
- shutdown
- !
- interface FastEthernet0/2
- !
- interface FastEthernet0/3
- !
- interface FastEthernet0/4
- !
- interface FastEthernet0/5
- !
- interface FastEthernet0/6
- !
- interface FastEthernet0/7
- !
- interface FastEthernet0/8
- !
- interface FastEthernet0/9
- !
- interface FastEthernet0/10
- !
- interface FastEthernet0/11
- !
- interface FastEthernet0/12
- !
- interface FastEthernet0/13
- !
- interface FastEthernet0/14
- !
- interface FastEthernet0/15
- !
- interface FastEthernet0/16
- !
- interface FastEthernet0/17
- !
- interface FastEthernet0/18
- !
- interface FastEthernet0/19
- !
- interface FastEthernet0/20
- !
- interface FastEthernet0/21
- !
- interface FastEthernet0/22
- !
- interface FastEthernet0/23
- no switchport
- ip address 192.168.100.1 255.255.255.0
- !
- interface FastEthernet0/24
- !
- interface GigabitEthernet0/1
- !
- interface GigabitEthernet0/2
- !
- interface Vlan1
- no ip address
- !
- ip classless
- ip http server
- ip http secure-server
- !
- !
- !
- control-plane
- !
- !
- line con 0
- line vty 0 4
- login
- line vty 5 15
- login
- !
- end
#p#
- Switch#conf t
- Switch(config)#int fa 0/1 進(jìn)入F0/1
- Switch(config-if)#no switchport 關(guān)閉L2端口
- Switch(config-if)#ip add 10.0.0.1 255.255.255.0 配置IP地址
- Switch(config-if)#no sh 打開端口
- Switch(config-if)#exi
- Switch(config)#int fa 0/2
- Switch(config-if)#no sw
- Switch(config-if)#no switchport
- Switch(config-if)#no sh
- Switch(config-if)#ip add 10.0.1.1 255.255.255.0
- Switch(config-if)#no sh
- Switch(config-if)#exi
- Switch(config)#ip dhcp pool ccna 設(shè)置DHCP組
- Switch(dhcp-config)#network 10.0.0.0 255.255.255.0 地址池
- Switch(dhcp-config)#default-router 10.0.0.254 缺省路由(網(wǎng)關(guān))
- Switch(dhcp-config)#dns-server 202.103.24.68 DNS地址設(shè)置
- Switch(dhcp-config)#lease 365 地址租期
- Switch(dhcp-config)#exi
- Switch(config)#ip dhcp pool ccnp
- Switch(dhcp-config)#network 10.0.1.0 255.255.255.0
- Switch(dhcp-config)#default-router 10.0.1.254
- Switch(dhcp-config)#dns-server 202.103.24.68
- Switch(dhcp-config)#lease 365
- Switch(dhcp-config)#exi
- Switch(config)#ip dhcp excluded-address 10.0.0.1 不參與分配的地址
- Switch(config)#ip dhcp excluded-address 10.0.0.254
- Switch(config)#ip dhcp excluded-address 10.0.1.254
- Switch(config)#ip dhcp excluded-address 10.0.1.1
- Switch(config)#exi
- Switch(config)#int fa 0/1
- Switch(config-if)#ip helper-address 10.0.0.1 指定幫助地址,它將默認(rèn)轉(zhuǎn)發(fā)給8個(gè)UDP服務(wù)
- Switch(config-if)#exi
- Switch(config)#int fa 0/2
- Switch(config-if)#ip helper-address 10.0.1.1
- Switch(config-if)#exi
- Switch#sh run
- Switch#sh running-config
- Building configuration...
#p#
- Current configuration : 1864 bytes
- !
- version 12.2
- no service pad
- service timestamps debug uptime
- service timestamps log uptime
- no service password-encryption
- !
- hostname Switch
- !
- !
- no aaa new-model
- system mtu routing 1500
- ip subnet-zero
- no ip domain-lookup
- ip dhcp excluded-address 10.0.0.1
- ip dhcp excluded-address 10.0.0.254
- ip dhcp excluded-address 10.0.1.254
- ip dhcp excluded-address 10.0.1.1
- !
- ip dhcp pool ccna
- network 10.0.0.0 255.255.255.0
- default-router 10.0.0.254
- dns-server 202.103.24.68
- lease 365
- !
- ip dhcp pool ccnp
- network 10.0.1.0 255.255.255.0
- default-router 10.0.1.254
- dns-server 202.103.24.68
- lease 365
- !
- !
- !
- !
- !
- !
- !
- !
- !
- spanning-tree mode pvst
- spanning-tree extend system-id
- !
- vlan internal allocation policy ascending
- !
- !
- !
- !
- interface FastEthernet0/1
- no switchport
- ip address 10.0.0.1 255.255.255.0
- ip helper-address 10.0.0.1
- !
- interface FastEthernet0/2
- no switchport
- ip address 10.0.1.1 255.255.255.0
- ip helper-address 10.0.1.1
- !
- interface FastEthernet0/3
- !
- interface FastEthernet0/4
- !
- interface FastEthernet0/5
- !
- interface FastEthernet0/6
- !
- interface FastEthernet0/7
- !
- interface FastEthernet0/8
- !
- interface FastEthernet0/9
- !
- interface FastEthernet0/10
- !
- interface FastEthernet0/11
- !
- interface FastEthernet0/12
- !
- interface FastEthernet0/13
- !
- interface FastEthernet0/14
- !
- interface FastEthernet0/15
- !
- interface FastEthernet0/16
- !
- interface FastEthernet0/17
- !
- interface FastEthernet0/18
- !
- interface FastEthernet0/19
- !
- interface FastEthernet0/20
- !
- interface FastEthernet0/21
- !
- interface FastEthernet0/22
- !
- interface FastEthernet0/23
- no switchport
- ip address 192.168.100.1 255.255.255.0
- !
- interface FastEthernet0/24
- !
- Switch#sh arp
- Protocol Address Age (min) Hardware Addr Type Interface
- Internet 10.0.0.2 0 001a.4b58.42a9 ARPA FastEthernet0/1
- Internet 10.0.1.1 - 001e.4a0a.2042 ARPA FastEthernet0/2
- Internet 10.0.0.1 - 001e.4a0a.2041 ARPA FastEthernet0/1
- Internet 192.168.100.1 - 001e.4a0a.2043 ARPA FastEthernet0/23
根據(jù)上面的配置,現(xiàn)在我們只要連接到f0/1口上,那么客戶端分配到的地址將是0網(wǎng)段的地址 ,如果連接到f 0/2口上,那么客戶端將分配到1網(wǎng)段的地址。
help-address的說明:
help-address 缺省轉(zhuǎn)發(fā)的8個(gè)udp服務(wù):time37 , tacacs49 , dns53 , boot/dhcp服務(wù)器67 , boot/dhcp客戶端68 , tftp69 , netbios名字服務(wù)137, netbios數(shù)據(jù)報(bào)服務(wù)138
責(zé)任編輯:佟健
來源:
hi.baidu.com