PAJEROHEL6无人值班守护安装,最简便易行的DHCP服务

2019-07-22 作者:yzc216亚洲城   |   浏览(131)

在网络上有很多关于无人值守安装方法,但是大部分都是用 FTP,用HTTP 和 FTP 基本上差不多,所以今天我们没事干就用 NFS 也安装了一个,发现 NFS 和那两个有些区别,所以就和大家一起来分享一下我的实验成果 ,希望能给大家带来一些帮助。

这几天在准备网络安装linux操作系统。最后决定用pxe kickstart 的方式完成。原理、方案弄完了之后,开始搭建,结果被DHCP给挡住了。这不就得研究研究最简单最实用的DHCP使用方法。

方法:NFS TFTP DHCP Kickstart PXE
准备两台虚拟机,一台作为测试环境(RHEL6,IP 为 192.168.0.254),另一台作为RHEL6被安装端,设置网络引导安装。
安装所需要的服务及修改相应配置文件 :

* 红色的是必须有

1.用 yum 来安装所需要的软件包,先来搭建 yum 光盘源:
[root@www.linuxidc.com ~]# mount /dev/cdrom /mnt
在/etc/yum.repos.d 目录下创建一个以.repo 结尾的文件:
[root@www.linuxidc.com ~]# vi /etc/yum.repos.d/server.repo
配置内容如下:
[server]
name=this is my yum server
baseurl=file:///mnt /Server
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-RedHat-release
然后执行 rpm –import /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
gpgkey
2.安装 TFTP,修改 tftp 配置文件及开启服务
[root@www.linuxidc.com ~]# yum install tftp-server
Loaded plugins: refresh-packagekit, rhnplugin
This system is not registered with RHN.
RHN support will be disabled.
aaa
| 3.7 kB 00:00 ...
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package tftp-server.x86_64 0:0.49-5.1.el6 set to be updated
--> Finished Dependency Resolution

* 绿色的是要注意

Dependencies Resolved

===========================================
Package
Arch
Version
Repository

 

Size

===========================================
Installing:
tftp-server
x86_64
0.49-5.1.el6
aaa
39 k

* 蓝色的是包安装时,要有的程序包

Transaction Summary

===========================================
Install
1 Package(s)
Upgrade
0 Package(s)
Total download size: 39 k
Installed size: 57 k
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : tftp-server-0.49-5.1.el6.x86_64
1/1
Installed:
tftp-server.x86_64 0:0.49-5.1.el6
Complete!
[root@www.linuxidc.com yzc216亚洲城官方网站,~]#
[root@www.linuxidc.com ~]# vim /etc/xinetd.d/tftp
# default: off
# description: The tftp server serves files using the trivial file transfer
#
protocol. The tftp protocol is often used to boot diskless
#
workstations, download configuration files to network-aware printers,
#
and to start the installation process for some operating systems.
service tftp
{
socket_type  = dgram
protocol  = udp
wait  = yes
user  = root
server  = /usr/sbin/in.tftpd
server_args  = -s /var/lib/tftpboot
disable   = no
per_source  = 11
cps    = 100 2
flags   = IPv4
}
[root@www.linuxidc.com ~]# /etc/init.d/xinetd restart
Stopping xinetd:
[ OK ]
Starting xinetd:
[ OK ]
[root@www.linuxidc.com ~]#
~
3.在/下面创建一个 NFS 目录,并且共享出去如下:
[root@www.linuxidc.com ~]# mkdir /NFS
[root@www.linuxidc.com ~]# vim /etc/exports
/NFS
192.168.0.0/24(rw,sync)
[root@www.linuxidc.com ~]# /etc/init.d/nfs restart
Shutting down NFS mountd:
Shutting down NFS daemon:
Shutting down NFS quotas:
Starting NFS services:
Starting NFS quotas:
Starting NFS daemon:
Starting NFS mountd:
[FAILED]
[FAILED]
[FAILED]
[ OK ]
[ OK ]
[ OK ]
[ OK ]
4.安装 dhcp,修改配置文件及开启服务:
[root@www.linuxidc.com ~]# yum install dhcp -y
Loaded plugins: refresh-packagekit, rhnplugin
This system is not registered with RHN.
RHN support will be disabled.
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package dhcp.x86_64 12:4.1.1-12.P1.el6 set to be updated
--> Finished Dependency Resolution

 

Dependencies Resolved

===========================================
Package
Arch
Version
Repository

1. DHCP的实现

Size

===========================================
Installing:
dhcp
x86_64
12:4.1.1-12.P1.el6
aaa
820 k

2. 配置文件实例

Transaction Summary

===========================================
Install
1 Package(s)
Upgrade
0 Package(s)
Total download size: 820 k
Installed size: 2.0 M
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : 12:dhcp-4.1.1-12.P1.el6.x86_64
1/1
Installed:
dhcp.x86_64 12:4.1.1-12.P1.el6
Complete!
[root@www.linuxidc.com ~]#
[root@www.linuxidc.com ~]# cp /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample
/etc/dhcp/dhcpd.conf
[root@www.linuxidc.com ~]# vim /etc/dhcp/dhcpd.conf(RHEL6 原文件内容如下所示,一
开始看上去可能觉得很乱)
# 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
# have to hack syslog.conf to complete the redirection).
log-facility local7;
# No service will be given on this subnet, but declaring it helps the
# DHCP server to understand the network topology.
subnet 10.152.187.0 netmask 255.255.255.0 {
}
# This is a very basic subnet declaration.
subnet 10.254.239.0 netmask 255.255.255.224 {
range 10.254.239.10 10.254.239.20;
option routers rtr-239-0-1.example.org, rtr-239-0-2.example.org;
}
# This declaration allows BOOTP clients to get dynamic addresses,
# which we don't really recommend.
subnet 10.254.239.32 netmask 255.255.255.224 {
range dynamic-bootp 10.254.239.40 10.254.239.60;
option broadcast-address 10.254.239.31;
option routers rtr-239-32-1.example.org;
}
# A slightly different configuration for an internal subnet.
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;
}
# Hosts which require special configuration options can be listed in
# host statements. If no address is specified, the address will be
# allocated dynamically (if possible), but the host-specific information
# will still come from the host declaration.
host passacaglia {
hardware ethernet 0:0:c0:5d:bd:95;
filename "vmunix.passacaglia";
server-name "toccata.fugue.com";
}
# Fixed IP addresses can also be specified for hosts. These addresses
# should not also be listed as being available for dynamic assignment.
# Hosts for which fixed IP addresses have been specified can boot using
# BOOTP or DHCP. Hosts for which no fixed address is specified can only
# be booted with DHCP, unless there is an address range on the subnet
# to which a BOOTP client is connected which has the dynamic-bootp flag
# set.
host fantasia {
hardware ethernet 08:00:07:26:c0:a5;
fixed-address fantasia.fugue.com;
}
# You can declare a class of clients and then do address allocation
# based on that. The example below shows a case where all clients
# in a certain class get addresses on the 10.17.224/24 subnet, and all
# other clients get addresses on the 10.0.29/24 subnet.
class "foo" {
match if substring (option vendor-class-identifier, 0, 4) = "SUNW";
}
shared-network 224-29 {
subnet 10.17.224.0 netmask 255.255.255.0 {
option routers rtr-224.example.org;
}
subnet 10.0.29.0 netmask 255.255.255.0 {
option routers rtr-29.example.org;
}
pool {
allow members of "foo";
range 10.17.224.10 10.17.224.250;
}
pool {
deny members of "foo";
range 10.0.29.10 10.0.29.230;
}
}
所以我把 RHEL5 里的 dhcp 原文件复制过来如下:
ddns-update-style interim;
ignore client-updates;
filename "pxelinux.0";
next-server 192.168.0.254; (这两行是新加的内容)
subnet 192.168.0.0 netmask 255.255.255.0 {
# --- default gateway
option routers
option subnet-mask
192.168.0.254;
255.255.255.0;
option nis-domain
"domain.org";
option domain-name
"domain.org";
option domain-name-servers
192.168.0.254;
option time-offset
-18000; # Eastern Standard Time
#
option ntp-servers
192.168.1.1;
#
option netbios-name-servers 192.168.1.1;
# --- Selects point-to-point node (default is hybrid). Don't change this unless
# -- you understand Netbios very well
#
option netbios-node-type 2;
range dynamic-bootp 192.168.0.100 192.168.0.200;
default-lease-time 21600;
max-lease-time 43200;
# we want the nameserver to appear at a fixed address
host ns {
next-server marvin.redhat.com;
hardware ethernet 12:34:56:78:AB:CD;
fixed-address 207.175.42.254;
}
}
[root@www.linuxidc.com ~]# /etc/init.d/dhcpd configtest
Syntax: OK
[root@www.linuxidc.com ~]# /etc/init.d/dhcpd restart
Starting dhcpd:
[ OK ]
[root@www.linuxidc.com ~]#

yzc216亚洲城官方网站 1

实例1

实例2


1. DHCP的实现

DHCP服务必须给本网段提供一个地址池。

 

# yum -y install dhcp-devel

# rpm -aq | grep dhcp

dhcp-4.1.1-38.P1.el6.CentOS.i686

dhcp-devel-4.1.1-38.P1.el6.centos.i686

# cp /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcp/dhcpd.conf

 

# vi dhcpd.conf

ddns-update-style interim( 这项不能少,否则服务起不来的 )

default-lease-time 21600;

max-lease-time 43200;

option domain-name “test.com”;

option domain-name-servers 192.168.1.1,202.106.0.20;

 

subnet 192.168.1.0 netmask 255.255.2550 {

range 192.168.1.128 192.168.1.254;

option subnet-mask 255.255.255.0;

option routers 192.168.1.1;

}

 

host server01 {

hardware ethernet 0:c0:c3:22:46:81;

fixed-address 192.168.1.11;

option subnet-mask 255.255.255.0;

option routers 192.168.1.1;

}

 

subnet 117.34.70.0 netmask 255.255.255.0 {

default-lease-time 21600;

max-lease-time 43200;

option routers 117.34.70.1;

option subnet-mask 255.255.255.0;

 

}

 

一台主机有多块网卡,需要在某个网卡上启用DHCP服务时,需要配置如下:

# vi /etc/sysconfig/dhcpd

 

# Command line options here

DHCPDARGS=eth0

 

 


2. 配置文件实例

简单的样例:(红色部分必须有)

 

# vi /etc/dhcp/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

# have to hack syslog.conf to complete the redirection).

log-facility local7;

 

# No service will be given on this subnet, but declaring it helps the

# DHCP server to understand the network topology.

 

subnet 117.34.73.0 netmask 255.255.255.0 {

}

 

subnet 10.152.187.0 netmask 255.255.255.0 {

}

 

# vi /etc/dhcp/dhcpd.conf

default-lease-time 600;

max-lease-time 7200;

 

ddns-update-style none;

 

subnet 117.34.73.0 netmask 255.255.255.0 {

}

相关阅读:

Linux系统下构建DHCP服务器 http://www.linuxidc.com/Linux/2013-06/86531.htm

CentOS下配置主从DNS服务器以及DHCP下的DDNS http://www.linuxidc.com/Linux/2013-06/85634.htm

SUSE Linux 11 pxe DHCP tftp ftp 无人值守安装 http://www.linuxidc.com/Linux/2013-06/85481.htm

Linux下架设DHCP服务器过程及3种测试 http://www.linuxidc.com/Linux/2013-05/84832.htm

Linux上一步一步实现DHCP服务器 http://www.linuxidc.com/Linux/2013-04/82244.htm

yzc216亚洲城官方网站 2

本文由yzc216亚洲城发布于yzc216亚洲城,转载请注明出处:PAJEROHEL6无人值班守护安装,最简便易行的DHCP服务

关键词: yzc216亚洲城