实验:搭建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传输成功 查看是否成功开启服务 修改了一些文件里面的内容 和原有的文件做区别