Chinaunix首页 | 论坛 | 博客
  • 博客访问: 421784
  • 博文数量: 136
  • 博客积分: 5351
  • 博客等级: 少校
  • 技术积分: 1446
  • 用 户 组: 普通用户
  • 注册时间: 2011-04-29 15:46
文章存档

2013年(2)

2012年(18)

2011年(116)

分类: LINUX

2011-06-02 09:41:49

0.软件包dhcp      #yum  install    dhcp    -y 

1.dhcp服务器   dhcpd服务      住配置文件在/etc/dhcp/目录下:共有三个文件:

[root@acermt dhcp]# ll
total 12
drwxr-xr-x. 2 root root 4096 May 10 21:28 dhclient.d
-rw-r--r--. 1 root root  193 Sep  4  2010 dhcpd6.conf
-rw-r--r--. 1 root root 3282 Jun  1 19:43 dhcpd.conf
[root@acermt dhcp]# pwd
/etc/dhcp
[root@acermt dhcp]# ls  -a
.  ..  dhclient.d  dhcpd6.conf  dhcpd.conf  .dhcpd.conf.swp  
    //当vim  dhcpd.conf  出错时   #rm  -r  .dhcpd.conf.swp  类似问题在gcc编译是也会出现
               //没删除会出现的情况:
E325: ATTENTION
Found a swap file by the name ".dhcpd.conf.swp"
          owned by: root   dated: Wed Jun  1 20:08:41 2011
         file name: /etc/dhcp/dhcpd.conf
          modified: YES
         user name: root   host name: acermt
        process ID: 5002
While opening file "dhcpd.conf"
             dated: Wed Jun  1 19:43:21 2011

(1) Another program may be editing the same file.
    If this is the case, be careful not to end up with two
    different instances of the same file when making changes.
    Quit, or continue with caution.

(2) An edit session for this file crashed.
    If this is the case, use ":recover" or "vim -r dhcpd.conf"
    to recover the changes (see ":help recovery").
    If you did this already, delete the swap file ".dhcpd.conf.swp"
    to avoid this message.

Swap file ".dhcpd.conf.swp" already exists!
[O]pen Read-Only, (E)dit anyway, (R)ecover, (D)elete it, (Q)uit, (A)bort:

   //要学会保存一些原始的配置文件:   cp    dhcpd.conf      dhcpd-backup.conf

2.  #  vim  dhcpd.conf                 //注意 # 表示注释  每一行都得 ; 结尾      写租约
                                 自己的ip最好是static                          
log-facility local7;
subnet 192.168.1.0 netmask 255.255.255.0 {          //用ifconfig   -a  查看一下自己的ip
   range dynamic-bootp 192.168.1.1  192.168.1.254;    //ip动态分配池的范围 c类最多 253 个   空格隔开
#   option broadcast-address 192.168.1.255;   //这事组播地址  可以去掉  协议自动生成
   option domain-name-servers 192.168.1.103,8.8.8.8;   //DNS SERVER 可以是localhost 多个逗号隔开
   option domain-name "internal.example.org";   //
   option routers 192.168.1.103;            //路由   本处配为自己的主机ip 
                                                              也可以是本机经过的路由 192.168.1.1    ?
   default-lease-tiime  43200 ;
   max-lease-time    86400 ;     // 租约时间设置 默认半天    最多一天  如果超时了呢?
}
      //一些附加  或者说自由的服务  dhcp  给某一些主机  固定的 ip
host  boss{                //fantasia是默认参数幻想的含义    此处我改为  boss
  hardware ethernet 08:00:07:26:c0:a5;  //08:00:07:26:c0:a5  必须是boss主机的MAC地址
  fixed-address 192.168.1.88;    //分配给boss   的具体或者说固定的  ip  
}
host   staff1 {
  hardware ethernet 08:00:07:26:c0:a5;   //员工1  的  MAC地址
  fixed-address  192.168.1.2;  
}
host  stall2{
  hardware ethernet 08:00:07:26:c0:a5;   //员工2  de MAC地址
  fixed-address 192.168.1.3;
}
  //  可以很自由地   加下去  


  //  更自由的设置   不同网段得到不同的地址(跨网段的DHCP) 
 

# A slightly different configuration for an internal subnet.
log-facility local7;
shared-network   example {  //注意这一个 { 的匹配  把整个内容 括起来
  
   default-lease-time 600;
   max-lease-time 7200;
   option  routers  192.168.1.103  ;   //如此设置就把下面所有的网段的路由都定为 192.168.1.103  
                一般此处都不加路由设置 只有时间设置  而把路由放不同的网段内 来满足需要    关键是需求    
  subnet   192.168.1.0   netmask   255.255.255.0  {
  rang   dynamic-bootp   192.168.0.1  192.168.0.13;
  option routers   192.168.1.254                //没有 option  routers  192.168.1.103  ;
  option domain-name-servers 192.168.0.254 ;

}
subnet   192.168.2.0   netmask   255.255.255.0{
    rang  dynamic-bootp   192.168.2.1    192.168.2.13 ;
    option  routers  192.168.2.254               //没有 option  routers  192.168.1.103  ;
    option domain-name-servers 192.168.1.254;

}
}

    //   对不同的操做系统,以及虚拟机  都可以让它得到不同的ip 



     
  
阅读(1697) | 评论(0) | 转发(0) |
0

上一篇:文件 /proc/

下一篇:samba 住配置文件 注释

给主人留下些什么吧!~~