linux下安装配置DHCP服务器

前提是已经安装了 core 及 base 两个组

 

1
2
3
4
5
# cat /etc/redhat-release  
Red Hat Enterprise Linux Server release 6.8 (Santiago)  
# uname -a 
Linux localhost.localdomain 2.6.32-358.el6.x86_64 #1 SMP Tue Jan 29 
11:47:41 EST 2013 x86_64 x86_64 x86_64 GNU/Linux

修改本机IP为静态获取

1
2
3
4
5
6
7
8
9
10
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0 
TYPE=Ethernet 
ONBOOT=yes 
NM_CONTROLLED=yes 
BOOTPROTO=static 
IPADDR=192.168.101.11 
NETMASK=255.255.255.0 
GATEWAY=192.168.101.1
# service network restart

关闭 selinux

1
2
3
4
5
6
7
8
9
10
11
12
# vi /etc/sysconfig/selinux 
# 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=enforcing 
SELINUX=disabled 
# SELINUXTYPE= can take one of these two values: 
#     targeted – Targeted processes are protected, 
#     mls – Multi Level Security protection. 
SELINUXTYPE=targeted

安装服务器组件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# mkdir /mnt/cdrom 
# mount /dev/cdrom /mnt/cdrom/ 
mount: block device /dev/sr0 is write-protected, mounting read-only 
  
# cd /mnt/cdrom/Packages/ 
# ls dhcp* 
dhcp-4.1.1-34.P1.el6.x86_64.rpm  
dhcp-common-4.1.1-34.P1.el6.x86_64.rpm 
  
#安装 DHCP 软件包 
# rpm -Uvh dhcp-4.1.1-34.P1.el6.x86_64.rpm  
error: Failed dependencies: 
        portreserve is needed by dhcp-12:4.1.1-34.P1.el6.x86_64 
  
#解决包的依赖性 
# rpm -Uvh dhcp-4.1.1-34.P1.el6.x86_64.rpm \ 
 portreserve-0.0.4-9.el6.x86_64.rpm  
Preparing…                ########################### [100%] 
   1:portreserve            ########################### [ 50%] 
   2:dhcp                    ########################### [100%]

更改配置文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# cat dhcpd.conf 
option domain-name “bigcloud.local”;#此处设置主机名
option domain-name-servers 192.168.188.11, 192.168.188.12;#此处设置默认DNS
subnet 192.168.188.0  netmask 255.255.255.0 {   #此处设置第一个子网
  range dynamic-bootp 192.168.188.100  192.168.188.160;  #此处设定为不连续的IP段
  range dynamic-bootp 192.168.188.169  192.168.188.253;
  default-lease-time 259200; #默认租约时间
  max-lease-time 259200;
  option routers 192.168.188.2;  # 默认网关
}
subnet 192.168.189.0  netmask 255.255.255.0 {    #第二个子网
  range dynamic-bootp 192.168.189.100  192.168.189.253;
  default-lease-time 691200;
  max-lease-time 691200;
  option routers 192.168.189.2;
}
host pc1 {     #为某一台主机单独配置静态IP
  hardware ethernet 00:12:34:56:78:90;
  fixed-address 192.168.188.111;
#启动服务。 
# service dhcpd start 
Starting dhcpd:                                            [  OK  ]

原创文章,作者:zero,如若转载,请注明出处:http://www.178linux.com/74747

(1)
zerozero
上一篇 2017-05-03 20:38
下一篇 2017-05-04 08:22

相关推荐

  • 第二周作业

    1 linux 常见的文件管理命令都有哪些?其常用的使用方法。 ls 文件列出命令   常见选项  -l 显示长文本信息          -d 显示当前目录信息          -a 显示所有文件信息     &nb…

    Linux干货 2016-09-26
  • 2016全球运维大会,优云蒋君伟演讲“CMDB+自动化的管理融合”成一大亮点

    2016全球运维大会于9月23日-24日在上海盛大开幕。作为国内运维行业的重量级大会,优云产品总监蒋君伟在自动化专场与来自全国各地的运维同行一起探讨、分享业内自动化运维的最佳实践。现场情绪热烈,气氛高涨,成为了本届全球运维大会的一大亮点。 全新梳理自动化与CMDB的融合之道 全球运维大会当天,运维自动化专场很多大牛针对自动化运维管理中的CMDB进行了激烈的讨…

    Linux资讯 2016-12-05
  • N26第二周博客作业

    1.Linux上的文件管理类命令都有哪些,其常用的使用方法及其相关示例演示。 Ø  ls 查看文件与目录 ls [选项] 文件或目录 常用选项 -a:全部的文件,连同隐藏文件(以.开头)一起列出来 -d:列出目录本身,而不是列出目录里的文件 -l:列出详细信息,如文件的属性与权限等数据 -h:将文件容量以易读的方式显示(例如:GB,KB等) -t:…

    Linux干货 2017-01-08
  • 破坏grub实验之一

    1、删除grub stage1阶段 [root@centos6 ~]# dd if=/dev/zero of=/dev/sda bs=446 count=1 1+0 records in 1+0 records out 446 bytes …

    Linux干货 2016-09-19
  • linux网络管理

    Linux网络配置 摘要:Linux 对网络的管理分为 静态指定和动态管理。 静态指定 静态指定ip一般有命令              ifconfig       &…

    Linux干货 2016-04-05
  • Nginx配置与应用详解

    前言 Nginx是由俄罗斯软件工程师Igor Sysoev开发的一个高性能的HTTP和反向代理服务器,具备IMAP/POP3和SMTP服务器功能。Nginx最大的特点是对高并发的支持和高效的负载均衡,在高并发的需求场景下,是Apache服务器不错的替代品。目前,包括新浪、腾讯等知名网站都已使用Nginx作为Web应用服务器。本文带来的是Nginx配置与应用详…

    Linux干货 2015-06-15

评论列表(1条)

  • 成都
    成都 2018-02-16 09:57

    请问代码怎么插入的?