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。


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  /etc/sysconfig/network-scripts/ifcfg-eth0

编辑内容如下:


2.systemctl restart network            重启服务获得ip

3.ifconfig                         **查看ip



三.cat /var/lib/dhcpd/dhcpd.leases     查看分配的ip客户端的mac(物理)地址


tftp服务:

在服务端安装tftp,dhcp,syslinux


打开tftp服务(默认关闭)

systemctl restart xinetd.service 重置tftp服务


rpm -ql tftp-server  找到tftp-server服务的配置文件目录

cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/下

cd /var/lib/tftpboot/

ls

将镜像中isolinux目录下的所有文件放在配置文件的目录下

查询pexlinux.0说明书

根据说明书操作

建立目录

建立文件

修改dhcp配置文件


重启dhcp服务,设置firewalld

修改配置文件



虚拟机启动,boot选择网卡启动(全自动安装)

启动后