Am Donnerstag, 7. März 2002 16:23 schrieb Simon Oliver:
i realise this is a bit OT but I know there are network guys on this list
and I'm hoping for a quick solution. I need to temporarily host another
web site on my server. I don't want to chage any DNS registrations as it's
only for one day.
How do I bind/associate more than one ip address with my NIC.
I tried `ipconfig add xxx.xxx.xxx.xxx` and it seemed to work but it only
works for local subnet conmnections. What am I missing?
While Oliviers solution works for you, and which I used for 2 years, I had
some errors due the error-prone increasing of 2 values (Alias and IP) I use
nowadays this :
--------------------------
#! /bin/sh
#
# Author: Peter Wiersig
#
# init.d/local.virtualips
#
# and symbolic its link
#
# /sbin/rclocal.virtualips
#
# System startup script for VirtualHosts
#
### BEGIN INIT INFO
# Provides: local.virtualips
# Required-Start: $network
# Required-Stop: $apache $httpd
# Default-Start: 3 5
# Default-Stop: 0 1 2 6
# Description: Manages IP addresses on eth0 for VirtualHosts.
### END INIT INFO
# Source SuSE config
. /etc/rc.config
# Determine the base and follow a runlevel link name.
base=${0##*/}
link=${base#*[SK][0-9][0-9]}
# Force execution if not called by a runlevel directory.
#test $link = $base && START_local.virtualips=yes
#test "$START_local.virtualips" = yes || exit 0
#better enable the previous 2 lines and modify /etc/rc.config(.local?)
IPs="192.168.0.165 192.168.0.166 192.168.0.201 192.168.0.202
192.168.0.203 192.168.0.204 192.168.0.205 192.168.0.206 192.168.0.207
192.168.0.208 192.168.0.209 192.168.0.210 192.168.0.211 192.168.0.212
192.168.0.213 192.168.0.214 192.168.0.215 192.168.0.216 192.168.0.217
192.168.0.218 192.168.0.219 192.168.0.220 192.168.0.221 192.168.0.222
192.168.0.223 192.168.0.224 192.168.0.225 192.168.0.226 192.168.0.227
192.168.0.228 192.168.0.229 192.168.0.230 192.168.0.231 192.168.0.232
192.168.0.233 192.168.0.234 192.168.0.235 192.168.0.236 192.168.0.237
192.168.0.238 192.168.0.239 192.168.0.240 192.168.0.241 192.168.0.242
192.168.0.243 192.168.0.244 192.168.0.245 192.168.0.248 192.168.0.249
192.168.0.250 192.168.0.251 192.168.0.252 192.168.0.253 192.168.0.254"
# Shell functions sourced from /etc/rc.status:
# rc_check check and set local and overall rc status
# rc_status check and set local and overall rc status
# rc_status -v ditto but be verbose in local rc status
# rc_status -v -r ditto and clear the local rc status
# rc_failed set local and overall rc status to failed
# rc_failed <num> set local and overall rc status to <num><num>
# rc_reset clear local rc status (overall remains)
# rc_exit exit appropriate to overall rc status
. /etc/rc.status
# First reset status of this service
rc_reset
# Return values acc. to LSB for all commands but status:
# 0 - success
# 1 - generic or unspecified error
# 2 - invalid or excess argument(s)
# 3 - unimplemented feature (e.g. "reload")
# 4 - insufficient privilege
# 5 - program is not installed
# 6 - program is not configured
# 7 - program is not running
#
# Note that starting an already running service, stopping
# or restarting a not-running service as well as the restart
# with force-reload (in case signalling is not supported) are
# considered a success.
case "$1" in
start)
echo -n "Starting local.virtualips"
## Start daemon with startproc(8). If this fails
## the echo return value is set appropriate.
# NOTE: startproc return 0, even if service is
# already running to match LSB spec.
for IP in $IPs
do
ip addr add $IP dev eth0
done
# Remember status and be verbose
rc_status -v
;;
stop)
echo -n "Shutting down FOO"
## Stop daemon with killproc(8) and if this fails
## set echo the echo return value.
for IP in $IPs
do
ip addr del $IP dev eth0
done
# Remember status and be verbose
rc_status -v
;;
( Rest of /etc/init.d/skel )