了解一些關于路由器配置DHCP的知識還是很重要的,這裡主要分析了Cisco路由器配置DHCP的主要步驟和配置語句。某機關使用Cisco 3620作為IOS DHCP Server,它和内網相連的fastethernet0端口的IP位址為192.168.1.4,二層交換機采用兩台Cisco 2950,三層交換機采用一台Cisco 3550。
在整個網絡中有二個VLAN,為簡化描述,假設每個VLAN都采用24位網絡位址,其中VLAN1的IP位址為192.168.1.254,VLAN2的IP位址為192.168.2.254。在Cisco裝置上實作IOS DHCP Server功能以使各VLAN中的主機自動獲得IP位址。
路由器配置DHCP位址池、附加資訊以及租約期限
路由器配置DHCP伺服器的資料庫被組織成一個樹形結構,樹根是用于動态配置設定的所有網絡段的位址池,樹枝是子網位址池,樹葉是手工綁定給節點的位址。具體操作步驟如下:首先登陸到Cisco 3640路由器上:
- ghq>enable
- Password(輸入路由器的特權密碼)
- ghq #config terminal (進入配置模式)
- Enter configuration commands one per line. End with CNTL/Z.
- ghqconfig # ip dhcp pool global
- ghq dhcp-config #network 192.168.0.0 255.255.0.0(動态配置設定的位址段)
- ghqdhcp-config #domain-name ghq.com(為客戶機配置域字尾)
- ghqdhcp-config #dns-server 192.168.1.1(為客戶機配置DNS伺服器)
- ghqdhcp-config #netbios-name-server 192.168.1.1(為客戶機配置wins伺服器)
- ghqdhcp-config #netbios-node-type h-node(為客戶機配置h節點模式)
- ghqdhcp-config #lease 30 (位址租用期為30天)
- ghqdhcp-config #ip dhcp pool vlan1
- ghqdhcp-config #network 192.168.1.0 255.255.255.0
- ghqdhcp-config#default-router 192.168.1.254
- ghqdhcp-config #ip dhcp pool vlan2
- ghqdhcp-config#network 192.168.2.0 255.255.255.0
- ghqdhcp-config #default-router 192.168.2.254
設定不能用于動态配置設定的IP位址
在整個網絡中,有些IP位址需要靜态的指定給一些特定的裝置,例如路由器端口、wins伺服器以及VLAN的位址等。顯然,這些靜态IP位址是不能用于動态配置設定的,這就需要将它們排除掉。其步驟如下:
- ghqconfig #ip dhcp excluded-address 192.168.1.1 192.168.1.5
- ghqconfig # ip dhcp excluded-address 192.168.1.254
- ghqconfig # ip dhcp excluded-address 192.168.2.254