[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: RFC: new network config (was: Re: network configuration)



On Sat, Feb 06, 1999 at 02:19:33PM +1000, Anthony Towns wrote:
> On Sat, Feb 06, 1999 at 08:06:22AM +1100, Craig Sanders wrote:
> > however, the config file used to do all the ifconfigs should
> > have extra information for other virtual-host services like http and
> > ftp.
> 
> I dunno. I think an entirely different conffile would be more suitable
> here.
> 
> In particular, /etc/interfaces needs to specify an address, and an
> interface. It might make use of other things too, but they're not
> *desperately* necessary.
> 
> For virtual hosts, the interface isn't at all important, and the hostname
> is really more relevant than the IP address (in particular for virtual
> web hosting).

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.)


one thing that just now occurs to me is that for machines with multiple
NICs, i will need to either include an interface=eth0 field, or somehow
extract it from netbase's config file(s). an alias address should go on
the most appropriate eth* interface.

e.g. a machine with two NICs, eth0=192.168.1.1 and eth1=192.168.2.1.
aliases in the 192.168.1/24 network should go on eth0:n, while aliases
in 192.168.2/24 should go on eth1:n. this will complicate the counting
for 'n' a little but it shouldn't be terribly difficult to do.

i've currently got this simple shell script for configuring alias interfaces:

    #! /bin/sh

    ALIASES=$(cat /etc/virtuals/virtual-hosts.conf | 
              grep -v "#\|^[[:space:]]*$" | 
              awk '{ print $1 }')
    i=0
    for j in $ALIASES ; do
      echo ifconfig eth0:$i $j up
      i=$(( $i + 1))
    done

it should be something like this:

(i'll take advantage of the fact that it's not likely to ever be part of
netbase now so i'll write it in perl :-)

    #! /usr/bin/perl

    $confdir='/etc/virtuals' ;
    $virtuals="$confdir/virtual-hosts.conf" ;

    open(VIRT,"<$virtuals") || die "couldn't open $virtuals:$!\n" ;
    while(<VIRT>) {
        next if (/^\s*(#|$)/) ;
        push @aliases, (split /:/,$_,1) ;
    } ;
    close(VIRT);

    $interfaces='/etc/interfaces' ;

    open(INT,"<$interfaces") || die "couldn't open $interfaces:$!\n" ;
    while(<INT>) {
        next if (/^\s*(#|$)/) ;
        # the next 2 lines probably aren't good enough. example
        # only...assume it works by magic for now :-)
		($key,$val) = split /:/ ;
        $interfaces{$key} = $val ;
    } ;
    close(INT);
    
    foreach (@aliases) {
        $interface = &figure_out_interface($_) ;
        # the following looks good and may even work :-)
        system("/sbin/ifconfig $interface:$icount{$interface}++ $_ up") ;
    }

    sub figure_out_interface {
        # do some magic
		return $interface_name ;
    }


as you can probably tell from the comments, the above is entirely
untested. i wrote it off the top of my head.  it's included here for
example/conceptual purposes only.

i could probably do it in sh, but it would be much longer and much
uglier to read (and much slower, too...although speed isn't a huge issue
for something like this)

as ever, comments are welcome. (i wouldn't be posting it publicly if i
didn't want comments)


> So an /etc/virtualhosts or something file could include such things as
> preferred port number, canonical name (if the web browser doesn't support
> http/1.1, eg), hostname/ip address (ip address for ftp and mail servers
> and kin), and a list of capabilities and options of some sort.

yep.

> I'm not completely against having this stuff in /etc/interfaces (or a
> different filename), but I have a feeling that splitting them would be
> 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.

> > ensuring that auto-configurator tools work WITHOUT sacrificing a system
> > admin's flexibility is one of my bugbears.  I refuse to use junk which
> > does that kind of thing, and i'd be ashamed to write anything that
> > committed the same crime myself.
> 
> _Great_. :)
> 
> I'm not really sure why I had any fears that it might be otherwise around
> here, actually. Sorry for the imputation.

because nearly everyone who does an auto-config tool does it the easy way
aka the broken way. :-(

no offence taken.

craig

--
craig sanders


Reply to: