how to attach class C net to an interface?

David Fuchs david at davidfuchs.ca
Thu Jun 3 10:50:33 PDT 2004


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 at davidfuchs.ca)

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


More information about the freebsd-questions mailing list