Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #-- 100.100.100.160/29 - Sun 04/22/18 02-38-pm
- #-- -----------------------------------------
- auto eth0:0
- iface eth0:0 inet static
- address 100.100.100.160
- netmask 255.255.255.255
- auto eth0:1
- iface eth0:1 inet static
- address 100.100.100.161
- netmask 255.255.255.255
- auto eth0:2
- iface eth0:2 inet static
- address 100.100.100.162
- netmask 255.255.255.255
- auto eth0:3
- iface eth0:3 inet static
- address 100.100.100.163
- netmask 255.255.255.255
- auto eth0:4
- iface eth0:4 inet static
- address 100.100.100.164
- netmask 255.255.255.255
- auto eth0:5
- iface eth0:5 inet static
- address 100.100.100.165
- netmask 255.255.255.255
- auto eth0:6
- iface eth0:6 inet static
- address 100.100.100.166
- netmask 255.255.255.255
- auto eth0:7
- iface eth0:7 inet static
- address 99.100.100.167
- netmask 255.255.255.255
- #!/bin/bash
- #
- #-- bash add_ips.sh "eth0" "100.100.100.160" "255.255.255.255" "29"
- wDir="/scripts/tools/ips"
- ifaceFile="/etc/network/interfaces"
- ipFile="${wDir}/ipFile.txt"
- nic="${1}"
- address="${2}"
- netmask="${3}"
- block="${4}"
- timeStamp="$(date '+%a %D %I-%M-%P')"
- if [ ! -n "$4" ]; then
- echo 'add_ips.sh nic address mask block ...';
- exit 1;
- fi
- #-- echo the address block on a header line
- {
- echo "";
- echo "#-- IP Block ${address}/${block} - ${timeStamp}";
- echo "#-- ----------------------------------------------";
- } > "$ipFile"
- #-- If a 30/block
- if [[ "$block" == "30" ]]; then
- start="0"
- end="3"
- for ipnum in $(seq "$start" "$end"); do
- {
- echo "auto ${nic}:${ipnum}";
- echo "iface ${nic}:${ipnum} inet static";
- echo -e "t address ${address}";
- echo -e "t netmask ${netmask}";
- echo "";
- } >> "$ipFile"
- done
- #-- 100.100.100.160/29 - Sun 04/22/18 02-38-pm
- #-- -----------------------------------------
- auto eth0:0
- iface eth0:0 inet static
- address 100.100.100.160
- netmask 255.255.255.255
- auto eth0:1
- iface eth0:1 inet static
- address 100.100.100.160
- netmask 255.255.255.255
- auto eth0:2
- iface eth0:2 inet static
- address 100.100.100.160
- netmask 255.255.255.255
- #-- If a 30/block
- if [[ "$block" == "30" ]]; then
- start="0"
- end="3"
- for ipnum in $(seq "$start" "$end"); do
- ipaddress=$(expr "$address" + "$ipnum")
- {
- echo "auto ${nic}:${ipnum}";
- echo "iface ${nic}:${ipnum} inet static";
- echo -e "t address ${ipaddress}";
- echo -e "t netmask ${netmask}";
- echo "";
- } >> "$ipFile"
- done
- fi
Add Comment
Please, Sign In to add comment