• No related posts.

      • No related posts.

        • No related posts.

          • No related posts.

              No related posts.

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

            #!/bin/bash
            ifile=/etc/network/interfaces
            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))`

            ip=$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++
            }

            Related posts:

            1. Script to generate interface configs on Linux
            2. Xen howto create domU on Debian
            3. FreeBSD: GRE Tunnels
            4. Why would you disable ‘ip routing’ on a router?
            5. NetBSD Qemu
            This entry was posted in Debian, Linux, Ubuntu and tagged , , , , , .

            Leave a Reply