Chinaunix

标题: cisco路由器DHCP配置 [打印本页]

作者: cheshiblog    时间: 2009-05-25 10:58
标题: cisco路由器DHCP配置
        用一台cisco3600系列路由器作为DHCP server,此路由器F0/0接口与内网相连,下联cisco3560三层交换机,在整个网络里以起两个VLAN为例,连接两个二层交换机(也可以不在二层交换上起vlan,直接在cisco3560上起两个vlan,把相应端口划入对应vlan中)。
如下图:
      

       在路由器上配置地址池,ip地址租约时间,dns服务器等:
    router(config)#ip dhcp pool global(配置一个地址池)
    router(dhcp-config)#network 192.168.0.0 255.255.0.0(配置地址池ip段)
    router(dhcp-config)#domain-name router.com(为客户机配置域后缀,名字可以按实际DNS域后缀)
    router(dhcp-config)#dns-server 192.168.1.1(为客户机配置DNS服务器,实际网络中域名解析服务器DNS的IP地址)
    router(dhcp-config)#netbios-name-server 192.168.1.1(为客户机配置WINS服务器)
    router(dhcp-config)#netbios-node-type h-hode (为客户机配置H节点模式)
    router(dhcp-config)#lease 5 (地址租约期为5天,可以详细设置小时分钟等)
    router(dhcp-config)#ip dhcp pool vlan1(本池为global的子池,它继承global池的配置,例如DNS服务器等)
    router(dhcp-config)#network 192.168.1.0 255.255.255.0
    router(dhcp-config)#default-router 192.168.1.254(为客户机配置默认网关,即vlan1的ip地址)
    router(dhcp-config)#ip dhcp pool vlan2(本池为global的子池,它继承global池的配置,例如DNS服务器等)
    router(dhcp-config)#network 192.168.2.0 255.255.255.0
    router(dhcp-config)#default-router 192.168.2.254
    router(dhcp-config)#ip dhcp exclude-address 192.168.1.1 192.168.1.4(dhcp池中除去这些地址不能分配)
    router(dhcp-config)#ip dhcp exclude-address 192.168.1.2(也可以这样再添加单个IP,路由器接口地址)
    router(dhcp-config)#ip dhcp exclude-address 192.168.1.254(两个vlan地址)
    router(dhcp-config)#ip dhcp exclude-address 192.168.2.254
不设置dhcp数据库代理:
    router(config)#no ip dhcp conflict logging (取消地址冲突记录日志)
设置DHCP数据库代理:
    服务器可以是TFTP,FTP RCP服务器,也可以配置多个DHCP数据库代理。
    在路由器上配置两个静态路由保证网内主机可以和路由器正常通信:
    router(config)# ip route 192.168.1.0 255.255.255.0 f0/0
    router(config)# ip route 192.168.2.0 255.255.255.0 f0/0
在二层或者三层交换机设置VLAN 地址 :
   switch1(config)#int vlan 1
   switch1(config-if)#ip add 192.168.1.254 255.255.255.0
   switch(config-if)ip helper-address 192.168.1.2(指定DHCP服务器地址,即路由器接口地址)
   switch1(config)#no sh
   switch2(config)#int vlan 1
   switch2(config-if)#ip add 192.168.2.254 255.255.255.0
   switch(config-if)ip helper-address 192.168.1.2(指定DHCP服务器地址,即路由器接口地址)
   switch2(config)#no sh
或者在三层上:  
   switch(config)#int vlan 1
   switch(config-if)#ip add 192.168.1.254 255.255.255.0
   switch(config-if)ip helper-address 192.168.1.2(指定DHCP服务器地址,即路由器接口地址)
   switch(config)#no sh
   switch(config)#int range f0/1 - 12
   switch(config-if)#switchport mode access
   switch(config-if)#switchport access vlan 1
   switch(config)#int vlan 2
   switch(config-if)#ip add 192.168.2.254 255.255.255.0
   switch(config-if)ip helper-address 192.168.1.2(指定DHCP服务器地址,即路由器接口地址)
   switch(config)#no sh
   switch(config)#int range f0/13 - 24
   switch(config-if)#switchport mode access
   switch(config-if)#switchport access vlan 2
   

最后在客户端主机上IP地址DNS属性设置自动获取即可。(客户机必须开启了DHCP服务)


本文章图片和部分文字转载其他网站。
   





本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u1/50533/showart_1943890.html




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2