【实验】DHCPv4

DHCPv4
DHCPv4

实验环境:

操作系统:Mac OS X 10.11.5(当时最新测试版),模拟器:GNS3 IOU for Mac 1.4.5(当时最新版本)
注:当然,只要有思科模拟器都可以做这个实验

实验步骤:

1、先做基础配置:

IOU1的e 0/0配置成ip address dhcp就行。

IOU1:

conf t
int e 0/0
ip address dhcp
no sh

IOU2:

conf t
int e 0/0
ip address 12.1.1.2 255.255.255.0
no sh

int s 2/0
ip add 23.1.1.2 255.255.255.0
no sh

IOU3:

conf t
int s 2/0
ip address 23.1.1.3 255.255.255.0
no sh

2、因为IOU3是DHCP server,接着在IOU3上配置DHCP:

IOU3:

ip dhcp excluded-address 12.1.1.2 —— 排除掉12.1.1.2这个IP地址,因为这个IP地址已经用
在了IOU2上,不能被DHCP分配
ip dhcp pool CCIES
network 12.1.1.0 255.255.255.0 —— 设置要分配的IP地址段

3、注意!因为IOU1发送的DHCP请求是广播,根据这个拓扑来看,IOU1和IOU3不在一个广播域内(或者说一个网段内、一个VLAN内),所以IOU2要中转这个DHCP请求,在IOU2上配置:

IOU2:

int e 0/0
ip helper-address 23.1.1.3 —— DHCP请求将会中转给23.1.1.3

4、这个时候IOU1还是不能通过DHCP得到IP地址,因为IOU2中转DHCP请求时是使用12.1.1.2这个地址作为源地址来中转的;但是IOU3回包的时候,并不知道要怎么去往12.1.1.2,所以还需要:

开启OSPF通告12.1.1.0网段给IOU3,或者使用静态路由,或者把DHCP Server配置成一台主机(关闭路由功能)

如果是要开启OSPF:

IOU2:

router ospf 23
router-id 2.2.2.2
passive-interface e 0/0
上面这句是设置被动口,
会通告该网段但不会向它发送hello包

int e 0/0
ip os 23 a 0

int s 2/0
ip os 23 a 0

IOU3:

router ospf 23
router-id 3.3.3.3

int s 2/0
ip os 23 a 0

如果是要使用静态路由:

IOU3:

ip route 12.1.1.0 255.255.255.0 s 2/0

把IOU3当做主机:

IOU3:

no ip routing
ip default-gateway 23.1.1.2

现在,IOU1就可以在IOU3上申请到IP地址了:

IOU1#
*Apr 14 13:04:45.133: %DHCP-6-ADDRESS_ASSIGN: Interface Ethernet0/0 assigned 
DHCP address 12.1.1.1, mask 255.255.255.0, hostname IOU1

IOU1#sh ip int bri
Interface                IP-Address      OK?   Method   Status      Protocol
Ethernet0/0              12.1.1.1        YES   DHCP     up          up
......

5、下面再跟大家说说两条命令,学习了这两条命令就不用通过shutdown/no shutdown接口的形式重新让DHCP分配IP地址了:

IOU1#release dhcp e 0/0 —— 释放e 0/0接口下从DHCP学习过来的IP地址
IOU1#renew dhcp e 0/0 —— 重新通过DHCP申请IP地址

Not in Bound state.

IOU1#

*Apr 14 13:51:52.863: %DHCP-6-ADDRESS_ASSIGN: Interface Ethernet0/0 assigned 
DHCP address 12.1.1.1, mask 255.255.255.0, hostname IOU1

IOU1#

6、上述DHCP配置的汇总:

IOU1:

conf t
int e 0/0
ip address dhcp
no sh

IOU2:

conf t
int e 0/0
ip address 12.1.1.2 255.255.255.0
ip helper-address 23.1.1.3
no sh

int s 2/0
ip add 23.1.1.2 255.255.255.0
no sh

—————————————
! 要么开启OSPF

router ospf 23
router-id 2.2.2.2
passive-interface e 0/0

int e 0/0
ip os 23 a 0

int s 2/0
ip os 23 a 0

IOU3:

conf t
int s 2/0
ip address 23.1.1.3 255.255.255.0
no sh

ip dhcp excluded-address 12.1.1.2
ip dhcp pool CCIES
network 12.1.1.0 255.255.255.0

————————————————
! 要么开启OSPF

router ospf 23
router-id 3.3.3.3

int s 2/0
ip os 23 a 0

————————————————
!要么使用静态路由

ip route 12.1.1.0 255.255.255.0 s 2/0

————————————————
! 要么把IOU3当做主机

no ip routing
ip default-gateway 23.1.1.2

 

其他相关文章:

这篇文章对你有帮助吗?

相关文章

发表评论?

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据