linux系统下Dhcp服务介绍
dhcp服务:
一.服务端
(1)配置服务器ip为静态
1.通过图形修改:nm-connection-editor
2.配置yum源
cd /etc/yum.repos.d------ls------vim rhel_dvd.repo(配置yum源)------yum install dhcp -y(安装dhcp)------ yum clean all(清空yum缓
存)
3.rpm -qc dhcp 查看dhcp的配置文件在哪里
4.vim /etc/dhcp/dhcpd.conf 查看配置文件
5.cp /usr/share/doc/dhcp*/dhcpd.conf.example(配置文件模板) /etc/dhcp/dhcpd.conf复制配置文件模板到/etc/dhcp/dhcpd.conf。
6.vim /etc/dhcp/dhcpd.conf 修改配置文件
编辑内容如下:
6 # option definitions common to all supported networks...
7 option domain-name "westos.com"; **域名
8 option domain-name-servers 172.25.254.250; **dns地址
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
28
29 # This is a very basic subnet declaration.
30
31 subnet 172.25.254.0 netmask 255.255.255.0 { **设定分配ip的网络位
32 range 172.25.254.200 172.25.254.220; **ip地址池
33 option routers 172.25.254.250; **客户主机获得的网关
7.systemctl restart dhcpd **重启dhcp服务
二.客户端
1.编辑配置文件修改dhcp:vim
编辑内容如下:
HWADDR=52:54:00:00:07:0B
TYPE=Ethernet
BOOTPROTO=dhcp
NAME=eth0
ONBOOT=yes
2.systemctl restart network **重启服务获得ip
3.ifconfig **查看ip
三.cat /var/lib/dhcpd/dhcpd.leases **查看分配的ip客户端的mac(物理)地址
se 172.25.254.212 {
starts 4 2018/04/12 05:06:56;
ends 4 2018/04/12 05:16:56;
cltt 4 2018/04/12 05:06:56;
binding state active;
next binding state free;
rewind binding state free;
hardware ethernet 52:54:00:00:07:0b; 客户端mac(物理)地址
}
tftp服务:
服务端:
1.yum install tftp -y(安装tftp服务)
2.cd /var/lib/tftpboot/ **移动到目录下
3.mkdir pxelinux.cfg **新建目录
4.cp isolinux.cfg pxelinux.cfg/default **复制文件
5.scp root@172.25.254.7:/var/www/html/pub/rhel7.2/isolinux/* /var/lib/tftpboot/
**复制镜像中的文件
6.编辑配置文件: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 **开启tftp
per_source = 11
cps = 100 2
flags = IPv4
}
7.systemctl restart xinetd.service **重启服务
8.chkconfig --list **查看状态
xinetd based services:
chargen-dgram: off
chargen-stream: off
daytime-dgram: off
daytime-stream: off
discard-dgram: off
discard-stream: off
echo-dgram: off
echo-stream: off
tcpmux-server: off
tftp: on **tftp服务开启
time-dgram: off
time-stream: off
9.编辑配置文件:vim /etc/dhcp/dhcpd.conf
内容为:
# This is a very basic subnet declaration.
subnet 172.25.254.0 netmask 255.255.255.0 {
range 172.25.254.200 172.25.254.220;
option routers 172.25.254.250;
next-server 172.25.254.107;
filename "pxelinux.0";
}
10.systemctl restart dhcpd **重启服务
11.systemctl stop firewalld **关闭防火墙
测试端:
1.virt-manager **开启显示虚拟机
2.点灯泡------boot options------网卡------屏幕------开始
通过物理地址安装虚拟机:
服务端:
1.编辑文件:vim default
内容如下:
64 kernel vmlinuz
65 append initrd=initrd.img repo=http://172.25.254.7/pub/rhel7.2/ **yum源位置
66
67 label check61 label linux
62 menu label ^Install Red Hat Enterprise Linux 7.2
63 menu default **默认在第一行
64 kernel vmlinuz
2.systemctl stop firewalld **关闭防火墙
测试端:
1.virt-manager **开启显示虚拟机
2.点灯泡------boot options------网卡------屏幕------开始
10.systemctl restart dhcpd **重启服务
11.systemctl stop firewalld **关闭防火墙
上一篇: 走出“色界”之路:成人情色论坛站长的忏悔