拓撲圖如上圖所示,R1作爲交換機,DS1作爲多層交換機,AS1,AS2模擬主機。AS1,AS2都自動獲取ip地址,並將R1當作dhcp服務器。
R1其配置如下:
ip dhcp excluded-address 192.168.3.1
ip dhcp excluded-address 192.168.3.2
ip dhcp pool net2
network 192.168.1.0 255.255.255.0
ip dhcp pool net3
network 192.168.2.0 255.255.255.0
no ip domain lookup
interface Loopback0
ip address 1.1.1.1 255.255.255.255
interface FastEthernet0/0
ip address 192.168.3.1 255.255.255.0
router eigrp 1
network 1.1.1.1 0.0.0.0
network 192.168.3.0
DS1的配置如下:
ip routing
interface FastEthernet0/0
no switchport
ip address 192.168.3.2 255.255.255.0
interface FastEthernet0/1
switchport access vlan 2
no ip address
interface FastEthernet0/2
switchport access vlan 3
no ip address
interface Vlan2
ip address 192.168.1.1 255.255.255.0
ip helper-address 192.168.3.2//由於dhcp是以廣播的形式向外發送的,而路由器以及三層交換機是抑制廣播域的,所以要在接口上配置一個輔助接口,來轉發廣播
interface Vlan3
ip address 192.168.2.1 255.255.255.0
ip helper-address 192.168.3.2
router eigrp 1
network 192.168.1.0
network 192.168.2.0
network 192.168.3.0
auto-summary
AS1的配置如下:
no ip routing
int f0/0
ip add dhcp
no shutdown
ip default-gateway 192.168.1.1
AS2的配置如下:
no ip routing
int f0/0
ip add dhcp
no shutdown
ip default-gateway 192.168.2.1