Add IP aliases script

this script assumes the following :
1) we need to enter the config file for the IP-aliases
2) we need to enter the ip number

#!/bin/bash
clear
read -p "Enter the IP number: [example eth0:1 eth0:2]: " ip
read -p "Enter the configuration file : " cf
path=/etc/sysconfig/network-scripts/ifcfg-$cf
check=`ifconfig |grep "\<$ip\>"`

if [ ! -f /etc/sysconfig/network-scripts/ifcfg-"$cf" ]; then

if [ -z "$check" ]; then

cat >> $path << _eof_
DEVICE=$cf
BOOTPROTO=static
BROADCAST=192.168.0.255
HWADDR=00:0C:29:9D:65:6F
IPADDR=$ip
NETMASK=255.255.255.0
NETWORK=192.168.0.0
ONBOOT=yes
_eof_

echo -e "######## Added the IP aliases ##############"
ifup $cf
else
echo -e "The Ip address already exist"
fi
else
echo -e "The ip aliases $cf exist"
fi


--

No comments:

Other Articles

Enter your email address: