CentOS6.9 DHCP服务器配置

   2023-02-09 学习力0
核心提示:  首先查看一下CentOS版本查看网络配置我用虚拟机能上网的。安装dhcp服务yum install dhcp -y配置dhcp服务器的配置文件cat /etc/dhcp/dhcpd.conf它告诉你去 /usr/share/doc/dhcp*/dhcpd.conf.sample 里面去找一个例子直接重定向 简单粗暴打开文件后里面的内

 

 首先查看一下CentOS版本

CentOS6.9 DHCP服务器配置

查看网络配置

CentOS6.9 DHCP服务器配置

我用虚拟机能上网的。

安装dhcp服务

yum install dhcp -y

CentOS6.9 DHCP服务器配置

CentOS6.9 DHCP服务器配置

配置dhcp服务器的配置文件

cat /etc/dhcp/dhcpd.conf

CentOS6.9 DHCP服务器配置

它告诉你去 /usr/share/doc/dhcp*/dhcpd.conf.sample 里面去找一个例子

直接重定向 简单粗暴

CentOS6.9 DHCP服务器配置

打开文件后里面的内容是:

  1 # dhcpd.conf
  2 #
  3 # Sample configuration file for ISC dhcpd
  4 #
  5 
  6 # option definitions common to all supported networks...
  7 option domain-name "example.org";
  8 option domain-name-servers ns1.example.org, ns2.example.org;
  9 
 10 default-lease-time 600;
 11 max-lease-time 7200;
 12 
 13 # Use this to enble / disable dynamic dns updates globally.
 14 #ddns-update-style none;
 15 
 16 # If this DHCP server is the official DHCP server for the local
 17 # network, the authoritative directive should be uncommented.
 18 #authoritative;
 19 
 20 # Use this to send dhcp log messages to a different log file (you also
 21 # have to hack syslog.conf to complete the redirection).
 22 log-facility local7;
 23 
 24 # No service will be given on this subnet, but declaring it helps the 
 25 # DHCP server to understand the network topology.
 26 
 27 subnet 10.152.187.0 netmask 255.255.255.0 {
 28 }
 29 
 30 # This is a very basic subnet declaration.
 31 
 32 subnet 10.254.239.0 netmask 255.255.255.224 {
 33   range 10.254.239.10 10.254.239.20;
 34   option routers rtr-239-0-1.example.org, rtr-239-0-2.example.org;
 35 }
 36 
 37 # This declaration allows BOOTP clients to get dynamic addresses,
 38 # which we don't really recommend.
 39 
 40 subnet 10.254.239.32 netmask 255.255.255.224 {
 41   range dynamic-bootp 10.254.239.40 10.254.239.60;
 42   option broadcast-address 10.254.239.31;
 43   option routers rtr-239-32-1.example.org;
 44 }
 45 
 46 # A slightly different configuration for an internal subnet.
 47 subnet 10.5.5.0 netmask 255.255.255.224 {
 48   range 10.5.5.26 10.5.5.30;
 49   option domain-name-servers ns1.internal.example.org;
 50   option domain-name "internal.example.org";
 51   option routers 10.5.5.1;
 52   option broadcast-address 10.5.5.31;
 53   default-lease-time 600;
 54   max-lease-time 7200;
 55 }
 56 
 57 # Hosts which require special configuration options can be listed in
 58 # host statements.   If no address is specified, the address will be
 59 # allocated dynamically (if possible), but the host-specific information
 60 # will still come from the host declaration.
 61 
 62 host passacaglia {
 63   hardware ethernet 0:0:c0:5d:bd:95;
 64   filename "vmunix.passacaglia";
 65   server-name "toccata.fugue.com";
 66 }
 67 
 68 # Fixed IP addresses can also be specified for hosts.   These addresses
 69 # should not also be listed as being available for dynamic assignment.
 70 # Hosts for which fixed IP addresses have been specified can boot using
 71 # BOOTP or DHCP.   Hosts for which no fixed address is specified can only
 72 # be booted with DHCP, unless there is an address range on the subnet
 73 # to which a BOOTP client is connected which has the dynamic-bootp flag
 74 # set.
 75 host fantasia {
 76   hardware ethernet 08:00:07:26:c0:a5;
 77   fixed-address fantasia.fugue.com;
 78 }
 79 
 80 # You can declare a class of clients and then do address allocation
 81 # based on that.   The example below shows a case where all clients
 82 # in a certain class get addresses on the 10.17.224/24 subnet, and all
 83 # other clients get addresses on the 10.0.29/24 subnet.
 84 
 85 class "foo" {
 86   match if substring (option vendor-class-identifier, 0, 4) = "SUNW";
 87 }
 88 
 89 shared-network 224-29 {
 90   subnet 10.17.224.0 netmask 255.255.255.0 {
 91     option routers rtr-224.example.org;
 92   }
 93   subnet 10.0.29.0 netmask 255.255.255.0 {
 94     option routers rtr-29.example.org;
 95   }
 96   pool {
 97     allow members of "foo";
 98     range 10.17.224.10 10.17.224.250;
 99   }
100   pool {
101     deny members of "foo";
102     range 10.0.29.10 10.0.29.230;
103   }
104 }

然后删除 删成这个样子:

CentOS6.9 DHCP服务器配置

为了方便把这部分贴出来

subnet 10.5.5.0 netmask 255.255.255.224 {
  range 10.5.5.26 10.5.5.30;
  option domain-name-servers ns1.internal.example.org;
  option domain-name "internal.example.org";
  option routers 10.5.5.1;
  option broadcast-address 10.5.5.31;
  default-lease-time 600;
  max-lease-time 7200;
}

host fantasia {
  hardware ethernet 08:00:07:26:c0:a5;
  fixed-address fantasia.fugue.com;
}

然后就开始配置吧 假设在一个局域网192.168.48.0配置   分配给host的ip范围是192.168.48.10 192.168.48.200 然后开始搞起

CentOS6.9 DHCP服务器配置

网络接口配置:

vim /etc/sysconfig/dhcpd

DHCPDARGS=eth0

 

配置一下本地虚拟机的网络

CentOS6.9 DHCP服务器配置

这个样子,我的XShell也就断了

然后虚拟机配置一下桥接模式,这样我的Windows就和虚拟机在一个局域网下了

CentOS6.9 DHCP服务器配置

成功了嘿嘿嘿。

但是在这里还是要说以下细节的

本地的Windows网卡要设置自动获取ip自动获取dns

CentOS6.9 DHCP服务器配置

然后要重启一下网卡才能生效,这样最简单粗暴了。

 
反对 0举报 0 评论 0
 

免责声明:本文仅代表作者个人观点,与乐学笔记(本网)无关。其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
    本网站有部分内容均转载自其它媒体,转载目的在于传递更多信息,并不代表本网赞同其观点和对其真实性负责,若因作品内容、知识产权、版权和其他问题,请及时提供相关证明等材料并与我们留言联系,本网站将在规定时间内给予删除等相关处理.

  • 用Xshell设置CentOS密钥登录
    用Xshell设置CentOS密钥登录
    今天带来设置X shell 密钥登录  因为用的中文x shell 所以按照中文设置很简单1.点击工具(Tools)------新建用户密钥生成向导(New User key Wizard)(附图)2.然后出现下图时,记得密钥类型 选择RSA.其实选择DSA ,也能实现,二者其实是不同的算法。(我用的R
    03-08
  • centOS下安装Adobe Flash Player
    centOS下安装Adobe Flash Player
    centOS下安装Adobe Flash Player  2009-10-09 11:29:33|  分类:linux|  标签: |订阅 写出来就这么简单几步,当初刚接触Linux的时候搜索了很长时间,找了很多资料,总是出现这样那样的问题,最后终于摸索出最简单最有效的安装的方法。 随便打开一个带
    03-08
  • 部署Node.js项目(CentOS) node项目搭建
    部署Node.js项目(CentOS) node项目搭建
    操作步骤步骤 1:创建ECS实例选择操作系统为公共镜像CentOS7.2。使用root用户登录Linux实例。步骤2:部署Node.js环境—二进制文件安装该部署过程使用的安装包是已编译好的二进制文件,解压之后,在bin文件夹中就已存在node和npm,无需手工编译。安装步骤:1、
    02-10
  • centos安装python与jdk centos安装python3.7
    centos安装python与jdk centos安装python3.7
    安装python#压缩包安装[root@china ~]# yum -y install zlib*Loaded plugins: fastestmirror, refresh-packagekit, securityLoading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun
    02-10
  • centos6下同时安装python2和python3
    #build-essential compile packagesyum groupinstall "Development Tools"yum install openssl-develyum install zlib-develyum install make gcc gcc-c++ kernel-develhttp://unix.stackexchange.com/questions/291737/zipimport-zipimporterror-cant-decomp
    02-10
  • CentOS下查看文件和文件夹大小 linux查看文件夹
    当磁盘大小超过标准时会有报警提示,这时如果掌握df和du命令是非常明智的选择。  df可以查看一级文件夹大小、使用比例、档案系统及其挂入点,但对文件却无能为力。当磁盘大小超过标准时会有报警提示,这时如果掌握df和du命令是非常明智的选择。  df可以查
    02-10
  • centos7 离线升级/在线升级操作系统内核
    centos7 离线升级/在线升级操作系统内核
    centos7 离线升级/在线升级操作系统内核目录一.前言二.系统环境三.系统内核下载网址四.centos7离线升级系统内核1.先查看系统环境2.离线升级系统内核五.在线升级系统内核一.前言CentOS(Community ENTerprise Operating System)是Linux发行版之一,它是来自于
    02-10
  • centos7 rc.local脚本执行不成功
    腾讯云 centos7   配置文件/etc/rc.local的内容如下:#!/bin/sh#secu_agent init monitor, install at Thu Aug 3 11:19:41 CST 2017/usr/local/sa/agent/init_check.sh/dev/null 21/usr/sbin/ntpdate ntpupdate.tencentyun.com /dev/null 21 /usr/local/qclo
    02-10
  • 如何在centos7启动时自动挂载硬盘
    在/etc/rc.local中加入如下的语句,这样就不用每次重启后手动挂载了(后面挂载的目录根据自己的需求而定):mount  /dev/sdb1 /usr/sharedfiles/sdbmount  /dev/sdc1 /usr/sharedfiles/sdcmount  /dev/sdb1 /root/sdbmount  /dev/sdc1 /root/sdc注意:可以
    02-10
  • centos7.2 开启防火墙
    开启防火墙当我们修改了某些配置之后(尤其是配置文件的修改),firewall并不会立即生效。可以通过两种方式来激活最新配置 systemctl restart firewalld 和 firewall-cmd --reload 两种方式,前一种是重启firewalld服务,建议使用后一种“重载配置文件”
    02-10
点击排行