Chinaunix首页 | 论坛 | 博客
  • 博客访问: 564950
  • 博文数量: 88
  • 博客积分: 7206
  • 博客等级: 少将
  • 技术积分: 1162
  • 用 户 组: 普通用户
  • 注册时间: 2007-10-26 16:04
文章分类

全部博文(88)

文章存档

2011年(3)

2010年(24)

2009年(16)

2008年(45)

分类: 系统运维

2009-04-15 10:40:55

路由器DHCP server的简单配置

 

R1路由作为DHCP serverR2作为PC机,使用命令no ip routing去除路由功能!路由器R1Fa0/0端口与R2Fa0/0端口相连!

R2的配置其实很简单,去除路由功能后,将对应端口配置为dhcpclient即可!

Router>en

Router#conf t

Enter configuration commands, one per line.  End with CNTL/Z.

Router(config)#ho

Router(config)#hostname PC1

PC1(config)#no ip routing (在工程中切忌要谨慎使用,因为他会去掉你所有的路由信息)

PC1(config)#int f0/0

PC1(config-if)#ip address dhcp

 

接下来外面将配置DHCP server了!

Router>en

Router#conf terminal

Enter configuration commands, one per line.  End with CNTL/Z.

Router(config)#hostname R1

R1(config)#no ip domain-lookup

R1(config)#line con 0

R1(config-line)#no exec-timeout

R1(config-line)#logg sy

R1(config-line)#end

R1#

00:18:19: %SYS-5-CONFIG_I: Configured from console by console

R1#conf t

Enter configuration commands, one per line.  End with CNTL/Z.

R1(config)#int f0/0

R1(config-if)#ip add 172.16.1.1 255.255.255.0

R1(config-if)#no sh

R1(config)#ip dhcp pool lyxm

R1(dhcp-config)#network 172.16.1.0  /24

R1(dhcp-config)#default-router 172.16.1.1

R1(dhcp-config)#dns-server 172.16.1.1

R1(dhcp-config)#domain-name c1813.com

R1(dhcp-config)#lease ?

  <0-365>   Days

  infinite  Infinite lease

R1(dhcp-config)#lease infinite

R1(dhcp-config)#exit

R1(config)#ip dhcp excluded-address ?   

  A.B.C.D  Low IP address

 

R1(config)#ip dhcp excluded-address 172.168.1.0

R1(config)#ip dhcp excluded-address 172.168.1.1

R1(config)#ip dhcp excluded-address 172.168.1.255

R1(config)#end

 

使用sh ip dhcp server statistics来查看DHCP的信息统计

R1#sh ip dhcp server statistics

Memory usage         13597

Address pools        1

Database agents      0

Automatic bindings   0

Manual bindings      0

Expired bindings     0

Malformed messages   0

 

Message              Received

BOOTREQUEST          0

DHCPDISCOVER         0

DHCPREQUEST          0

DHCPDECLINE          0

DHCPRELEASE          0

DHCPINFORM           0

 

Message              Sent

BOOTREPLY            0

DHCPOFFER            0

DHCPACK              0

DHCPNAK              0

此时所有信息都是为0,因为外面还没有开启PC机的端口!

使用sh ip dhcp binding 查看绑定的IP地址

R1#sh ip dhcp binding

IP address       Client-ID/              Lease expiration        Type

                 Hardware address

此时没有任何分配的IP地址,因为PC机的端口没有开启来!

下面外面要去做的事情就是将PC机的端口开启!

PC1#conf t

PC1(config)#int f0/0

PC1(config-if)#no sh

 

此时外面再去R1上使用以上两个命令去查看!

R1#sh ip dhcp server statistics

Memory usage         13700

Address pools        1

Database agents      0

Automatic bindings   1

Manual bindings      0

Expired bindings     0

Malformed messages   0

 

Message              Received

BOOTREQUEST          0

DHCPDISCOVER         1

DHCPREQUEST          1

DHCPDECLINE          0

DHCPRELEASE          0

DHCPINFORM           0

 

Message              Sent

BOOTREPLY            0

DHCPOFFER            1

DHCPACK              1

DHCPNAK              0

R1#

此时可以看到address poolsautomatic bindingsdhcpdiscoverdhcprequestdhcpackdhcpnak等收到一个一个信息,因为PC1开始或许DHCP地址了!所以就产生了IP地址dhcp的分配数据!

 

R1#sh ip dhcp binding

IP address       Client-ID/              Lease expiration        Type

                 Hardware address

172.16.1.2       0063.6973.636f.2d63.    Infinite                Automatic

                 6130.312e.3038.6438.

                 2e30.3030.302d.4661.

                 302f.30

阅读(1569) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~