我們將以上面的拓撲圖為例,router9為dhcp的服務器,為pc4,5,6分配三個不同網段的地址,pool為要分配的三個地址池,我們要把pc4設置為12網段,pc5設置成34網段,pc6設置成56網段
首先為路由器分配ip地址
router9:
en 進入特權模式
config t 進入全局配置模式
interface s0/3/0
ip address 192.168.100.1 255.255.255.0
no shu
exit
interface g0/0
ip address 192.168.12.254 255.255.255.0
no shu
router10:
en 進入特權模式
config t 進入全局配置模式
interface s0/3/0
ip address 192.168.100.2 255.255.255.0
clock rate 6400
no shu
exit
interface s0/3/1
ip address 192.168.200.1 255.255.255.0
clock rate 6400
no shu
interface g0/0
ip address 192.168.34.254 255.255.255.0
no shu
router11:
en 進入特權模式
config t 進入全局配置模式
interface s0/3/0
ip address 192.168.200.2 255.255.255.0
no shu
exit
interface g0/0
ip address 192.168.56.254 255.255.255.0
no shu
ip地址分配完畢,現在配置rip路由,方便路由器之間的通信
router9
在全局配置模式下
router rip
ver 2
network 192.168.12.0
network 192.168.100.0
router10
在全局配置模式下
router rip
ver 2
network 192.168.34.0
network 192.168.100.0
network 192.168.200.0
router11
在全局配置模式下
router rip
ver 2
network 192.168.200.0
network 192.168.56.0
rip配置完畢,現在開始配置dhcp,拓撲圖中的路由器為思科的2911,在模擬器中。dhcp是默認開啟的,所以我們直接定義地址池即可
router9
在全局配置模式下
ip dhcp pool ccie 定義的地址池的名稱
network 192.168.12.0 255.255.255.0 定義地址段
default-router 192.168.12.254 定義網關
exit
ip dhcp excluded-address 192.168.12.254 設置不分配的地址或者地址段,可寫兩個地址,這兩個地址包括之間的地址都為排除的地址
ip dhcp pool qqq 在定義一個地址池
network 192.168.34.0 255.255.255.0
default-router 192.168.34.254
exit
ip dhcp excluded-address 192.168.34.254
ip dhcp pool abc 定義第三個地址池
network 192.168.56.0 255.255.255.0
default-router 192.168.56.254
exit
ip dhcp excluded-address 192.168.56.254
router9的dhcp配置完畢,pc4已經可以分配,但pc5和pc6在其他路由器之下,所以我們這里需要用到dhcp中繼
router10
在全局配置模式下
interface g0/0
ip helper-address 192.168.100.1 離dhcp路由器最近的那個dhcp路由器上的接口
這樣router10的中繼就配置完畢了
router11
在全局配置模式下
interface g0/0
ip helper-address 192.168.100.1
這樣router11的中繼也配置完成了,接下來就可以開啟pc機的dhcp功能獲取地址了