Cisco实验:【DHCP配置】客户端跨网段通过DHCP服务器自动获取动态IP和固定IP地址

模拟环境:
R1为路由器e0/0接口和e0/1接口分别连接两个网段,e0/0连接用户区域,e0/1连接服务器区域;
用户区域中SW1为接入层交换机,连接一台PC(R2模拟)和一台打印机(R5模拟);
服务器区域中连接一台DHCP服务器(R3模拟);
要求实现PC通过DHCP服务器自动获取动态IP地址,打印机通过DHCP服务器获取固定IP地址。

R2 模拟PC 获取100.1.1.0/24段内地址
R5 模拟打印机 获取100.1.1.200/24固定地址
SW1 接入层交换机
R1 路由器 e0/0:100.1.1.1/24;e0/1:13.1.1.1/24
R3 模拟DHCP服务器 13.1.1.3/24
*Cisco路由器模拟成PC,关闭路由选择协议 no ip routing,
*指定网关 ip default-gateway x.x.x.x

 

 

 R1配置信息:

Router>enable
Router#configure terminal 
Router(config)#hostname R1
R1(config)#interface ethernet 0/1
R1(config-if)#ip address 13.1.1.1 255.255.255.0
R1(config-if)#no shutdown
R1(config-if)#exit 
R1(config)#interface ethernet 0/0
R1(config-if)#ip address 100.1.1.254 255.255.255.0
R1(config-if)#no shutdown
R1(config-if)#ip helper-address 13.1.1.3    //网关接口设置中继,实现将用户网段内的DHCP请求中继到服务器网段的DHCP服务器获取地址

 

R3配置信息(DHCP Server):

Router>enable
Router#configure terminal 
Router(config)#hostname Server
Server(config)#interface ethernet 0/0
Server(config-if)#ip address 13.1.1.3 255.255.255.0 
Server(config-if)#no shutdown 
Server(config)#service dhcp   //开启DHCP服务
Server(config)#ip dhcp pool CCIE    //创建名为CCIE的地址池
Server(dhcp-config)#network 100.1.1.0 255.255.255.0    //指定网段地址池为100.1.1.0/24
Server(dhcp-config)#default-router 100.1.1.254    //指定网关
Server(dhcp-config)#dns-server 100.1.1.254    //指定DNS服务器
Server(dhcp-config)#domain-name aaa.net    //指定域名
Server(dhcp-config)#lease 1 0 30    //修改租期,天 时 分,默认为1天
Server#show run | section dhcp    //查看DHCP配置信息
ip dhcp pool CCIE
 network 100.1.1.0 255.255.255.0
 default-router 100.1.1.254 
 dns-server 100.1.1.254 
 domain-name aaa.net
 lease 1 0 30
Server(config)#ip dhcp excluded-address 100.1.1.254 100.1.1.254    //排除范围地址不参与分配,从低地址-高地址的一个范围

Server(config)#ip dhcp pool Printer    
Server(dhcp-config)#host 100.1.1.200 255.255.255.0    //指定主机地址池
Server(dhcp-config)#default-router 100.1.1.254
Server(dhcp-config)#dns-server 100.1.1.254
Server(dhcp-config)#domain-name aaa.net
Server(dhcp-config)#lease 3 0 0
Server(dhcp-config)#client-identifier 01aa.bbcc.0050.00    //指定客户端的ID,用于识别该地址分配到指定的设备;01+MAC地址 小数点前移
Server#show run | section dhcp
ip dhcp excluded-address 100.1.1.254
ip dhcp pool CCIE
 network 100.1.1.0 255.255.255.0
 default-router 100.1.1.254 
 dns-server 100.1.1.254 
 domain-name aaa.net
 lease 1 0 30
ip dhcp pool Printer
 host 100.1.1.200 255.255.255.0
 client-identifier 01aa.bbcc.0050.00
 default-router 100.1.1.254 
 dns-server 100.1.1.254 
 domain-name aaa.net
 lease 3

Server(config)#no ip routing    //关闭路由协议,模拟成终端设备
Server(config)#ip default-gateway 13.1.1.1    //设置设备网关

 

R2配置信息(PC):

Router>enable
Router#configure terminal 
Router(config)#hostname PC
PC(config)#no ip routing    //关闭路由协议,模拟成终端设备
PC(config)#interface ethernet 0/0
PC(config-if)#ip address dhcp    //DHCP获取地址
PC(config-if)#no shutdown

 

R5配置信息(Printer):

Router>enable
Router#configure terminal 
Router(config)#hostname Printer
Printer(config)#no ip routing    //关闭路由协议,模拟成终端设备
Printer(config)#interface ethernet 0/0
Printer(config-if)#ip address dhcp client-id ethernet 0/0    //DHCP自动获取地址,获取时出示连接接口的客户端ID用于匹配主机地址池中客户端ID
Printer(config-if)#no shutdown

 

posted @ 2020-04-19 09:47  it_逗逗  阅读(4079)  评论(0编辑  收藏  举报