Mailinglist Archive: opensuse-security (192 mails)

< Previous Next >
Re: [suse-security] multiple ip adresses per network adapter?
  • From: Fred Mobach <fred@xxxxxxxxx>
  • Date: Mon, 08 May 2000 15:25:14 +0200
  • Message-id: <3916C03A.E3D7874C@xxxxxxxxx>
Heiko Nardmann wrote:

> 1) Is it possible to assign multiple ip adresses to a single
> network adapter?

Look at :

#!/bin/bash
#
# procedure : virtual-host-config for offerans.foo.org
# target : virual hosting start /stop
# arguments : start / stop / restart
# author : Fred Mobach
# date : 13-09-1999
#

. /etc/rc.config

base=${0##*/}
link=${base#*[SK][0-9][0-9]}

return=$rc_done
case "$1" in
start)
echo -n "Starting virtual hosting."
/sbin/ifconfig eth0:0 241.242.243.197
/sbin/ifconfig eth0:1 241.242.243.198
/sbin/ifconfig eth0:2 241.242.243.199
/sbin/ifconfig eth0:3 241.242.243.200
/sbin/ifconfig eth0:4 241.242.243.201
/sbin/ifconfig eth0:5 241.242.243.202
/sbin/ifconfig eth0:6 241.242.243.213
/sbin/ifconfig eth0:7 241.242.243.214
/sbin/route add -host 241.242.243.197 dev eth0:0
/sbin/route add -host 241.242.243.198 dev eth0:1
/sbin/route add -host 241.242.243.199 dev eth0:2
/sbin/route add -host 241.242.243.200 dev eth0:3
/sbin/route add -host 241.242.243.201 dev eth0:4
/sbin/route add -host 241.242.243.202 dev eth0:5
/sbin/route add -host 241.242.243.213 dev eth0:6
/sbin/route add -host 241.242.243.214 dev eth0:7
echo -e "$return"
;;
stop)
echo -n "Shutting down virtual hosting:"
/sbin/route del -host 241.242.243.197 dev eth0:0
/sbin/route del -host 241.242.243.198 dev eth0:1
/sbin/route del -host 241.242.243.199 dev eth0:2
/sbin/route del -host 241.242.243.200 dev eth0:3
/sbin/route del -host 241.242.243.201 dev eth0:4
/sbin/route del -host 241.242.243.202 dev eth0:5
/sbin/route del -host 241.242.243.213 dev eth0:6
/sbin/route del -host 241.242.243.214 dev eth0:7
/sbin/ifconfig eth0:0 down
/sbin/ifconfig eth0:1 down
/sbin/ifconfig eth0:2 down
/sbin/ifconfig eth0:3 down
/sbin/ifconfig eth0:4 down
/sbin/ifconfig eth0:5 down
/sbin/ifconfig eth0:6 down
/sbin/ifconfig eth0:7 down
echo -e "$return"
echo
;;
restart|reload)
$0 stop && $0 start || return=$rc_failed
;;
*)
echo "Usage: $0 {start|stop|restart|reload|status}"
exit 1
esac

test "$return" = "$rc_done" || exit 1
exit 0

Make some additional links to this file in /sbin/init.d/rc[2-3].d/ and it
will start and stop like other network services.

Will this do ?


> 2) If 1 is possible, then my next question is:
> is it possible to direct the requests to different processes
> listening to the same port?
> Maybe I should ask if it is possible to have different (ip-based)
> "port spaces" where different processes listen to the same port
> but for a different ip address?

Yes, that can be done. I've managed this with Apache with the Listen and
VirtualHost commands. It works also very well with rinetd (see freshmeat).

Regards,

Fred Mobach



< Previous Next >
References