1#!/bin/sh 2# 3# Copyright (C) 2004, 2007-2010, 2012, 2013 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..8} RFC 1918 24# IPv6: fd92:7065:b8e:ffff::{1..8} 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 [1-9]|[1-9][0-9]|[1-9][0-9][0-9]) base=$2;; 57 *) base="1" 58esac 59 60case "$3" in 61 [1-9]|[1-9][0-9]|[1-9][0-9][0-9]) base6=$3;; 62 *) base6=$base 63esac 64 65case "$1" in 66 67 start|up) 68 for ns in 1 2 3 4 5 6 7 8 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 8 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 if test -n "$base6" 159 then 160 int6=`expr $ns + $base6 - 1` 161 else 162 int6=$ns 163 fi 164 case "$sys" in 165 *-pc-solaris2.5.1) 166 ifconfig lo0:$int 0.0.0.0 down 167 ;; 168 *-sun-solaris2.[6-7]) 169 ifconfig lo0:$int 10.53.0.$ns down 170 ;; 171 *-*-solaris2.[8-9]|*-*-solaris2.1[0-9]) 172 ifconfig lo0:$int 10.53.0.$ns down 173 ifconfig lo0:$int 10.53.0.$ns unplumb 174 if test -n "$int6" 175 then 176 ifconfig lo0:$int6 inet6 down 177 ifconfig lo0:$int6 inet6 unplumb 178 fi 179 ;; 180 *-*-linux*) 181 ifconfig lo:$int 10.53.0.$ns down 182 ifconfig lo inet6 del fd92:7065:b8e:ffff::$ns/64 183 ;; 184 *-unknown-freebsd*) 185 ifconfig lo0 10.53.0.$ns delete 186 ifconfig lo0 inet6 fd92:7065:b8e:ffff::$ns delete 187 ;; 188 *-unknown-netbsd*) 189 ifconfig lo0 10.53.0.$ns delete 190 ifconfig lo0 inet6 fd92:7065:b8e:ffff::$ns delete 191 ;; 192 *-unknown-openbsd*) 193 ifconfig lo0 10.53.0.$ns delete 194 ifconfig lo0 inet6 fd92:7065:b8e:ffff::$ns delete 195 ;; 196 *-*-bsdi[3-5].*) 197 ifconfig lo0 remove 10.53.0.$ns 198 ;; 199 *-dec-osf[4-5].*) 200 ifconfig lo0 -alias 10.53.0.$ns 201 ;; 202 *-sgi-irix6.*) 203 ifconfig lo0 -alias 10.53.0.$ns 204 ;; 205 *-*-sysv5uw7*|*-*-sysv*UnixWare*|*-*-sysv*OpenUNIX*) 206 ifconfig lo0 -alias 10.53.0.$ns 207 ;; 208 *-ibm-aix4.*|*-ibm-aix5.*) 209 ifconfig lo0 delete 10.53.0.$ns 210 ifconfig lo0 delete inet6 fd92:7065:b8e:ffff::$ns/64 211 ;; 212 hpux) 213 ifconfig lo0:$int 0.0.0.0 214 ifconfig lo0:$int inet6 :: 215 ;; 216 *-sco3.2v*) 217 ifconfig lo0 -alias 10.53.0.$ns 218 ;; 219 *darwin*) 220 ifconfig lo0 -alias 10.53.0.$ns 221 ifconfig lo0 inet6 fd92:7065:b8e:ffff::$ns delete 222 ;; 223 *) 224 echo "Don't know how to destroy interface. Giving up." 225 exit 1 226 esac 227 done 228 229 ;; 230 231 *) 232 echo "Usage: $0 { up | down } [base]" 233 exit 1 234esac 235