*BSD News Article 44772


Return to BSD News archive

Xref: sserve comp.infosystems.www.servers.unix:866 comp.unix.bsd.freebsd.misc:1575
Path: sserve!newshost.anu.edu.au!harbinger.cc.monash.edu.au!news.uwa.edu.au!DIALix!haywire.DIALix.COM!not-for-mail
From: peter@haywire.DIALix.COM (Peter Wemm)
Newsgroups: comp.infosystems.www.servers.unix,comp.unix.bsd.freebsd.misc
Subject: Re: FreeBSD Web servers (was Re: NT server vs workstation for WWW server)
Date: 1 Jun 1995 15:13:19 +0800
Organization: DIALix Services, Perth, Australia.
Lines: 44
Sender: peter@haywire.DIALix.COM
Message-ID: <3qjpaf$25d$1@haywire.DIALix.COM>
References: <3p8afo$sb8@nntp.interaccess.com> <3pebt2$4g0@clarknet.clark.net> <3pmrs4$g5t@gate.sinica.edu.tw> <3q265j$j77@ibridge.iohk.com> <3q2esm$ko7@gate.sinica.edu.tw>
NNTP-Posting-Host: haywire.dialix.com
NNTP-Posting-User: peter

taob@gate.sinica.edu.tw (Brian Tao) writes:

>In article <3q265j$j77@ibridge.iohk.com>, David Wu <dyw@igate.iohk.com> wrote:
>>
>>i would like to run multiple IP addresses on a single web server on 
>>BSDI.   if this can be done on FreeBSD it is probably possible to do the 
>>same on BSDI, but i don't know how.   can you elaborate?

>    Yes, it works on both FreeBSD and BSD/OS (and probably NetBSD
>too).  Just use ifconfig's "alias" option to add as many IP's as you
>need to your network interface.  Under FreeBSD, you also need to add a
>loopback route to each one ("route add <alias> localhost") so the
>machine can talk to itself at one of the aliases.  The Apache server's
>VirtualHost directive works beautifully with this setup.

Actually, the route to localhost isn't needed anymore on FreeBSD..
When you add an alias to an ethernet address on a network your main
address is on, you use a different netmask.  That stops the "ioctl
(SIOCAIFADDR): file exists" error.  The message was actually correct -
without the host netmask, you were effectively causing a network route
to be set to the interface, and a route to the same network already
existed.  What the 255.255.255.255 netmask does, is add a specific
route to the address, and since the routing system works in the
least-specific to most specific order, the aliases will override the
network route.

eg: For a Web server on a C-class net, you'd do something like this:

ifconfig ed0 inet 192.9.200.1 netmask 255.255.255.0 broadcast 192.9.200.255
ifconfig ed0 inet 192.9.200.2 netmask 255.255.255.255 alias
ifconfig ed0 inet 192.9.200.3 netmask 255.255.255.255 alias
ifconfig ed0 inet 192.9.200.4 netmask 255.255.255.255 alias
ifconfig ed0 inet 192.9.200.5 netmask 255.255.255.255 alias
[....]

I've only tried this on FreeBSD-current.  The older 2.0R ifconfig command
may not accept 255.255.255.255, you mileage may vary.

Cheers,
-Peter

>-- 
>Brian ("Though this be madness, yet there is method in't") Tao
>taob@gate.sinica.edu.tw <-- work ........ play --> taob@io.org