有一次到一公司去面试,问到客户端DHCP的事,我只是简单的把原理说出来,后面试官要我写命令,因刚接触CISCO不久,把命令写得乱七八糟的,最后就把这个工作机会给弄丢了,今天在小凡上面以3725路由器模拟WINDOWS 2003作DHCP服务器,CISCO交换机作DHCP RELAY的一个DHCP网络环境,希望新手看到后,有所收获。
设备:四台3725路由器,SW4作DHCP SERVER,SW1,SW2,SW3作交换机。4台DHCP客户端,一台与DHCP SERVER
数据:SW4作如下DHCP 池
pool vlan2 172.18.1.0 255.255.255.0 gateway 172.18.1.10
pool vlan3 172.18.3.0 255.255.255.0 gateway 172.18.3.254
pool vlan4 172.18.4.0 255.255.255.0 gateway 172.18.4.254
pool vlan5 172.18.5.0 255.255.255.0 gateway 172.18.5.254
f1/1 ip 172.18.1.11(模拟windows的IP地址)
ip route 0.0.0.0 0.0.0.0 172.18.1.10(模拟windows的网关)
SW1交换机划分VLAN 2,VLAN3,VLAN4,VLAN5
VLAN2 IP 172.18.1.10
VLAN3 IP 172.18.3.254
VLAN4 IP 172.18.4.254
VLAN5 IP 172.18.5.254
F1/1 ,F1/4 属于 vlan2,并且f1/4接PC4 (设计目的为,同一 vlan里,应该不要用ip helper-address命令,就可以获取IP)
F1/2属于 vlan3(设计目的为,不同VLAN里,应用ip helper-address命令,可以获取vlan 3的IP)
f1/3 trunk 口(设计目的为,如果dhcp广播通过trunk后,各个vlan应用ip helper-address命令后,能不能获取各自的IP)
SW2交换机
f1/2 接sw1的f1/2
f1/1 接pc1
SW3交换机划分vlan4,vlan5
f1/3 trunk口接sw1的f1/3
f1/1 属于 vlan4 接pc2
f1/2 属于 vlan5接pc3
具体拓朴图如下:
SW1,SW2,SW3,SW4的具体配置分别如下:
R1的具体配置:
R1#sh run
Building configuration...
Current configuration : 1461 bytes
!
version 12.4
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
!
hostname R1
!
boot-start-marker
boot-end-marker
!
!
no aaa new-model
memory-size iomem 5
ip cef
!
!
multilink bundle-name authenticated
!
interface FastEthernet1/0
!
interface FastEthernet1/1
switchport access vlan 2 (把它放到vlan2里,vlan1一般作管理地址)
!
interface FastEthernet1/2
switchport access vlan 3 (接下级交换机,如果下级交换机没有划分vlan,那么这个交换机的所有口都属于vlan3)
!
interface FastEthernet1/3
switchport mode trunk (便于vlan4,vlan5通过trunk口与下级交换机SW3通信)
!
interface FastEthernet1/4
switchport access vlan 2 (这个口接PC,验证同vlan里DHCP情况)
!
interface FastEthernet1/5
!
interface FastEthernet1/6
!
interface Vlan1
no ip address
!
interface Vlan2
ip address 172.18.1.10 255.255.255.0 (设个IP,意为着SW4在vlan2的网络里)
!
interface Vlan3
ip address 172.18.3.254 255.255.255.0
ip helper-address 172.18.1.11 (这里为SW4的IP,即服务器的IP地址)
!
interface Vlan4
ip address 172.18.4.254 255.255.255.0
ip helper-address 172.18.1.11
!
interface Vlan5
ip address 172.18.5.254 255.255.255.0
ip helper-address 172.18.1.11
!
!
ip http server
no ip http secure-server
!
!
control-plane
!
!
line con 0
line aux 0
line vty 0 4
login
!
!
end
=============
R2的具体配置:
R2#sh run
Building configuration...
Current configuration : 1040 bytes
!
version 12.4
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
!
hostname R2
!
boot-start-marker
boot-end-marker
!
!
no aaa new-model
memory-size iomem 5
ip cef
!
!
!
!
multilink bundle-name authenticated
!
interface FastEthernet1/0
!
interface FastEthernet1/1
!
interface FastEthernet1/2
!
interface FastEthernet1/3
!
interface FastEthernet1/4
!
interface FastEthernet1/5
!
interface Vlan1 (这个交换机没有什么配置的,当HUB用)
no ip address
!
!
ip http server
no ip http secure-server
!
!
control-plane
!
!
line con 0
line aux 0
line vty 0 4
login
!
!
end
=========
R3的具体配置:
R3#sh run
Building configuration...
Current configuration : 1243 bytes
!
version 12.4
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
!
hostname R3
!
boot-start-marker
boot-end-marker
!
!
no aaa new-model
memory-size iomem 5
ip cef
!
!
!
!
multilink bundle-name authenticated
!
interface FastEthernet1/0
!
interface FastEthernet1/1
switchport access vlan 4
!
interface FastEthernet1/2
switchport access vlan 5
!
interface FastEthernet1/3
switchport mode trunk (本交换机的vlan4,vlan5数据通过这个口上连至SW)
!
interface FastEthernet1/4
!
interface FastEthernet1/5
!
interface FastEthernet1/6
!
interface FastEthernet1/7
!
interface Vlan1
no ip address
!
interface Vlan4
no ip address
!
interface Vlan5
no ip address
!
!
ip http server
no ip http secure-server
!
!
control-plane
!
!
line con 0
line aux 0
line vty 0 4
login
!
!
end
==============
R4的具体配置:
R4#sh run
Building configuration...
Current configuration : 1774 bytes
!
version 12.4
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
!
hostname R4
!
boot-start-marker
boot-end-marker
!
!
no aaa new-model
memory-size iomem 5
ip cef
!
!
no ip dhcp use vrf connected
!
ip dhcp pool vlan2 (cisco作dhcp服务器的命令)
network 172.18.1.0 255.255.255.0
default-router 172.18.1.10
dns-server 172.18.1.110
netbios-name-server 172.18.1.110
!
ip dhcp pool vlan3
network 172.18.3.0 255.255.255.0
default-router 172.18.3.254
dns-server 172.18.1.110
netbios-name-server 172.18.1.110
!
ip dhcp pool vlan4
network 172.18.4.0 255.255.255.0
default-router 172.18.4.254
netbios-name-server 172.18.1.110
dns-server 172.18.1.110
!
ip dhcp pool vlan5
network 172.18.5.0 255.255.255.0
dns-server 172.18.1.110
netbios-name-server 172.18.1.110
default-router 172.18.5.254
!
!
multilink bundle-name authenticated
!
interface FastEthernet1/0
!
interface FastEthernet1/1
no switchport
ip address 172.18.1.11 255.255.255.0
!
interface FastEthernet1/2
!
interface FastEthernet1/3
!
interface FastEthernet1/4
!
interface FastEthernet1/5
!
interface FastEthernet1/6
!
interface FastEthernet1/7
!
interface Vlan1
no ip address
!
ip route 0.0.0.0 0.0.0.0 172.18.1.10 (模拟windwos服务器的网关)
!
ip http server
no ip http secure-server
!
!
control-plane
!
!
line con 0
line aux 0
line vty 0 4
login
!
!
end
R4#
要注意的地方:
ip helper-address 的地址一定是dhcp server服务器的ip地址,不是dhcp server服务器所在网络的网关。
本文出自 “系统网络运维” 博客,谢绝转载!