【美高梅手机版4858】DHCP服务器配置,怎么样设置网络辅导运维

By admin in 美高梅手机版4858 on 2019年4月24日

 

 

处境rhel5,至少两台Computer,或然1台微机方面安装了虚拟机,还有你的微型Computer的网卡必须能够支撑可互连网运行。当中五个Computer能够用壹根网线直接相接只怕在同在一个局域网里)

动用情状:

 首先查看一下CentOS版本

 首先查看一下CentOS版本

要达标的目的:分为1号机和二号机,要高达,作为客户端的二号机能通过网络查询到1号机为她分配的ip,而且二号机能通过一号机提供的服务,举行互联网运营,并设置rhel伍

1、在管理多台Computer的图景下,落成自动化安装系统,自动分配IP地址。

美高梅手机版4858 1

美高梅手机版4858 2

留目的在于那个进度进展事先要关门防火墙iptatble

二、消除ipv四财富不足的主题素材。

翻开互联网安插

翻看网络布局

壹 倘诺两台机子同在三个局域网里,在实行考试从前要切断局域网与外场的连线

计划事项:

美高梅手机版4858 3

美高梅手机版4858 4

  1. 将rhel5.iso过载:mount  /dev/cdrom  /mnt/memory

  2. 查询系统是不是安装了dhcp,rpm -qa | grep dhcpd 
    如若没设置,要进来/mnt/memory/Server,推行命令rpm -ivh
    dhcp-三.0.5-1八.rpm,安装dhcp

壹、为了不影响局域网内的通讯,本身搭建虚拟的网卡VMnet拾,选用进机格局,和去掉利用本地dhcp服务这选项,网卡的地方也能够是除①3柒那网段外的别样网段,不须要同一网段。

本身用编造机能上网的。

本身用编造机能上网的。

四,假设设置了,会现出dhcp-叁.0.伍-1八.el五或曾经设置好了的话,setup  设置ip

二、须求预备好两台虚拟机,1台centos7做dhcp服务器,主机的地点是1九二.16八.一三七.17八;一台新建的centos陆.玖做客户端,centos七上的急需配备三个网卡,第二个是互连网连接的是仅主机的自定义的VMnet十 ,第二个挑选是桥接方式;在centos陆.九客户端上的网卡选择仅主机的自定义的杜撰网卡VMnet12个网卡就能够了。

安装dhcp服务

安装dhcp服务

192.168.1.45
255.255.255.0
192.168.1.1

三、关闭centos7和centos陆.玖上的防火墙和selinux。

yum install dhcp -y

【美高梅手机版4858】DHCP服务器配置,怎么样设置网络辅导运维。yum install dhcp -y

五.  cp /usr/share/doc/dhcp-叁.0.5/dhcp.conf/sample  /etc/dhcpd.conf mv
etc/dhcpd.conf.sample /etc/dhcpd.conf  将原先的dhcpd.conf覆盖

配置DHCP服务器:

安装dhcp 包
yum -y install dhcp

查看包相关的路径和依赖的服务
rpm -ql dhcp  

美高梅手机版4858 5

美高梅手机版4858 6

美高梅手机版4858 7

6 vim /etc/dhcpd.conf

进去文件/etc/dhcp/dhcpd.conf 编辑 服务器的音信本来在cat /etc/dhcp/dhcpd.conf 那文件之中未有配备的内容,只提供了模版让大家参考,那大家就把模版的文件复制一份到/etc/dhcp/dhcpd.conf 那配置文件里,然后大家在配置文件里修改和扩展内需的故事情节就能够了。
cp /usr/share/doc/dhcp*/dhcpd.conf.example  /etc/dhcp/dhcpd.conf

美高梅手机版4858 8

美高梅手机版4858 9

将内部的具备ip的新闻依据setup里配置的ip音信做相应修改

文本编制:
vim /etc/dhcp/dhcpd.conf 
现在我的主机IP是192.168.137.178;我需要在配置文件里的把子网subnet改成和我主机在同一网段的地址192.168.137.0 ,其它的配置先不动,这样就可以启动dhcpd服务了,
 systemctl start dhcpd

美高梅手机版4858 10

用ss -nul 查看端口可以看到服务器的端口67,说明服务起来了

美高梅手机版4858 11

配置dhcp服务器的配置文件

布置dhcp服务器的陈设文件

7 Service network restart

在劳动器端设置分配给客户机的ip地址范围,今后大家分配的是66 到16陆范围的地点,当然大家也得以陈设不是叁柒网段的地点,前提必须是先安顿本网段的地点范围才能配置其余网段的。

cat /etc/dhcp/dhcpd.conf

cat /etc/dhcp/dhcpd.conf

Service dhcpd restart

只顾地址池的配置范围势必无法把dhcp服务器的地址(1玖2.16捌.一3七.178)包涵在里面,否则会发生龃龉。

美高梅手机版4858 12

配置完成后,重启网卡服务
systemctl restart network

美高梅手机版4858 13

美高梅手机版4858 14

万壹没不平时求证配置没难点,接着要进去2号机里,setup设置其ip为自行获取,Servicenetwork restart

客户端的布置:

网卡选用:

开启另一台新创建的虚拟机centos6.9,在设置里网络适配器的网络连接模式选择我们自定义的网段的VMnet10网卡。
网络的配置:
新建的centos6.9一般在eth0里的ip地址分配选项默认是选择的是dhcp
自动获取地址所以网卡一般不需要额外配置。

最后在客户端选择同一网段的自定义,重启网络服务就可以收到服务器分发的地址了。我们可以进去网卡查看一下,可以看到网卡是自动获取的 

美高梅手机版4858 15

它报告您去 /usr/share/doc/dhcp*/dhcpd.conf.sample 里面去找一个例证

它报告您去 /usr/share/doc/dhcp*/dhcpd.conf.sample 里面去找三个事例

Dhclient

然后用dhclient取激活一下客户端,用IP a 查看一下,已经赢得到dhcp服务器给客户端的四个地点

美高梅手机版4858 16

一贯重定向 轻松阴毒

直接重定向 轻便狂暴

Ifconfig查看ip和一号机即主机)的ip是不是在贰个网段里,假如在验证方面包车型大巴全部配
值是不利的,表达1号机已经打响的为2号机分配了ip

翻开一下租约的连带音讯
cd /var/lib/dhclient/
ll-t   #查看最新生成的客户端信息
从这里我们就可以知道如果不知道dhcp服务器的地址,默认的服务器地址就是我们用192.18.137.178主机的地址,租期默认是10分钟。

美高梅手机版4858 17

美高梅手机版4858 18

美高梅手机版4858 19

8 接着:cp /usr/lib/syslinux/pxelinux.0  ./uplooking

扩展:

张开文件后其中的内容是:

开垦文件后在那之中的始末是:

9 vim /etc/shcpd.conf   在比极大的轮回里,找一行写上如下音讯

除却大家还足以修改常用的,域名、网关、路由、租期、静态的IP地址等。
  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 }
  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 }

filename “uplooking”;

案例1:

修改域名,和DNS的ip,把域名改成magedu.com;把DNS的iP 改成172.18.0.2 ,和127.1.1.1
把默认租约的时间改成3600;注意格式ip之间用逗号隔开,用分号结尾否则会出现报错。

美高梅手机版4858 20

然后删除 删成那么些样子:

接下来删除 删成这些样子:

10 cp  /mnt/memory/isolinux/* ./

修改网关:

把网关修改成192.168.137.119

美高梅手机版4858 21

美高梅手机版4858 22

美高梅手机版4858 23

11 mkdir pxelinux.cfg

获得一定的IP地址:

获取指定的地址,需要在配置文件中写入,对方客户端的mac地址;
然后指定IP就完成了,现在我们要获取192.168.25.77的固定IP就需要知道它的mac地址。

美高梅手机版4858 24

为了便利把那部分贴出来

为了便于把那有的贴出来

12 mv isolinux.cfg pwelinux.cfg/default

注意事项:

1、dhcp服务不能直接启动的,需要先配置/etc/dhcp/dhcpd.conf 这文件里面的相关内容才能启动服务,否则会报错
[root@centos7 ~]# systemctl start dhcpd
Starting dhcpd:                                            [FAILED]
2、dhcp客户端在网卡配置里选择自动获取,而不是手工配置的时候,会自动获取来自dhcp分给他的地址。

3、如果配置完成后,重启服务 systemctl restart dhcpd ,发现有报错,用这条命令journalctl -xe可以精确查找配置文件/etc/dhcp/dhcpd.conf出错的地方,好加以修改。
4、centos7要想当作dhcp服务器,首先自己的有ip地址,否则dhcpd服务就起不来。
 5、地址池的配置范围是不能包含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;
}
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;
}

13 chkconfig tftp on

接下来就起来布局吧 假如在二个局域网19贰.168.4八.0铺排  
分配给host的ip范围是1九贰.16八.48.十 1九二.168.4八.200 然后先导搞起

下一场就起来布置吧 倘若在贰个局域网192.168.48.0配备  
分配给host的ip范围是1玖二.16八.48.十 1玖贰.16八.4八.200 然后开始搞起

14 service xinetd restart

美高梅手机版4858 25

美高梅手机版4858 26

15 service dhcpd restart

互连网接口配置:

网络接口配置:

1陆到那边在施行一步7,假如没难题,就印证方面包车型客车布署基本上未有毛病了,你只需将二号机重启,在bios里设置互连网运行,就能够了

vim /etc/sysconfig/dhcpd

vim /etc/sysconfig/dhcpd

一七 借使有幸的话,你会看到rhel伍 的设置分界面,到那边截止,你曾经打响
的通过互连网达成了计算机的运行携带,

DHCPDARGS=eth0

DHCPDARGS=eth0

到此地,其实还不可能真的的 安装rhel伍,因为那时您未有将真的的rhel5的安装源的格外地方告诉二号机,入真想安装,能够施行如下:
Vim /etc/exports

 

 

在其少校一号机的rhel5的安装源的贴切挂载停止写上就能够了,然后 service
portmap restart Service tftp
restart到此处差不离就减轻了,嘿嘿,努力吗!

布署一下本土虚拟机的网络

配备一下地点虚拟机的网络

,至少两台微型Computer,恐怕一台计算机方面安装了虚拟机,还有你的处理器的网卡必须能够协理可互连网运营。在那之中几个Computer能够用壹…

美高梅手机版4858 27

美高梅手机版4858 28

以此样子,小编的XShell也就断了

那些样子,作者的XShell也就断了

接下来虚拟机配置一下桥接情势,那样本人的Windows就和虚拟机在二个局域网下了

然后虚拟机配置一下桥接格局,这样本身的Windows就和虚拟机在三个局域网下了

美高梅手机版4858 29

美高梅手机版4858 30

得逞了嘿嘿嘿。

大功告成了嘿嘿嘿。

美高梅手机版4858,可是在此间照旧要说以下细节的

可是在那边依然要说以下细节的

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

本土的Windows网卡要安装自动获得ip自动获得dns

美高梅手机版4858 31

美高梅手机版4858 32

接下来要重启一下网卡才具一蹴而就,这样最简便残酷了。

然后要重启一下网卡才具卓有功效,那样最简便阴毒了。

发表评论

电子邮件地址不会被公开。 必填项已用*标注

网站地图xml地图
Copyright @ 2010-2019 美高梅手机版4858 版权所有