编写安装配置DHCP服务脚本
2013-07-05 07:33
513 查看
要求:
1、自动完成安装,基本配置
2、通过提示输入网段、子网掩码、网关、DNS、IP起止地址等信息完成作用域的添加
【方法一】:
#!/bin/bash
conf="/etc/dhcpd.conf"
rpm -q dhcp &> /dev/null
if [ $? -ne 0 ];then
yum -y install dhcp
fi
grep "subnet" $conf &> /dev/null
if [ $? -ne 0 ]; then
echo "
ddns-update-style interim;
ignore client-updates;
default-lease-time 21600;
max-lease-time 43200;
" > $conf
fi
read -p "please input network:" network
read -p "please input netmask:" netmask
read -p "please input gateway:" gateway
read -p "please input DNS:" dns
read -p "please input start_ip:" start_ip
read -p "please input end_ip:" end_ip
echo "
subnet $network netmask $netmask {
option routers $gateway;
option subnet-mask $netmask;
option domain-name-servers $dns;
range dynamic-bootp $start_ip $end_ip;
}
" >> $conf
service dhcpd restart
【方法二】:
#!/bin/bash
dhcpconf=/etc/dhcpd.conf
rpm -q dhcp &> /dev/null
if [ $? -ne 0 ];then
yum -y install dhcp
fi
grep "subnet" $dhcpconf &> /dev/null
if [ $? -ne 0 ];then
echo "ddns-update-style interim;
ignore client-updates;
default-lease-time 21600;
max-lease-time 43200;" > $dhcpconf
fi
while true
do
read -p "please input Network:" network
read -p "please input Netmask:" netmask
read -p "please input Gateway:" gateway
read -p "please input DNS:" dns
read -p "please input Start_IP:" start_ip
read -p "please input End_IP:" end_ip
grep $network $dhcpconf &> /dev/null
if [ $? -ne 0 ];then
echo "subnet $network netmask $netmask {
option routers $gateway;
option subnet-mask $netmask;
option domain-name-servers $dns;
range dynamic-bootp $start_ip $end_ip;
}" >> $dhcpconf
read -p "continue to do (yes/no)?" yn
if [ $yn = "no" ]; then
service dhcpd status &> /dev/null
if [ $? -ne 0 ]; then
service dhcpd start &> /dev/null
else
service dhcpd reload &> /dev/null
fi
exit 0
fi
fi
done
1、自动完成安装,基本配置
2、通过提示输入网段、子网掩码、网关、DNS、IP起止地址等信息完成作用域的添加
【方法一】:
#!/bin/bash
conf="/etc/dhcpd.conf"
rpm -q dhcp &> /dev/null
if [ $? -ne 0 ];then
yum -y install dhcp
fi
grep "subnet" $conf &> /dev/null
if [ $? -ne 0 ]; then
echo "
ddns-update-style interim;
ignore client-updates;
default-lease-time 21600;
max-lease-time 43200;
" > $conf
fi
read -p "please input network:" network
read -p "please input netmask:" netmask
read -p "please input gateway:" gateway
read -p "please input DNS:" dns
read -p "please input start_ip:" start_ip
read -p "please input end_ip:" end_ip
echo "
subnet $network netmask $netmask {
option routers $gateway;
option subnet-mask $netmask;
option domain-name-servers $dns;
range dynamic-bootp $start_ip $end_ip;
}
" >> $conf
service dhcpd restart
【方法二】:
#!/bin/bash
dhcpconf=/etc/dhcpd.conf
rpm -q dhcp &> /dev/null
if [ $? -ne 0 ];then
yum -y install dhcp
fi
grep "subnet" $dhcpconf &> /dev/null
if [ $? -ne 0 ];then
echo "ddns-update-style interim;
ignore client-updates;
default-lease-time 21600;
max-lease-time 43200;" > $dhcpconf
fi
while true
do
read -p "please input Network:" network
read -p "please input Netmask:" netmask
read -p "please input Gateway:" gateway
read -p "please input DNS:" dns
read -p "please input Start_IP:" start_ip
read -p "please input End_IP:" end_ip
grep $network $dhcpconf &> /dev/null
if [ $? -ne 0 ];then
echo "subnet $network netmask $netmask {
option routers $gateway;
option subnet-mask $netmask;
option domain-name-servers $dns;
range dynamic-bootp $start_ip $end_ip;
}" >> $dhcpconf
read -p "continue to do (yes/no)?" yn
if [ $yn = "no" ]; then
service dhcpd status &> /dev/null
if [ $? -ne 0 ]; then
service dhcpd start &> /dev/null
else
service dhcpd reload &> /dev/null
fi
exit 0
fi
fi
done
相关文章推荐
- 编写安装配置DNS服务脚本
- [置顶] 编写shell脚本以及利用函数实现批量安装Linux服务配置
- 编写安装配置httpd服务基于域名的虚拟主机脚本
- 在windows powershell中利用脚本自动安装和配置DHCP服务
- 编写安装配置mail服务脚本
- 编写安装配置ftp-samba服务脚本
- 编写安装配置LAMP服务脚本
- 关于linux - Centos 7 下DHCP服务的安装与配置
- nginx编译安装之后如何配置服务脚本
- PXE 自动安装物理机 (DHCP服务由路由提供, 不能再配置)
- DHCP服务安装配置
- shall 脚本-DHCP安装和配置
- 编译安装bind及SysV服务脚本编写
- nginx 安装、编写启动脚本、配置
- centos安装与配置dhcp服务
- rsync同步服务安装配置及脚本使用
- Linux服务器 CentOS 6系列最小化安装优化脚本详解02————修改history记录、定时校正服务器时间、停止IPv6网络服务、调整最大文件打开数、关闭写磁盘I/O功能、配置SSH服务
- 如何在Ubuntu服务器上安装和配置DHCP服务(转载)
- linux/unix 安装配置DHCP服务
- 安装、授权和配置DHCP服务(中)