linux系统部署dhcp服务和tftp服务

dhcp服务和tftp服务

一.dhcp服务:

服务端:

1.配置服务器ip为静态:通过图形修改: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;                              **客户主机获得的网关

修改域名和dns地址


删除27,28行的内容

设定分配ip的网络位,设定ip地址池,客户主机获得的网关,34行以后的内容都删除。


7.systemctl restart dhcpd         **重启dhcp服务


二.客户端

1.编辑配置文件修改dhcp:vim  /etc/sysconfig/network-scripts/ifcfg-eth0

编辑内容如下:
DEVICE=eth0                      网卡名称
BOOTPROTO=dhcp           动态网络
ONBOOT=yes                     
TYPE=Ethernet                    类型Ethernet
USERCTL=yes
PEERDNS=yes
PERSISTENT_DHCTLENT=1



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.yum whatprovides  */pxelinux.0         **下载引导文件

3.yum  install  syslinux-4.05-12.el7.x86_64 tftp-server     **安装syslinux


3.cd /var/lib/tftpboot/                           **移动到目录下

4.mkdir pxelinux.cfg                           **新建目录


touch  /pxelinux.cfg/fefault

4.scp  root@172.25.254.7:/var/www/html/pub/rhel7.2/isolinux/isolinux.cfg     /var/lib/ftpboot/

  pxelinux.cfg/default   **复制文件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     **重启服务(版本不同用以下方法)

rpm  -ql  tftp-server          查看tftp-server生成的文件

systemctl  restart  tftp                               重启tftp

systemctl   start  tftp.socket                       打开tftp服务

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

netstat   -antlupe   |  grep   69                查看69接口是否打开

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.点open------点灯泡------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 check


 61 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.poen------点灯泡------boot options------网卡------屏幕------开始





  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值