注册 | 登录 忘记密码? 51cto首页 | 博客 | 论坛 | 招聘
热点文章 小五思科技术学习笔记之SSH
 帮助

cisco路由器配置DHCP实例


2007-12-13 18:38:28
版权声明:原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。http://lgzeng2360.blog.51cto.com/275998/54967
RA#sh run                 ----查看当前配置
Building configuration...
Current configuration : 1253 bytes
!
version 12.1
……
!
hostname RA
!
logging rate-limit console 10 except errors
!
ip subnet-zero
no ip finger
ip domain-name svr80
ip host R2 10.0.0.1 1.1.1.2
no ip dhcp conflict logging
ip dhcp excluded-address 192.168.1.1 192.168.1.5   ----全局配置模式下完成
ip dhcp excluded-address 192.168.1.80
ip dhcp pool test
 network 192.168.1.0 255.255.255.0
   default-router 192.168.1.1
   domain-name sky.com
   dns-server 61.139.2.69 192.168.1.80
   lease 6
!
……
end
-----------------------------------------------------------
RA#sh ip dhcp server stat
Memory usage         13634
Address pools        1
Database agents      0
Automatic bindings   1
Manual bindings      0
Expired bindings     0
Malformed messages   0
Message              Received
BOOTREQUEST          0
DHCPDISCOVER         4
DHCPREQUEST          3
DHCPDECLINE          0
DHCPRELEASE          1
DHCPINFORM           0
Message              Sent
BOOTREPLY            0
DHCPOFFER            4
DHCPACK              3
DHCPNAK              0
-----------------------------------------
RA#sh ip dhcp binding
IP address       Hardware address        Lease expiration        Type
192.168.1.81     0100.e04c.4db4.71       Mar 07 1993 12:58 AM    Automatic

本文出自 “lgzeng” 博客,请务必保留此出处http://lgzeng2360.blog.51cto.com/275998/54967





    文章评论
 
2007-12-13 23:24:33
不错的实例

2008-03-27 14:30:06
摘自http://bbs.51cto.com/viewthread.php?tid=955&fpage=1&highlight=dhcp上的配置如下:
一位客户想把DHCP SERVER迁移到6509交换机的MSFC上,要求还挺复杂:
    1.同时为多个VLAN的客户机分配地址
    2.VLAN内有部分地址采用手工分配的方式
    3.为客户指定网关、Wins服务器等
    4.VLAN 2的地址租用有效期限为1天,其它为3天
    5.按MAC地址为特定用户分配指定的IP地址

最终配置如下:      
  ip dhcp excluded-address 10.1.1.1 10.1.1.19     //不用于动态地址分配的地址
  ip dhcp excluded-address 10.1.1.240 10.1.1.254
  ip dhcp excluded-address 10.1.2.1 10.1.2.19
  !
  ip dhcp pool global                     //global是pool name, 由用户指定
  network 10.1.0.0 255.255.0.0           //动态分配的地址段
  domain-name client.com                 //为客户机配置域后缀
  dns-server 10.1.1.1 10.1.1.2                 //为客户机配置dns服务器
  netbios-name-server 10.1.1.5 10.1.1.6           //为客户机配置wins服务器
  netbios-node-type h-node                 //为客户机配置节点模式(影响名称解释的顺利,如h-node=先通过wins服务器解释...)
  lease 3                           //地址租用期限: 3天
  ip dhcp pool vlan1
  network 10.1.1.0 255.255.255.0           //本pool是global的子pool, 将从global pool继承domain-name等option
  default-router 10.1.1.100 10.1.1.101           //为客户机配置默认网关
  !
  ip dhcp pool vlan2                     //为另一VLAN配置的pool
  network 10.1.2.0 255.255.255.0
  default-router 10.1.2.100 10.1.2.101
  lease 1
  !
  ip dhcp pool vlan1_john                 //总是为MAC地址为...的机器分配...地址
  host 10.1.1.21 255.255.255.0
  client-identifier 010050.bade.6384           //client-identifier=01加上客户机网卡地址
  !
  ip dhcp pool vlan1_tom
  host 10.1.1.50 255.255.255.0
  client-identifier 010010.3ab1.eac8

相关的DHCP调试命令:
  no service dhcp                     //停止DHCP服务[默认为启用DHCP服务]
  sh ip dhcp binding                     //显示地址分配情况
  show ip dhcp conflict                 //显示地址冲突情况
  debug ip dhcp server {events | packets | linkage}     //观察DHCP服务器工作情况
 
如果DHCP客户机分配不到IP地址,常见的原因有两个。第一种情况是没有把连接客户机的端口设置为Portfast方式。MS客户机开机后检查网卡连接正常,Link是UP的,就开始发送DHCPDISCOVER请求,而此时交换机端口正在经历生成树计算,一般需要30-50秒才能进入转发状态。MS客户机没有收到DHCP SERVER的响应就会给网卡设置一个169.169.X.X的IP地址。解决的方法是把交换机端口设置为Portfast方式:CatOS(4000/5000/6000): set spantree portfast mod_num/port_num enable; IOS(2900/3500): interface ... ; spanning-tree portfast。
 
另外一种情况是DHCP服务器和DHCP工作站不在同一个VLAN,这时候通常通过设置ip helper-address来解决:      
  interface vlan1
  ip address 10.1.1.254 255.255.255.0          //假设DHCP服务器地址为10.1.1.8
  interface Vlan2
  ip address 10.1.2.254 255.255.255.0
  ip helper-address 10.1.1.8               //假设这是DHCP客户机所在的VLAN


2008-03-27 14:33:11
3550#show run
Building configuration...

Current configuration : 4054 bytes
!
version 12.2
no service pad
service timestamps debug uptime
service timestamps log uptime
no service password-encryption
!
hostname center-1
!
enable secret 5 $1$1V3k$Iy3Oh4gLjMc9RZLmT2oM2.
!
no aaa new-model
ip subnet-zero
ip routing
no ip dhcp conflict logging
ip dhcp excluded-address 192.168.1.1 192.168.1.100
ip dhcp excluded-address 192.168.1.200 192.168.1.254
ip dhcp excluded-address 192.168.2.1 192.168.2.100
ip dhcp excluded-address 192.168.2.200 192.168.2.254
ip dhcp excluded-address 192.168.3.1 192.168.3.100
ip dhcp excluded-address 192.168.3.200 192.168.3.254
ip dhcp excluded-address 192.168.4.1 192.168.4.100
ip dhcp excluded-address 192.168.4.200 192.168.4.254
ip dhcp excluded-address 192.168.1.1 192.168.1.80
ip dhcp excluded-address 192.168.1.220 192.168.1.254
!
ip dhcp pool vlan1
  network 192.168.1.0 255.255.255.0
  default-router 192.168.1.1
  dns-server 192.168.1.55 202.99.8.1
  domain-name steven-dhcp
  netbios-name-server 192.168.1.55
  netbios-node-type h-node
!
ip dhcp pool vlan2
  network 192.168.2.0 255.255.255.0
  default-router 192.168.2.1
  dns-server 192.168.1.55 202.99.8.1
  domain-name steven-dhcp
  netbios-name-server 192.168.1.55
  netbios-node-type h-node
!
ip dhcp pool vlan3
  network 192.168.3.0 255.255.255.0
  default-router 192.168.3.1
  dns-server 192.168.1.55 202.99.8.1
  domain-name steven-dhcp
  netbios-name-server 192.168.1.55
  netbios-node-type h-node
!
ip dhcp pool vlan4
  network 192.168.4.0 255.255.255.0
  default-router 192.168.4.1
  dns-server 192.168.1.55 202.99.8.1
  domain-name steven-dhcp
  netbios-name-server 192.168.1.55
  netbios-node-type h-node
!
!
!
!
no file verify auto
spanning-tree mode pvst
spanning-tree extend system-id
!
vlan internal allocation policy ascending
!
interface FastEthernet0/1
switchport mode dynamic desirable
!
interface FastEthernet0/2
switchport mode dynamic desirable
!
interface FastEthernet0/3
switchport mode dynamic desirable
!
interface FastEthernet0/4
switchport mode dynamic desirable
!
interface FastEthernet0/5
switchport mode dynamic desirable
!
interface FastEthernet0/6
switchport mode dynamic desirable
!
interface FastEthernet0/7
switchport mode dynamic desirable
!
interface FastEthernet0/8
switchport mode dynamic desirable
!
interface FastEthernet0/9
switchport mode dynamic desirable
!
interface FastEthernet0/10
switchport mode dynamic desirable
!
interface FastEthernet0/11
switchport mode dynamic desirable
!
interface FastEthernet0/12
switchport mode dynamic desirable
!
interface FastEthernet0/13
switchport mode dynamic desirable
!
interface FastEthernet0/14
switchport mode dynamic desirable
!
interface FastEthernet0/15
switchport mode dynamic desirable
!
interface FastEthernet0/16
switchport mode dynamic desirable
!
interface FastEthernet0/17
switchport mode dynamic desirable
!
interface FastEthernet0/18
switchport mode dynamic desirable
!
interface FastEthernet0/19
switchport mode dynamic desirable
!
interface FastEthernet0/20
switchport mode dynamic desirable
!
interface FastEthernet0/21
description connect to center-2
switchport trunk encapsulation dot1q
switchport mode trunk
duplex full
speed 100
!
interface FastEthernet0/22
description link to center-3
switchport trunk encapsulation dot1q
switchport mode trunk
duplex full
speed 100
!
interface FastEthernet0/23
switchport mode dynamic desirable
!
interface FastEthernet0/24
no switchport
ip address 192.168.255.1 255.255.255.0
!
interface GigabitEthernet0/1
switchport mode dynamic desirable
!
interface GigabitEthernet0/2
switchport trunk encapsulation dot1q
switchport mode trunk
!
interface Vlan1
ip address 192.168.1.1 255.255.255.0
!
interface Vlan2
ip address 192.168.2.1 255.255.255.0
!
interface Vlan3
ip address 192.168.3.1 255.255.255.0
!
interface Vlan4
ip address 192.168.4.1 255.255.255.0
!
ip classless
ip route 0.0.0.0 0.0.0.0 192.168.255.2
ip http server
!
!
control-plane
!
!
line con 0
line vty 0 4
password cisco
login
line vty 5 15
no login
!
!
end

3550#

2008-03-27 15:25:37
这里还有一个:三层交换机配置实例及说明

在汇聚层的三层交换机的配置。

Enable   //进入私有模式
Configure terminal   //进入全局模式
service password-encryption   //对密码进行加密
hostname Catalyst 3550-12T1   //给三层交换机定义名称
enable password 123456.     //enable密码
Enable secret 654321     //enable的加密密码(应该是乱码而不是654321这样)
Ip subnet-zero     //允许使用全0子网(默认都是打开的)
Ip name-server 172.16.8.1 172.16.8.2     //三层交换机名字Catalyst 3550-12T1对应的IP地址是172.16.8.1
Service dhcp   //提供DHCP服务
ip routing   //启用三层交换机上的路由模块
Exit

Vtp mode server     //定义VTP工作模式为sever模式
Vtp domain centervtp   //定义VTP域的名称为centervtp
Vlan 2 name vlan2     //定义vlan并给vlan取名(如果不取名的话,vlan2的名字应该是vlan002)
Vlan 3 name vlan3
Vlan 4 name vlan4
Vlan 5 name vlan5
Vlan 6 name vlan6
Vlan 7 name vlan7
Vlan 8 name vlan8
Vlan 9 name vlan9
Exit

interface Port-channel 1       //进入虚拟的以太通道组1
Interface gigabitethernet 0/1   //进入模块0上的吉比特以太口1
channel-group 1 mode on       //把这个接口放到快速以太通道组1中
Interface gigabitethernet 0/2   //同上channel-group 1 mode on

port-channel load-balance src-dst-ip //定义快速以太通道组的负载均衡方式(依靠源和目的IP的方式)
interface gigabitethernet 0/3       //进入模块0上的吉比特以太口3

interface gigabitethernet 0/4   //同上
interface gigbitethernet 0/5   //同上
interface gigbitethernet 0/6   //同上
interface gigbitethernet 0/7   //进入模块0上的吉比特以太口7
no shutdown
spanning-tree vlan 6-9 cost 1000   //在生成树中,vlan6-9的开销定义为10000
interface range gigabitethernet 0/8 – 10   //进入模块0上的吉比特以太口8,9,10
no shutdown
spanning-tree portfast   //在这些接口上使用portfast(使用portfast以后,在生成树的时候不参加运算,直接成为转发状态)
interface gigabitethernet 0/11 //进入模块0上的吉比特以太口11
interface gigabitethernet 0/12 //同上

interface vlan 1     //进入vlan1的逻辑接口(不是物理接口,用来给vlan做路由用)
ip address 172.16.1.7 255.255.255.0 //配置IP地址和子网掩码
no shutdown
standby 1 ip 172.16.1.9     //开启了冗余热备份(HSRP),冗余热备份组1,虚拟路由器的IP地址为172.16.1.9
standby 1 priority 110 preempt   //定义这个三层交换机在冗余热备份组1中的优先级为110,preempt是用来开启抢占模式

interface vlan 2   //同上
ip address 172.16.2.252 255.255.255.0
no shutdown
standby 2 ip 172.16.2.254
standby 2 priority 110 preempt
ip access-group 101 in   //在入方向上使用扩展的访问控制列表101

interface vlan 3     //同上
ip address 172.16.3.252 255.255.255.0
no shutdown
standby 3 ip 172.16.3.254
standby 3 priority 110 preempt
ip access-group 101 in

interface vlan 4     //同上
ip address 172.16.4.252 255.255.255.0
no shutdown
standby 4 ip 172.16.4.254
standby 4 priority 110 preempt
ip access-group 101 in

interface vlan 5
ip address 172.16.5.252 255.255.255.0
no shutdown
standby 5 ip 172.16.5.254
standby 5 priority 110 preempt
ip access-group 101 in
interface vlan 6

ip address 172.16.6.252 255.255.255.0
no shutdown
standby 6 ip 172.16.6.254
standby 6 priority 100 preempt

interface vlan 7
ip address 172.16.7.252 255.255.255.0
no shutdown
standby 7 ip 172.16.7.254
standby 7 priority 100 preempt

interface vlan 8
ip address 172.16.8.252 255.255.255.0
no shutdown
standby 8 ip 172.16.8.254
standby 8 priority 100 preempt

interface vlan 9
ip address 172.16.9.252 255.255.255.0
no shutdown
standby 9 ip 172.16.9.254
standby 9 priority 100 preempt

access-list 101 deny ip any 172.16.7.0 0.0.0.255 //扩展的访问控制列表101
access-list 101 permit ip any any

Interface vlan 1           //进入vlan1这个逻辑接口
Ip helper-address 172.16.8.1   //可以转发广播(helper-address的作用就是把广播转化为单播,然后发向172.16.8.1)
Interface vlan 2
Ip helper-address 172.16.8.1
Interface vlan 3
ip helper-address 172.16.8.1
interface vlan 4
ip helper-address 172.16.8.1
interface vlan 5
ip helper-address 172.16.8.1
interface vlan 6
ip helper-address 172.16.8.1
interface vlan 7
ip helper-address 172.16.8.1
interface vlan 9
ip helper-address 172.16.8.1

router rip   //启用路由协议RIP
version 2   //使用的是RIPv2,如果没有这句,则是使用RIPv1
network 172.16.0.0   //宣告直连的网段
exit

ip route 0.0.0.0 0.0.0.0 172.16.9.250 //缺省路由,所有在路由表中没有办法匹配的数据包,都发向下一跳地址为172.16.9.250这个路由器
line con 0
line aux 0
line vty 0 15     //telnet线路(路由器只有5个,是0-4)
password 12345678   //login密码
login
end
copy running-config startup-config   保存配置

讨论:-----------------------------------------------------------------------------
你配的是cisco 3550 三层交换机(做汇聚层),我看了一些高校的汇聚层都是光交换机,接入层才用cisco 3550 ,我很想学学,不知你有没有一个完成的实例:从骨干层(双树或者环形)到汇聚层,再到接入层的网络配置,谢谢。
--------------------------------------------------------------------------------

一个Catalyst 3550至少要3-5万,如果这个学校有1000个点,你算算需要多少个48口的3550?需要多少人民币呢?所以不现实。而且Catalyst 3550是模块化的设备,可以加入光纤模块,同样可以支持光纤。而且配置中已经有gigabitethernet做为上行链路了。

核心层一般都是双树+快速以太通道做为冗余和容错的方式,环行一般用于城域网等,通常是FDDI。因为FDDI的双环结构提供充分的冗余,而且当环断了以后,还可以自己成为小环,提高了容错性。

 

发表评论

昵   称:
验证码:  点击图片可刷新验证码  博客过2级,无需填写验证码
内   容: