#!/bin/bash
#dhcp-script
read -p "请输入本机
IP地址: " IP
IPNET=$(echo $IP |
linuxjishu/13830.html target=_blank class=infotextkey>awk -F. '{print $1"."$2"."$3}')
IPD="/etc/sysconfig/network-scripts/ifcfg-
eth0"
sed -i 's/IPADDR=.*/IPADDR='"$IP"'/' $IPD
sed -i 's/GATEWAY=.*/GATEWAY='"$IPNET"'.1/' $IPD
service network restart &> /dev/null
rpm -q dhcp &> /dev/null
[ $? -eq 0 ] ||
yum -y install dhcp &> /dev/null
cd /usr/share/doc/dhcp-3.0.5
grep -v "#" dhcpd.conf.sample |grep -v "^$"|sed -e 's/192.168.0/'"$IPNET"'/g' > /etc/dhcpd.conf
service dhcpd start