Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 03 Jun 2004 10:53:26 -0700
From:      David Fuchs <david@davidfuchs.ca>
To:        Artem Koutchine <matrix@itlegion.ru>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: how to attach class C net to an interface?
Message-ID:  <40BF6596.8090705@davidfuchs.ca>
In-Reply-To: <01fa01c44973$efe697f0$0c00a8c0@artem>
References:  <004401c4496f$08f83be0$7a01a8c0@nobodyfuckhead> <01fa01c44973$efe697f0$0c00a8c0@artem>

next in thread | previous in thread | raw e-mail | index | archive | help
Artem Koutchine wrote:
> Hi!
> 
> I have a server with one interface and many virtual web hosts.
> I have been given class C network to use for the virtual
> web hosts and jails on the server. How to i tell the interface
> that all addresses of some A1.A2.A3.A4  0xFFFFFF00 
> network belong to the interface. Do i specify 250-some aliases?
> Or there is a better way?
> 

Hi Artem!

Unfortunately, there is no built-in solution I know of to add aliases in 
bulk - you need to issue individual ifconfig commands.  As such, you can 
do it on the command-line using a loop such as this:

for (( foo = 1; foo < 255; foo++ )); \
do ifconfig fxp1 alias 172.16.100.$foo netmask 0xffffffff; \
done

This will add the aliases 172.16.100.1 through 172.16.100.254 to the 
fxp1 interface.  All you need to do is change the command to reflect 
your requirements for the network number and interface name, and you 
should be good to go.  You can add this command into /etc/rc.local to 
have it run at startup.

-- 
Thanks,
-David Fuchs BCIS (david@davidfuchs.ca)

WWW:    http://www.davidfuchs.ca/
MSN:    david@davidfuchs.ca
PGP:    http://www.davidfuchs.ca/aboutme/433EEC91.pgp



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?40BF6596.8090705>