#!/bin/sh
ETHCONF=/etc/sysconfig/network-scripts/ifcfg-eth0
HOSTS=/etc/hosts
NETWORK=/etc/sysconfig/network
NETMASK=255.255.255.0
###
function Change_ip ()
{
grep "dhcp" $ETHCONF
if [ $? -eq 0 ];then
read -p "Please insert ip Address:" IPADDR
sed -i ‘s/dhcp/static/g‘ $ETHCONF
echo -e "IPADDR=$IPADDR\nNETMASK=$NETMASK\nGATEWAY=`echo $IPADDR|awk -F. ‘{print $1"."$2"."$3}‘`.2" >>$ETHCONF
echo "This IP address Change success !"
时间: 2024-10-02 14:54:25