debian dhcp服务启动不了_全网最全的DHCP搭建步骤

1. dhcp服务:

1) dhcp服务功能:自动为大量主机配置网络参数(ip地址、子网掩码、网关、dns、主机名)

2) dhcp服务架构是C/S(客户端/服务器)架构,一般情况下一台服务为多台客户机提供服务(如dhcp自动配置网络参数),DHCP(动态主机配置协议)监听端口UDP/67安装包dhcp主配置文件/etc/dhcp/dhcpd.conf.

3) linux客户端获取网络参数的方法:dhclient -d 网卡 (自动获取IP地址)dhclient -r  网卡  (释放网络参数)或者修改网卡配置文件BOOTPROTO=dhcp配置项并重启服务

配置dhcp服务

1. 安装dhcp服务:

1)放入光盘镜像配置yum:

32802a6e-8a1a-eb11-8da9-e4434bdf6706.png

33802a6e-8a1a-eb11-8da9-e4434bdf6706.png

[root@www ~]# rm -rf /etc/yum.repos.d/*   ##删除原有的yum配置文件

[root@www ~]# vi /etc/yum.repos.d/ctos.repo  ##编写yum配置文件

[cdrom]  ##yum仓库模块名

name=cdrom   ##仓库名称

baseurl=file:///mnt/   ##仓库软件存放位置

enabled=1    ##启用软件仓库

gpgcheck=0   ##不进行公钥验证

:wq

[root@www ~]# echo "/dev/cdrom /mnt/ iso9660 defaults 0 0" >>/etc/fstab    ##挂载ISO镜像

[root@www ~]# mount -a   ##加载/etc/fstab

mount: block device /dev/sr0 is write-protected, mounting read-only

[root@www ~]# ls /mnt  ##查看验证,光盘已经挂载

CentOS_BuildTag  isolinux                  RPM-GPG-KEY-CentOS-Debug-6

EFI              Packages                  RPM-GPG-KEY-CentOS-Security-6

EULA             RELEASE-NOTES-en-US.html  RPM-GPG-KEY-CentOS-Testing-6

GPL              repodata                  TRANS.TBL

images           RPM-GPG-KEY-CentOS-6

[root@www ~]#

2)安装dhcp服务:

[root@www ~]# yum -y install dhcp   ##安装dhcp服务软件,yum好处是自动解决依赖关系,推荐使用安装rpm包

2. 配置DHCP服务

1)配置ip地址关闭防火墙及selinux::

[root@www ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0

TYPE=Ethernet

ONBOOT=yes

NM_CONTROLLED=no

BOOTPROTO=static

HWADDR=00:0c:29:ee:92:39   ##修改为自己的MAC地址使用“ip a”查看复制

IPADDR=192.168.200.100

NETMASK=255.255.255.0

GATEWAY=192.168.200.254

DNS1=202.106.0.20

:wq

[root@www ~]# /etc/init.d/network restart

正在关闭接口eth0:                      [确定]

关闭环回接口:                         [确定]

弹出环回接口:                    [确定]

弹出界面 eth0:Determining if ip address 192.168.200.100 is already in use for device eth0...                [确定]

[root@www ~]# vi /etc/sysconfig/network   ##修改主机名

NETWORKING=yes

HOSTNAME=www.linuxfan.cn

:wq

[root@www ~]# chkconfig iptables off   ##禁用防火墙

[root@www ~]# sed -i '/^SELINUX/s/enforcing/disabled/g' /etc/selinux/config   ##禁用selinux

[root@www ~]# cat /etc/selinux/config  ##验证

# This file controls the state of SELinux on the system.

# SELINUX= can take one of these three values:

#     enforcing - SELinux security policy is enforced.

#     permissive - SELinux prints warnings instead of enforcing.

#     disabled - No SELinux policy is loaded.

SELINUX=disabled

# SELINUXTYPE= can take one of these two values:

#     targeted - Targeted processes are protected,

#     mls - Multi Level Security protection.

SELINUXTYPE=targeted

[root@www ~]# reboot  ##重启生效

[root@www 桌面]# iptables -L   ##查看验证防火墙

Chain INPUT (policy ACCEPT)

target     prot opt source               destination         

Chain FORWARD (policy ACCEPT)

target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)

target     prot opt source               destination         

[root@www 桌面]# getenforce   ##查看禁用selinux

Disabled

[root@www 桌面]# hostname

www.linuxfan.cn

[root@www 桌面]#

2)配置dhcp服务并启动服务:

[root@www ~]# vi /etc/dhcp/dhcpd.conf   ##删除原有内容如果复制请删除中文及空格

option domain-name "linuxfan.cn";   ##指定域名

option domain-name-servers 192.168.200.100;   ##指定dns服务地址

default-lease-time 600;   ##租期时间单位秒

max-lease-time 7200;      ##最大租期

log-facility local7;      ##日志级别

subnet 192.168.200.0 netmask 255.255.255.0 {   ##网段声明

  range 192.168.200.10 192.168.200.20;   ##地址池者是地址分配范围

  option routers 192.168.200.254;   ##网关

}

host netserver {   ##主机绑定,可以用来设置对应MAC地址主机主机及IP地址

  hardware ethernet 00:0c:29:ee:92:39;   ##主机MAC地址,根据具体进行修改

  server-name "www.linuxfan.cn";   ##设置主机名

  fixed-address 192.168.200.95;    ##设置ip地址

}

:wq

[root@www ~]#

[root@www ~]# /etc/init.d/dhcpd restart  ##启动服务

正在启动 dhcpd:                        [确定]

[root@www ~]# chkconfig dhcpd on  ##开机启动dhcp服务

[root@www 桌面]# netstat -utpln |grep 67   ##查看监听

udp  0   0 0.0.0.0:67          0.0.0.0:*

2597/dhcpd  

[root@www ~]# tail -30 /var/log/messages   ##查看是否有报错

3.客户机验证:

1)在同一个网络中尽量确保只有一个DHCP服务,虚拟机本身有DHCP服务,在配置DHCP服务时必须关闭。

34802a6e-8a1a-eb11-8da9-e4434bdf6706.png

2)window的测试:开启win7网卡设置为仅主机

35802a6e-8a1a-eb11-8da9-e4434bdf6706.png

36802a6e-8a1a-eb11-8da9-e4434bdf6706.png

38802a6e-8a1a-eb11-8da9-e4434bdf6706.png

3)linux客户机:开启linux系统,网卡设置为仅主机

39802a6e-8a1a-eb11-8da9-e4434bdf6706.png

4)服务端验证:

[root@www ~]# cat /var/lib/dhcpd/dhcpd.leases   ##已经分配出去IP地址

# The format of this file is documented in the dhcpd.leases(5) manual page.

# This lease file was written by isc-dhcp-4.1.1-P1

server-duid "\000\001\000\001\030\335\231Y\000\014)\356\2229";

省略部分显示内容

lease 192.168.200.11 {

  starts 4 2013/03/21 10:34:49;

  ends 4 2013/03/21 10:44:49;

  cltt 4 2013/03/21 10:34:49;

  binding state active;

  next binding state free;

  hardware ethernet 00:0c:29:33:e0:4d;

}

lease 192.168.200.10 {

  starts 4 2013/03/21 10:36:59;

  ends 4 2013/03/21 10:46:59;

  cltt 4 2013/03/21 10:36:59;

  binding state active;

  next binding state free;

  hardware ethernet 00:0c:29:a0:7f:25;

  uid "\001\000\014)\240\177%";

  client-hostname "win7-1";

}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值