#!/bin/bash
#NFS 共享服务
#2019-8-25
#挂载光盘
d -p "请输入你的挂载点" dir
echo "正在挂载。。。。。"
mount | grep -q "/dev/sr0" && umount /dev/sr0
[ -d $dir ] || mkdir dir
mount /dev/sr0 $dir &> /dev/null
echo "挂载成功"
cd /etc/yum.repos.d/
[ -d likun ] || mkdir likun
mv C* likun
cat << EDF > local.repo
[xxx]
name=xxx
baseurl=file://$dir
enabled=1
gpgcheck=0
EDF
echo "清除小朋友"
yum clean all &> /dev/null
echo "构建轰趴基地yum"
yum makecache &> /dev/null
echo "构建成功"
#准备环境
rpm -q nfs rpccbind &>/dev/null
yum -y install nfs-utills rpcbind &>/dev/null
echo "安装成功"
#启动服务
/etc/init.d/rpcbind start
/etc/init.d/nfs start
echo "启动成功"
#建立挂载编写
mkdir /www
echo ‘test‘ >/www/index.html
cat << EDF >/etc/exports
/www 192.168.100.68(rw) 192.168.100.66(ro)
EDF
echo "配置成功"
#重启服务
/etc/init.d/nfs restart &> /dev/null
echo "重启成功"
#查看信息
showmount -e 192.168.100.68
#编辑DNCP中继器
#!/sbin/bash
echo "开启中继"
echo "关闭安全机制中。。。"
systemctl stop firewalld
iptables -F
setenforce 0
#DHCP服务
echo "构建环境"
echo "DHCP安装中..."
yum -y install dhcp &>/dev/null
echo "配置文件"
cat << EOF >> /etc/systemctl.conf
net.ipv4.ip _forward=1
EOF
echo "中继路由启动"
sysctl -p
read -p "DHCP服务器IP" lal
echo "开启转发"
dhcrelay $lal
原文地址:https://www.cnblogs.com/123456likun/p/11414630.html