On Sat, Feb 06, 1999 at 05:19:25PM +1100, Craig Sanders wrote: > ok, it seems to me that netbase probably doesn't need to configure > IP addresses for virtual hosts. it just needs to configure the main > addresses for each interface card. > > so how about we split it up like this: > > - your netbase does the main interface setup. whatever is need to get > the machine up and running on the net. > > - my virtual-services package does everything else needed for virtual > host service provision, including running ifconfig for ip_alias > addresses. > > (alternatively, if you want to handle ip_alias ifconfig in netbase, > that's fine too. would be nice to have some extra data in your > /etc/interfaces file, though...to avoid duplication of config data.) What I was thinking of was something like: /etc/interfaces eth0 200.200.200.5 # This is my real IP eth1 192.168.200.1 # But I'm also a masq g/w for this network eth0:0 200.200.200.6 # I also run a virtual ftp server on this # address /etc/virtual-services www.freakystuff.com apache,analog ftp.freakystuff.com proftpd /etc/hosts 200.200.200.6 ftp.freakystuff.com 200.200.200.5 www.freakystuff.com But yes, I see what you mean -- the eth0:0 line can be derived (with difficulty) from the fact you're hosting services for ftp.freakystuff, but you don't (yet) have ftp.freakystuff's IP. Making it "eth0:0 ftp.freakystuff.com" *might* be more acceptable but probably not all that much. Something like: /etc/init.d/virtual-services start: for each virtual service { resolve address of virtual-hostname; if ( we don't have an interface bound to that address ) { $added = 0; for each non-alias interface { if ( address & netmask == virtual-address & netmask ) { add an alias for this interface with address v-a $added = 1; last; } } if ( !$added ) die("Eeek, can't guess interface"); } # we're receiving packets for that address now, hopefully. Woo :) } (which isn't all that different from the code you posted) Hmmm. That *might* not be too hard, actually. Except for the "are we already that address" and "for each non-alias interface", maybe. Depending on how you wanted to do this, you could make it somewhat easier by adding to /etc/interfaces yourself (just as you'll be adding to /etc/apache/httpd.conf, and whatever else). That would mean you could just read /etc/interfaces to work out which address you were using, which would be a lot easier than stressing about parsing ifconfig's output. (ie, for each line { next if comment; ($iface, $ip, @rest) = split(/ +/, $line); $hash{$ip} = $iface; } if ( !$hash{$virt-ip} ) { ... } for (keys %hash) ... ) > > better. > i agree. we'll need to co-ordinate a few little things... mostly > to avoid duplication of data - duplication is bad because it's > depressingly easy to change something in one file and forget to make the > corresponding change in another file. > > which is part of the point of this virtual-services package i'm writing > - consolidate all the relevant data into one config file and generate > other config files from that. Exactly. Cheers, aj -- Anthony Towns <aj@humbug.org.au> <http://azure.humbug.org.au/~aj/> I don't speak for anyone save myself. PGP encrypted mail preferred. ``Like the ski resort of girls looking for husbands and husbands looking for girls, the situation is not as symmetrical as it might seem.''
Attachment:
pgpZSw5lPgCi9.pgp
Description: PGP signature