运维自动化之系统部署

实验:搭建dhcp服务器

实验⽬的
搭建可为局域网主机分配ip地址的dhcp服务器,为后面pxe实验做准备。
前提准备

一台没有ip地址的centos6主机,一台CentOS7虚拟机作为DHCP服务器;网卡设为NAT模式,设置固定IP地址,
关闭虚拟机的DHCP功能
在这里插入图片描述在这里插入图片描述
在局域网中实验切勿不能桥接模式

前提:
1、关闭iptables,selinux服务

 [root@centos7 ~]#iptables -F
[root@centos7 ~]#systemctl stop firewalld
[root@centos7 ~]#setenforce 0

2、安装DHCP服务包并启动dhcp服务
在这里插入图片描述
在这里插入图片描述
发现dhcpd服务启动失败,原因是未配置dhcp.conf⽂件:
3、修改dhcp配置⽂件
系统⾃带的dhcp.conf是空⽂件,找到安装包⾃带的example进⾏修改

在这里插入图片描述
拷贝参考文件 覆盖 之后修改配置文件
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
上图是参考文件修改配置文件

重启dhcp服务,并设置开机⾃启动:

[root@centos7 ~]#systemctl start dhcpd.service
[root@centos7 ~]#systemctl enable dhcpd.service

4、切换到另外⼀台CentOS6虚拟机,查看是否获取到ip地址
在这里插入图片描述
原地址192.168.39.100

重新获取DHCP地址

[root@kaivi6 ~]#dhclient -d

在这里插入图片描述
再次查看获取到ip地址(192.168.39.10),表⽰dhcp服务已搭建成功。

利⽤systemctl status dhcpd 命令可观察dhcp分发地址的全过程:在这里插入图片描述

搭建tftp服务器

实验⽬的

搭建ftp文件服务器,为后面pxe实验做准备。
可用centos7系统作为tftp服务器端,centos6系统作为tftp客户端,且关闭selinux和防火墙软件。

tftp服务器端: CentOS7:192.168.39.102
tftp客户端: CentOS6:192.168.39.100

1、tftp服务器端
安装tftp服务:
在这里插入图片描述在这里插入图片描述
在这里插入图片描述 查看tftp包信息

centos6的启动服务

 [root@kaivi6 ~]#chkconfig tftp on
[root@kaivi6 ~]#service xinetd restart
Stopping xinetd:                                           [FAILED]
Starting xinetd:                                           [  OK  ]
[root@kaivi6 ~]#service xinetd restart
Stopping xinetd:                                           [  OK  ]
Starting xinetd:                                           [  OK  ]
[root@kaivi6 ~]#chkconfig tftp enable

centos7上的启动服务

[root@centos7 ~]#systemctl start tftp.socket 
[root@centos7 ~]#systemctl enable tftp.socket 

[root@centos7 ~]#systemctl start tftp.socket 
[root@centos7 ~]#systemctl status tftp.socket 

在这里插入图片描述
查看对应的端口号 tftp对应端口号69是否开启
在这里插入图片描述
3、测试tftp服务
服务器端:拷贝一些⽂件到tftp⽬录下:

[root@centos7 ~]#cp /etc/fstab /var/lib/tftpboot/
[root@centos7 ~]#cp /etc/issue /var/lib/tftpboot/
[root@centos7 ~]#cd /var/lib/tftpboot/
[root@centos7 tftpboot]#ll
-rw-r--r-- 1 root root 595 Nov 13 22:20 fstab
-rw-r--r-- 1 root root  23 Nov 13 22:24 issue
[root@kaivi6 ~]#tftp 192.168.39.102
tftp> get issue
tftp> q

[root@kaivi6 ~]#tftp 192.168.39.102
tftp> get fstab 
tftp> q
[root@kaivi6 ~]#ls  

⽂件通过tftp传输成功 查看是否成功开启服务 修改了一些文件里面的内容 和原有的文件做区别
在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值