Guest User

Untitled

a guest
Apr 22nd, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.46 KB | None | 0 0
  1. #-- 100.100.100.160/29 - Sun 04/22/18 02-38-pm
  2. #-- -----------------------------------------
  3. auto eth0:0
  4. iface eth0:0 inet static
  5. address 100.100.100.160
  6. netmask 255.255.255.255
  7.  
  8. auto eth0:1
  9. iface eth0:1 inet static
  10. address 100.100.100.161
  11. netmask 255.255.255.255
  12.  
  13. auto eth0:2
  14. iface eth0:2 inet static
  15. address 100.100.100.162
  16. netmask 255.255.255.255
  17.  
  18. auto eth0:3
  19. iface eth0:3 inet static
  20. address 100.100.100.163
  21. netmask 255.255.255.255
  22.  
  23. auto eth0:4
  24. iface eth0:4 inet static
  25. address 100.100.100.164
  26. netmask 255.255.255.255
  27.  
  28. auto eth0:5
  29. iface eth0:5 inet static
  30. address 100.100.100.165
  31. netmask 255.255.255.255
  32.  
  33. auto eth0:6
  34. iface eth0:6 inet static
  35. address 100.100.100.166
  36. netmask 255.255.255.255
  37.  
  38. auto eth0:7
  39. iface eth0:7 inet static
  40. address 99.100.100.167
  41. netmask 255.255.255.255
  42.  
  43. #!/bin/bash
  44. #
  45. #-- bash add_ips.sh "eth0" "100.100.100.160" "255.255.255.255" "29"
  46.  
  47. wDir="/scripts/tools/ips"
  48. ifaceFile="/etc/network/interfaces"
  49. ipFile="${wDir}/ipFile.txt"
  50. nic="${1}"
  51. address="${2}"
  52. netmask="${3}"
  53. block="${4}"
  54. timeStamp="$(date '+%a %D %I-%M-%P')"
  55.  
  56. if [ ! -n "$4" ]; then
  57. echo 'add_ips.sh nic address mask block ...';
  58. exit 1;
  59. fi
  60.  
  61. #-- echo the address block on a header line
  62. {
  63. echo "";
  64. echo "#-- IP Block ${address}/${block} - ${timeStamp}";
  65. echo "#-- ----------------------------------------------";
  66. } > "$ipFile"
  67.  
  68. #-- If a 30/block
  69. if [[ "$block" == "30" ]]; then
  70. start="0"
  71. end="3"
  72. for ipnum in $(seq "$start" "$end"); do
  73. {
  74. echo "auto ${nic}:${ipnum}";
  75. echo "iface ${nic}:${ipnum} inet static";
  76. echo -e "t address ${address}";
  77. echo -e "t netmask ${netmask}";
  78. echo "";
  79. } >> "$ipFile"
  80. done
  81.  
  82. #-- 100.100.100.160/29 - Sun 04/22/18 02-38-pm
  83. #-- -----------------------------------------
  84. auto eth0:0
  85. iface eth0:0 inet static
  86. address 100.100.100.160
  87. netmask 255.255.255.255
  88.  
  89. auto eth0:1
  90. iface eth0:1 inet static
  91. address 100.100.100.160
  92. netmask 255.255.255.255
  93.  
  94. auto eth0:2
  95. iface eth0:2 inet static
  96. address 100.100.100.160
  97. netmask 255.255.255.255
  98.  
  99. #-- If a 30/block
  100. if [[ "$block" == "30" ]]; then
  101. start="0"
  102. end="3"
  103. for ipnum in $(seq "$start" "$end"); do
  104. ipaddress=$(expr "$address" + "$ipnum")
  105. {
  106. echo "auto ${nic}:${ipnum}";
  107. echo "iface ${nic}:${ipnum} inet static";
  108. echo -e "t address ${ipaddress}";
  109. echo -e "t netmask ${netmask}";
  110. echo "";
  111. } >> "$ipFile"
  112. done
  113. fi
Add Comment
Please, Sign In to add comment