I have a Debian server with many VLANs. All of that vlan started from 1. I need to read from file all IP, and output all of this in other file. All ok, but i have a problem with increment variable.
if [ -f /root/ip ]; then
for IP_ADD in `grep -v ^# /root/ip`; do
eth=1
eth=`expr $eth + 1`
cat >> "/root/inter" <<END
auto eth0:$eth
iface eth0:$eth inet static
address $IP_ADD
netmask 255.255.255.0
END
done
fi
After run this script, i have in file "inter" output:
auto eth0:2
iface eth0:2 inet static
address 192.168.110.1
netmask 255.255.255.0
auto eth0:2
iface eth0:2 inet static
address 192.168.109.1
netmask 255.255.255.0
auto eth0:2
iface eth0:2 inet static
address 192.168.108.1
netmask 255.255.255.0
auto eth0:2
iface eth0:2 inet static
address 192.168.107.1
netmask 255.255.255.0
My variable eth is incremented, but only one time. Where i have error ? Please help.