ifconfig.sh 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. #!/bin/sh
  2. #
  3. # Copyright (C) 2004, 2007-2010 Internet Systems Consortium, Inc. ("ISC")
  4. # Copyright (C) 2000-2003 Internet Software Consortium.
  5. #
  6. # Permission to use, copy, modify, and/or distribute this software for any
  7. # purpose with or without fee is hereby granted, provided that the above
  8. # copyright notice and this permission notice appear in all copies.
  9. #
  10. # THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
  11. # REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  12. # AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
  13. # INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  14. # LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  15. # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  16. # PERFORMANCE OF THIS SOFTWARE.
  17. #
  18. # Set up interface aliases for bind9 system tests.
  19. #
  20. # IPv4: 10.53.0.{1..7} RFC 1918
  21. # IPv6: fd92:7065:b8e:ffff::{1..7} ULA
  22. #
  23. config_guess=""
  24. for f in ./config.guess ../../config.guess
  25. do
  26. if test -f $f
  27. then
  28. config_guess=$f
  29. fi
  30. done
  31. if test "X$config_guess" = "X"
  32. then
  33. cat <<EOF >&2
  34. $0: must be run from the top level source directory or the
  35. bin/tests/system directory
  36. EOF
  37. exit 1
  38. fi
  39. # If running on hp-ux, don't even try to run config.guess.
  40. # It will try to create a temporary file in the current directory,
  41. # which fails when running as root with the current directory
  42. # on a NFS mounted disk.
  43. case `uname -a` in
  44. *HP-UX*) sys=hpux ;;
  45. *) sys=`sh $config_guess` ;;
  46. esac
  47. case "$2" in
  48. [0-9]|[1-9][0-9]|[1-9][0-9][0-9]) base=$2;;
  49. *) base=""
  50. esac
  51. case "$3" in
  52. [0-9]|[1-9][0-9]|[1-9][0-9][0-9]) base6=$2;;
  53. *) base6=""
  54. esac
  55. case "$1" in
  56. start|up)
  57. for ns in 1 2 3 4 5 6 7 8
  58. do
  59. if test -n "$base"
  60. then
  61. int=`expr $ns + $base - 1`
  62. else
  63. int=$ns
  64. fi
  65. if test -n "$base6"
  66. then
  67. int6=`expr $ns + $base6 - 1`
  68. else
  69. int6=$ns
  70. fi
  71. case "$sys" in
  72. *-pc-solaris2.5.1)
  73. ifconfig lo0:$int 10.53.0.$ns netmask 0xffffffff up
  74. ;;
  75. *-sun-solaris2.[6-7])
  76. ifconfig lo0:$int 10.53.0.$ns netmask 0xffffffff up
  77. ;;
  78. *-*-solaris2.[8-9]|*-*-solaris2.1[0-9])
  79. /sbin/ifconfig lo0:$int plumb
  80. /sbin/ifconfig lo0:$int 10.53.0.$ns up
  81. if test -n "$int6"
  82. then
  83. /sbin/ifconfig lo0:$int6 inet6 plumb
  84. /sbin/ifconfig lo0:$int6 \
  85. inet6 fd92:7065:b8e:ffff::$ns up
  86. fi
  87. ;;
  88. *-*-linux*)
  89. ifconfig lo:$int 10.53.0.$ns up netmask 255.255.255.0
  90. ifconfig lo inet6 add fd92:7065:b8e:ffff::$ns/64
  91. ;;
  92. *-unknown-freebsd*)
  93. ifconfig lo0 10.53.0.$ns alias netmask 0xffffffff
  94. ifconfig lo0 inet6 fd92:7065:b8e:ffff::$ns alias
  95. ;;
  96. *-unknown-netbsd*)
  97. ifconfig lo0 10.53.0.$ns alias netmask 255.255.255.0
  98. ifconfig lo0 inet6 fd92:7065:b8e:ffff::$ns alias
  99. ;;
  100. *-unknown-openbsd*)
  101. ifconfig lo0 10.53.0.$ns alias netmask 255.255.255.0
  102. ifconfig lo0 inet6 fd92:7065:b8e:ffff::$ns alias
  103. ;;
  104. *-*-bsdi[3-5].*)
  105. ifconfig lo0 add 10.53.0.$ns netmask 255.255.255.0
  106. ;;
  107. *-dec-osf[4-5].*)
  108. ifconfig lo0 alias 10.53.0.$ns
  109. ;;
  110. *-sgi-irix6.*)
  111. ifconfig lo0 alias 10.53.0.$ns
  112. ;;
  113. *-*-sysv5uw7*|*-*-sysv*UnixWare*|*-*-sysv*OpenUNIX*)
  114. ifconfig lo0 10.53.0.$ns alias netmask 0xffffffff
  115. ;;
  116. *-ibm-aix4.*|*-ibm-aix5.*)
  117. ifconfig lo0 alias 10.53.0.$ns
  118. ifconfig lo0 inet6 alias -dad fd92:7065:b8e:ffff::$ns/64
  119. ;;
  120. hpux)
  121. ifconfig lo0:$int 10.53.0.$ns netmask 255.255.255.0 up
  122. ifconfig lo0:$int inet6 fd92:7065:b8e:ffff::$ns up
  123. ;;
  124. *-sco3.2v*)
  125. ifconfig lo0 alias 10.53.0.$ns
  126. ;;
  127. *-darwin*)
  128. ifconfig lo0 alias 10.53.0.$ns
  129. ifconfig lo0 inet6 fd92:7065:b8e:ffff::$ns alias
  130. ;;
  131. *)
  132. echo "Don't know how to set up interface. Giving up."
  133. exit 1
  134. esac
  135. done
  136. ;;
  137. stop|down)
  138. for ns in 8 7 6 5 4 3 2 1
  139. do
  140. if test -n "$base"
  141. then
  142. int=`expr $ns + $base - 1`
  143. else
  144. int=$ns
  145. fi
  146. case "$sys" in
  147. *-pc-solaris2.5.1)
  148. ifconfig lo0:$int 0.0.0.0 down
  149. ;;
  150. *-sun-solaris2.[6-7])
  151. ifconfig lo0:$int 10.53.0.$ns down
  152. ;;
  153. *-*-solaris2.[8-9]|*-*-solaris2.1[0-9])
  154. ifconfig lo0:$int 10.53.0.$ns down
  155. ifconfig lo0:$int 10.53.0.$ns unplumb
  156. if test -n "$int6"
  157. then
  158. ifconfig lo0:$int6 inet6 down
  159. ifconfig lo0:$int6 inet6 unplumb
  160. fi
  161. ;;
  162. *-*-linux*)
  163. ifconfig lo:$int 10.53.0.$ns down
  164. ifconfig lo inet6 del fd92:7065:b8e:ffff::$ns/64
  165. ;;
  166. *-unknown-freebsd*)
  167. ifconfig lo0 10.53.0.$ns delete
  168. ifconfig lo0 inet6 fd92:7065:b8e:ffff::$ns delete
  169. ;;
  170. *-unknown-netbsd*)
  171. ifconfig lo0 10.53.0.$ns delete
  172. ifconfig lo0 inet6 fd92:7065:b8e:ffff::$ns delete
  173. ;;
  174. *-unknown-openbsd*)
  175. ifconfig lo0 10.53.0.$ns delete
  176. ifconfig lo0 inet6 fd92:7065:b8e:ffff::$ns delete
  177. ;;
  178. *-*-bsdi[3-5].*)
  179. ifconfig lo0 remove 10.53.0.$ns
  180. ;;
  181. *-dec-osf[4-5].*)
  182. ifconfig lo0 -alias 10.53.0.$ns
  183. ;;
  184. *-sgi-irix6.*)
  185. ifconfig lo0 -alias 10.53.0.$ns
  186. ;;
  187. *-*-sysv5uw7*|*-*-sysv*UnixWare*|*-*-sysv*OpenUNIX*)
  188. ifconfig lo0 -alias 10.53.0.$ns
  189. ;;
  190. *-ibm-aix4.*|*-ibm-aix5.*)
  191. ifconfig lo0 delete 10.53.0.$ns
  192. ifconfig lo0 delete inet6 fd92:7065:b8e:ffff::$ns/64
  193. ;;
  194. hpux)
  195. ifconfig lo0:$int 0.0.0.0
  196. ifconfig lo0:$int inet6 ::
  197. ;;
  198. *-sco3.2v*)
  199. ifconfig lo0 -alias 10.53.0.$ns
  200. ;;
  201. *darwin*)
  202. ifconfig lo0 -alias 10.53.0.$ns
  203. ifconfig lo0 inet6 fd92:7065:b8e:ffff::$ns delete
  204. ;;
  205. *)
  206. echo "Don't know how to destroy interface. Giving up."
  207. exit 1
  208. esac
  209. done
  210. ;;
  211. *)
  212. echo "Usage: $0 { up | down } [base]"
  213. exit 1
  214. esac