红联Linux门户
Linux帮助

求帮助啊!做的自动安装DHCP看看哪儿出问题了

发布时间:2014-09-11 22:27:56来源:红联作者:wangwenjie2500
#!/bin/bash

#一键安装dhcp

read -p "请输入服务的ip地址:" IP

Subnet=$( echo $IP | awk -F"." '{print $1"."$2"."$3}' )

IPCONF="/etc/sysconfig/network-scripts/ifcfg-eth0"

DHCP=$( cat $IPCONF | grep "BOOTPROTO" | awk -F "=" '{print $2}' )

if (( $DHCP -ne = "dhcp" ))

then

sed -i 's/^IPADDR/IPADDR="$IP"/' $IPCONF

else
sed -i 's/^ONBOOT/IPADD="$IP"/' $IPCONF

fi

service network restart

mount /dev/cdrom /mnt/

cd /mnt/Server/

rpm -ivh $( ls | grep "^dhcp-3*" ) &>/dev/null

BB=$(rpm -qa | grep "^dhcp-3.*')

\cp /user/share/doc/$BB/dhcpd.conf.sample /etc/dhcpd.conf

sed -i 'a/192.168.0/$Subnet/g' /etc/dhcpd.conf

service dhcpd restart
文章评论

共有 0 条评论