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# $Id: ifconfig.sh,v 1.59 2010/06/11 23:46:49 tbox Exp $ 19 20# 21# Set up interface aliases for bind9 system tests. 22# 23# IPv4: 10.53.0.{1..7} RFC 1918 24# IPv6: fd92:7065:b8e:ffff::{1..7} ULA 25# 26 27config_guess="" 28for f in ./config.guess ../../../config.guess 29do 30 if test -f $f 31 then 32 config_guess=$f 33 fi 34done 35 36if test "X$config_guess" = "X" 37then 38 cat <<EOF >&2 39$0: must be run from the top level source directory or the 40bin/tests/system directory 41EOF 42 exit 1 43fi 44 45# If running on hp-ux, don't even try to run config.guess. 46# It will try to create a temporary file in the current directory, 47# which fails when running as root with the current directory 48# on a NFS mounted disk. 49 50case `uname -a` in 51 *HP-UX*) sys=hpux ;; 52 *) sys=`sh $config_guess` ;; 53esac 54 55case "$2" in 56[0-9]|[1-9][0-9]|[1-9][0-9][0-9]) base=$2;; 57*) base="" 58esac 59 60case "$3" in 61[0-9]|[1-9][0-9]|[1-9][0-9][0-9]) base6=$2;; 62*) base6="" 63esac 64 65case "$1" in 66 67 start|up) 68 for ns in 1 2 3 4 5 6 7 69 do 70 if test -n "$base" 71 then 72 int=`expr $ns + $base - 1` 73 else 74 int=$ns 75 fi 76 if test -n "$base6" 77 then 78 int6=`expr $ns + $base6 - 1` 79 else 80 int6=$ns 81 fi 82 case "$sys" in 83 *-pc-solaris2.5.1) 84 ifconfig lo0:$int 10.53.0.$ns netmask 0xffffffff up 85 ;; 86 *-sun-solaris2.[6-7]) 87 ifconfig lo0:$int 10.53.0.$ns netmask 0xffffffff up 88 ;; 89 *-*-solaris2.[8-9]|*-*-solaris2.1[0-9]) 90 /sbin/ifconfig lo0:$int plumb 91 /sbin/ifconfig lo0:$int 10.53.0.$ns up 92 if test -n "$int6" 93 then 94 /sbin/ifconfig lo0:$int6 inet6 plumb 95 /sbin/ifconfig lo0:$int6 \ 96 inet6 fd92:7065:b8e:ffff::$ns up 97 fi 98 ;; 99 *-*-linux*) 100 ifconfig lo:$int 10.53.0.$ns up netmask 255.255.255.0 101 ifconfig lo inet6 add fd92:7065:b8e:ffff::$ns/64 102 ;; 103 *-unknown-freebsd*) 104 ifconfig lo0 10.53.0.$ns alias netmask 0xffffffff 105 ifconfig lo0 inet6 fd92:7065:b8e:ffff::$ns alias 106 ;; 107 *-unknown-netbsd*) 108 ifconfig lo0 10.53.0.$ns alias netmask 255.255.255.0 109 ifconfig lo0 inet6 fd92:7065:b8e:ffff::$ns alias 110 ;; 111 *-unknown-openbsd*) 112 ifconfig lo0 10.53.0.$ns alias netmask 255.255.255.0 113 ifconfig lo0 inet6 fd92:7065:b8e:ffff::$ns alias 114 ;; 115 *-*-bsdi[3-5].*) 116 ifconfig lo0 add 10.53.0.$ns netmask 255.255.255.0 117 ;; 118 *-dec-osf[4-5].*) 119 ifconfig lo0 alias 10.53.0.$ns 120 ;; 121 *-sgi-irix6.*) 122 ifconfig lo0 alias 10.53.0.$ns 123 ;; 124 *-*-sysv5uw7*|*-*-sysv*UnixWare*|*-*-sysv*OpenUNIX*) 125 ifconfig lo0 10.53.0.$ns alias netmask 0xffffffff 126 ;; 127 *-ibm-aix4.*|*-ibm-aix5.*) 128 ifconfig lo0 alias 10.53.0.$ns 129 ifconfig lo0 inet6 alias -dad fd92:7065:b8e:ffff::$ns/64 130 ;; 131 hpux) 132 ifconfig lo0:$int 10.53.0.$ns netmask 255.255.255.0 up 133 ifconfig lo0:$int inet6 fd92:7065:b8e:ffff::$ns up 134 ;; 135 *-sco3.2v*) 136 ifconfig lo0 alias 10.53.0.$ns 137 ;; 138 *-darwin*) 139 ifconfig lo0 alias 10.53.0.$ns 140 ifconfig lo0 inet6 fd92:7065:b8e:ffff::$ns alias 141 ;; 142 *) 143 echo "Don't know how to set up interface. Giving up." 144 exit 1 145 esac 146 done 147 ;; 148 149 stop|down) 150 for ns in 7 6 5 4 3 2 1 151 do 152 if test -n "$base" 153 then 154 int=`expr $ns + $base - 1` 155 else 156 int=$ns 157 fi 158 case "$sys" in 159 *-pc-solaris2.5.1) 160 ifconfig lo0:$int 0.0.0.0 down 161 ;; 162 *-sun-solaris2.[6-7]) 163 ifconfig lo0:$int 10.53.0.$ns down 164 ;; 165 *-*-solaris2.[8-9]|*-*-solaris2.1[0-9]) 166 ifconfig lo0:$int 10.53.0.$ns down 167 ifconfig lo0:$int 10.53.0.$ns unplumb 168 if test -n "$int6" 169 then 170 ifconfig lo0:$int6 inet6 down 171 ifconfig lo0:$int6 inet6 unplumb 172 fi 173 ;; 174 *-*-linux*) 175 ifconfig lo:$int 10.53.0.$ns down 176 ifconfig lo inet6 del fd92:7065:b8e:ffff::$ns/64 177 ;; 178 *-unknown-freebsd*) 179 ifconfig lo0 10.53.0.$ns delete 180 ifconfig lo0 inet6 fd92:7065:b8e:ffff::$ns delete 181 ;; 182 *-unknown-netbsd*) 183 ifconfig lo0 10.53.0.$ns delete 184 ifconfig lo0 inet6 fd92:7065:b8e:ffff::$ns delete 185 ;; 186 *-unknown-openbsd*) 187 ifconfig lo0 10.53.0.$ns delete 188 ifconfig lo0 inet6 fd92:7065:b8e:ffff::$ns delete 189 ;; 190 *-*-bsdi[3-5].*) 191 ifconfig lo0 remove 10.53.0.$ns 192 ;; 193 *-dec-osf[4-5].*) 194 ifconfig lo0 -alias 10.53.0.$ns 195 ;; 196 *-sgi-irix6.*) 197 ifconfig lo0 -alias 10.53.0.$ns 198 ;; 199 *-*-sysv5uw7*|*-*-sysv*UnixWare*|*-*-sysv*OpenUNIX*) 200 ifconfig lo0 -alias 10.53.0.$ns 201 ;; 202 *-ibm-aix4.*|*-ibm-aix5.*) 203 ifconfig lo0 delete 10.53.0.$ns 204 ifconfig lo0 delete inet6 fd92:7065:b8e:ffff::$ns/64 205 ;; 206 hpux) 207 ifconfig lo0:$int 0.0.0.0 208 ifconfig lo0:$int inet6 :: 209 ;; 210 *-sco3.2v*) 211 ifconfig lo0 -alias 10.53.0.$ns 212 ;; 213 *darwin*) 214 ifconfig lo0 -alias 10.53.0.$ns 215 ifconfig lo0 inet6 fd92:7065:b8e:ffff::$ns delete 216 ;; 217 *) 218 echo "Don't know how to destroy interface. Giving up." 219 exit 1 220 esac 221 done 222 223 ;; 224 225 *) 226 echo "Usage: $0 { up | down } [base]" 227 exit 1 228esac 229