Script to generate /etc/network/interfaces file on Ubuntu/Debian

echo -n “Insert IPstart:”
read ipstart
echo -n “Insert IPend:”
read ipend
echo -n “Insert Gateway:”
read gw
#echo -n “Insert Subnet: ”
#read subnet
echo -n “Insert Netmask: ”
read net
echo -n “Insert aliast to start: ”
read ali

firstIp=echo "${ipstart%.*}"
lastIpStart=echo "${ipstart##*.}"
lastIpEnd=echo "${ipend##*.}"
dif=echo $(($lastIpEnd-$lastIpStart))

for ((i=$ali;i<=$ali+$dif;i++)){ echo "auto eth0:$i" >>$ifile
echo “iface eth0:$i inet static” >>$ifile
echo “address $firstIp.$ip” >>$ifile
echo “network $subnet” >>$ifile
echo “netmask $net” >>$ifile
echo “gateway $gw” >> $ifile
echo ” ” >> $ifile
let ip++

Leave a Reply

Your email address will not be published. Required fields are marked *