dhcp 基于不同网段的简单配置

关于dhcp的安装此处就略过(不会安装的直接百度下就欧克了!),直接讲述dhcp基于不同网段的简单配置。

1.安装后切换到/etc/dhcp目录下,然后Vim  dhcp.conf  可以看到这个里面没有dhcp的配置文件,按照里面的说明到/usr/share/doc  目录下找到dhcp-4.1.1(版本不同版dhcp-****这个也就不同)进入这个目录里面可以看到有很多的文件,找到dhcpd.conf.sample这个文件,然后cp  dhcpd.conf.sample  /etc/dhcp

2.cd  /etc/dhcp  切换到dhcp目录下,ls后看dhcp的配置文件  vim  dhcpd.conf  可以看到如下东东:

# dhcpd.conf # # Sample configuration file for ISC dhcpd #

# option definitions common to all supported networks...

option domain-name "example.org";

option domain-name-servers ns1.example.org, ns2.example.org;

default-lease-time 600;

max-lease-time 7200;

# Use this to enble / disable dynamic dns updates globally. #ddns-update-style none;

# If this DHCP server is the official DHCP server for the local # network, the authoritative directive should be uncommented. #authoritative;

# Use this to send dhcp log messages to a different log file (you also)

我们要用的就是没有#注释的语句。

3一个网卡配置多个ip:  ifconfig  lo:1  10.32.1.3      然后重新启动下network :/etc/init.d/dhcpd  restart

 #哈哈,你kendinghui 问为什么要配置这个ip,在这里我就告诉你因为dhcp的原理里面有写到dhcp是通过客户端发送广播数据包给整个物理网络段内的所有主机,既然是通过广播哪肯定是在统一网段的,所以它不可以配置不同网段的ip,在这里添加的10.32.1.3这个ip就是为了是使dhcp可以配置不同网段的ip的 #

4.配置dhcp文件

例如要分配10.33和10.32这两个网段的ip并且绑定MAC。

option domain-name "example.org";

option domain-name-servers 59.69.128.8;

 default-lease-time 60000;

  max-lease-time 720000;

#ddns-update-style none;

#log-facility local7;

 subnet 10.0.0.0 netmask 255.0.0.0    {       #此处为ip地址池也即你要分配的网段#

range 10.32.1.30 10.33.44.130;     

option routers 10.33.250.250;       }  

host fantasia{                                               #此处为MAC地址的绑定#                

  hardware ethernet  00:0c:29:ea:3e:99;  

fixed-address 10.33.44.118;

 }

 host fantasiaa {
  hardware ethernet 00:0c:29:57:68:A6;
  fixed-address  10.32.1.31;
  }

5.启动dhcp服务器 

(1)/etc/init.d/dhcpd  start

 (2)  service  dhcpd  start

[root@localhost dhcp]# /etc/init.d/dhcpd  restart
Shutting down dhcpd:                                       [  OK  ]
Starting dhcpd:                                            [  OK  ]            #这说明dhcp已经启动成功了

6.查看dhcp服务器是否工作

[root@localhost dhcp]# ps  -aux  |grep dhcpd
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ
dhcpd     2255  0.0  3.1  22164 16200 ?        Ss   20:22   0:00 /usr/sbin/dhcpd -user dhcpd -group dhcpd eth0
root      2260  0.0  0.1   4300   620 pts/0    S+   20:24   0:00 grep dhcpd

 

备注:这个呢也是我刚开始弄dhcp服务器,如果有什么不对的地方的话可以评论给我。- _ - 

 

 

 

posted @ 2014-11-02 20:25  追梦的小小小孩儿  阅读(2543)  评论(0编辑  收藏  举报