S交換機配置dhcp有“基于全局地址池”和“基于接口地址池”兩種方法。
CE交換機V300版本配置dhcp有“基于全局地址池”和“基于接口地址池”兩種方法。且配置方法和S交換機的一致,需要在接口下配置dhcp select命令。不同的是CE交換機配好功能后需要commit提交。
CE交換機V200版本配置dhcp只有一種方式:基于全局方式的地址池。沒有接口方式地址池。V200版本是先配置dhcp服務和地址池,再配置接口分配地址。且無需在接口下配dhcp select global命令。
如下是dhcp關鍵配置舉例,還有更多功能此處未列舉。現網配置以實際需求為準。案例僅供參考。
【S交換機基于接口地址池配置舉例】
1、配置接口IP地址(步驟1為基礎配置,如已經配置好,可忽略)。
[Switch] vlan batch 10 //創建vlan
[Switch] interface gigabitethernet 0/0/1 //進入GE0/0/1接口
[Switch-GigabitEthernet0/0/1] port link-type access //配置接口vlan類型為access
[Switch-GigabitEthernet0/0/1] port default vlan 10 //配置接口加入vlan10
[Switch-GigabitEthernet0/0/1] quit //退出
[Switch] interface vlanif 10
[Switch-Vlanif10] ip address 10.1.1.1 24 //配置VLANIF10接口地址
[Switch-Vlanif10] quit
2、能dhcp服務。
[Switch] dhcp enable
3、配置接口地址池。配置VLANIF10接口下的客戶端從接口地址池中獲取IP地址和相關網絡參數。
[Switch] interface vlanif 10
[Switch-Vlanif10] dhcp select interface //配置基于接口的dhcp
[Switch-Vlanif10] dhcp server gateway-list 10.1.1.1 //配置網關地址
[Switch-Vlanif10] dhcp server dns-list 10.1.3.1 //(可選)配置dns服務器
[Switch-Vlanif10] dhcp server lease day 30 //(可選)配置租期
[Switch-Vlanif10] dhcp server excluded-ip-address 10.1.1.2 10.1.1.3 //(可選)配置需要排除的IP地址
[Switch-Vlanif10] dhcp server static-bind ip-address 10.1.1.100 mac-address 00e0-fc12-3456 //(可選)配置IP和MAC地址綁定,給固定MAC分配固定IP
[Switch-Vlanif10] dhcp server domain-name //(可選)分配給DHCP客戶端的DNS域名后綴
[Switch-Vlanif10] quit
【S交換機基于全局地址池配置舉例】
1、配置接口IP地址(步驟1為基礎配置,如已經配置好,可忽略)。
[Switch] vlan batch 10 //創建vlan
[Switch] interface gigabitethernet 0/0/1 //進入GE0/0/1接口
[Switch-GigabitEthernet0/0/1] port link-type access //配置接口vlan類型為access
[Switch-GigabitEthernet0/0/1] port default vlan 10 //配置接口加入vlan10
[Switch-GigabitEthernet0/0/1] quit //退出
[Switch] interface vlanif 10
[Switch-Vlanif10] ip address 10.1.1.1 24 //配置VLANIF10接口地址
[Switch-Vlanif10] quit
2、使能DHCP服務。
[Switch] dhcp enable
3、創建地址池并在地址池視圖下為PC配置網關地址、租期和DNS服務器地址;
[Switch] ip pool pool1
[Switch-ip-pool-pool1] network 10.1.1.0 mask 255.255.255.0 //配置dhcp分配的IP范圍
[Switch-ip-pool-pool1] gateway-list 10.1.1.1 //配置網關地址
[Switch-ip-pool-pool1] dns-list 10.1.1.2 //(可選)配置dns服務器
[Switch-ip-pool-pool1] lease day 10 hour 0 minute 0 //(可選)配置租期
[Switch-ip-pool-pool1] excluded-ip-address 10.1.1.2 10.1.1.3 //(可選)配置保留地址,這部分地址不會分配出去
[Switch-ip-pool-pool1] static-bind ip-address 10.1.1.4 mac-address 00e0-fc12-3456 //(可選)配置IP和MAC地址綁定,給固定MAC分配固定IP
[Switch-ip-pool-pool1] domain-name //(可選)分配給DHCP客戶端的DNS域名后綴 [Switch-ip-pool-pool1] quit
[Switch] interface vlanif 10
[Switch-Vlanif10] dhcp select global //配置基于全局地址池的dhcp
[Switch-Vlanif10] quit
【CE交換機(V200版本)配置dhcp服務舉例】
注意:CE交換機配置后需要commit提交才生效)
1、使能DHCP服務。
[~SwitchB] dhcp enable
[~SwitchB] dhcp server request-packet all-interface enable //V2R19 版本后需要配置該命令
[*SwitchB] commit
2、配置IP地址池1的屬性(地址池范圍、DNS地址、出口網關和地址池租期)。
[~SwitchB] ip pool pool1
[*SwitchB-ip-pool-pool1] gateway-list 10.1.1.1
[*SwitchB-ip-pool-pool1] network 10.1.1.0 mask 255.255.255.128
[*SwitchB-ip-pool-pool1] dns-list 10.1.1.2
[*SwitchB-ip-pool-pool1] excluded-ip-address 10.1.1.2
[*SwitchB-ip-pool-pool1] lease day 10
[*SwitchB-ip-pool-pool1] commit
[~SwitchB-ip-pool-pool1] quit
3、配置接口IP地址,以及配置VLANIF接口下地址分配方式。
[~SwitchB] vlan batch 10 //創建vlan10
[*SwitchB] interface 10ge 1/0/1
[*SwitchB-10GE1/0/1] port link-type access //配置接口vlan類型為access
[*SwitchB-10GE1/0/1] port default vlan 10 //配置接口加入vlan10
[*SwitchB-10GE1/0/1] commit //提交
[~SwitchB-10GE1/0/1] quit
[~SwitchB] interface vlanif 10
[*SwitchB-Vlanif10] ip address 10.1.1.1 255.255.255.128 // 配置接口VLANIF10的IP地址
[*SwitchB-Vlanif10] commit
[~SwitchB-Vlanif10] quit