双星科技需要配置一台RHEL6.3的文件服务器,使企业员工可以可以方便的进行资源共享。
1. 根据下图所示搭建网络环境,部门中除技术部为RHEL6.3系统外,其他部门客户端都是WinXP;每个部门配置一台测试客户机,IP地址必须如下图所示;DHCP服务器为市场部和财务部提供地址分配,测试客户机的IP地址必须是从服务器自动获取的。(服务器区Vmnet8,市场部网卡Vmnet1,财务部网卡Vmnet2,技术部网卡Vmnet3)
首先确保虚拟机之间能正常通信(搭建好网络环境)
服务器1.安装dhcp软件包
[root@localhost ~]# yum install dhcp -y
2.配置dhcp服务主配置文件
[root@localhost ~]# cp /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcp/dhcpd.conf -fcp: overwrite `/etc/dhcp/dhcpd.conf'? y[root@localhost ~]# vim /etc/dhcp/dhcpd.conf[root@localhost ~]# cat /etc/dhcp/dhcpd.conf
subnet 192.168.0.0 netmask 255.255.255.0 {
}subnet 192.168.10.0 netmask 255.255.255.0 { range 192.168.10.10 192.168.10.250; option routers 192.168.10.254;}subnet 192.168.20.0 netmask 255.255.255.0 { range 192.168.20.10 192.168.20.250; option routers 192.168.20.254;}subnet 192.168.30.0 netmask 255.255.255.0 { range 192.168.30.10 192.168.30.250; option routers 192.168.30.254;}
3.重启服务
[root@localhost ~]# service dhcpd restartShutting down dhcpd: [ OK ]Starting dhcpd: [ OK ]
#设置dhcpd服务开机自启动
[root@localhost ~]# chkconfig dhcpd on
4.关闭防火墙
[root@localhost ~]# iptables -F[root@localhost ~]# setenforce 0
#上面两条是临时关闭防火墙策略,要开启不启动按下面方式设置
[root@localhost ~]# chkconfig iptables off[root@localhost ~]# vim /etc/sysconfig/selinux[root@localhost ~]# grep ^S /etc/sysconfig/selinuxSELINUX=disabled #开机不加载selinux策略SELINUXTYPE=targeted
中继器#添加3块网卡(vmnet)
#分别把4块网卡的ip配置为192.168.0/10/20/30.254,这台主机做路由器1.开启路由功能[root@localhost ~]# vim /etc/sysctl.conf[root@localhost ~]# sysctl -pnet.ipv4.ip_forward = 1
2.修改dhcrelay(dhcp中继服务)的配置文件
[root@localhost ~]# vim /etc/sysconfig/dhcrelay[root@localhost ~]# tail -4 /etc/sysconfig/dhcrelay
# DHCPv4 only
INTERFACES="eth0 eth3 eth2 eth1" DHCPSERVERS="192.168.0.8"#通过查看67号端口检查dhcrelay服务是否开启
[root@localhost ~]# lsof -i :67
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
dhcrelay 27657 root 8u IPv4 37609 0t0 UDP *:bootps[root@localhost ~]# service dhcrelay restart #重启dhcrelay服务
Shutting down dhcrelay: [ OK ]
Starting dhcrelay: [ OK ][root@localhost ~]# chkconfig dhcrelay on #设置开机启动
客户机#客户机只要配置好相应的vmnet就能通过dhcp中继服务和dhcp服务自动获取到ip
#自动获取ip之前先确保客户机能好服务器通信,搭建好网络环境
2. 为服务器配置基于FTP的yum源,yum源的位置为/ftp/yum/,要求配合自动挂载器将光驱自动挂载到/ftp/yum,启用gpgcheck,技术部yum源指向服务器
1.安装所需软件包
[root@localhost ~]# yum install vsftpd autofs -y
2.修改dhcp主配置文件
[root@localhost ~]# vim /etc/vsftpd/vsftpd.conf[root@localhost ~]# grep yum /etc/vsftpd/vsftpd.confanon_root=/ftp/yum #将匿名用户的根目录修改到指定目录/ftp/yum
3.修改autofs主配置文件
[root@localhost ~]# vim /etc/auto.master[root@localhost ~]# cat /etc/auto.master |grep yum/ftp/yum /etc/auto.yum #添加神奇目录
4.修改神奇目录配置文件
[root@localhost ~]# cp -a /etc/auto.misc /etc/auto.yum[root@localhost ~]# vim /etc/auto.yum[root@localhost ~]# cat /etc/auto.yum |grep rhelrhel6.3 -fstype=iso9660,ro,nosuid,nodev :/dev/cdrom #添加自动挂载点
5.创建所需目录并重启服务
[root@localhost ~]# mkdir /ftp/yum -p[root@localhost ~]# service autofs restartStopping automount: [ OK ]Starting automount: [ OK ]
[root@localhost ~]# service vsftpd restartShutting down vsftpd: [FAILED]Starting vsftpd for vsftpd: [ OK ]
6.设置开机启动
[root@localhost ~]# chkconfig vsftpd on[root@localhost ~]# chkconfig autofs on
7.验证自动挂载点#下面现象说明自动挂载成功
[root@localhost ~]# ls /ftp/yum/[root@localhost ~]# ls /ftp/yum/rhel6.3
EULA README RELEASE-NOTES-hi-IN.html RELEASE-NOTES-pa-IN.html repodata
GPL RELEASE-NOTES-as-IN.html RELEASE-NOTES-it-IT.html RELEASE-NOTES-pt-BR.html ResilientStorage. . . . . .
8.配置yum源客户端#服务器和技术部客户端都是同样的配置
[root@localhost ~]# vim /etc/yum.repos.d/local.repo[root@localhost ~]# cat /etc/yum.repos.d/local.repo
[ftp]
name=ftpbaseurl=ftp://192.168.0.8/rhel6.3enabled=1gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release[root@localhost ~]# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release #导入gpg文件[root@localhost ~]# yum clean all
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
Updating certificate-based repositories.Unable to read consumer identityCleaning repos: InstallMedia ftpCleaning up Everything[root@localhost ~]# yum list
通过yum list查看yum源是否可用