Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using a Mac OS X, and I'm trying to begin using VirtualHost functionality with Apache2. I've created and loaded up a hosts file that looks like this:      localhost    name1    name2

Right now, I can only use because that's my computer's IP on my LAN. How can I make a broad range of IPs all point to my same computer?

(I don't know much, if anything, about LANs. I didn't even set up my LAN, I'm just using my wireless router as one... I haven't done any special networking.)

share|improve this question
Generally having to take an entire class C network to use a certain functionality seems like too much - what's your end goal here? There's probably a better way.. – Brandon May 9 '09 at 17:21
Generally the only reason to use multiple IP-adresses on a web server is if it's suppose to serve multiple HTTPS websites... otherwise just use 'host headers' (that answer +1:ed) – Oskar Duveborn May 9 '09 at 18:45
up vote 14 down vote accepted

You could set your network card to have 253 static IP addresses - but that's really not a good way to do this.

If you just want to host multiple sites on one IP address, use name-based virtual host instead of IP virtual hosts (the apache equivalent of Host Headers in Windows/IIS).

More info...

share|improve this answer
Oh. Well, I feel stupid. Name based is totally the way to go, I just never realized there was such a way! Thank you. – stalepretzel May 9 '09 at 20:44

What you need are virtual NICs. I don't know exactly how to do it in MacOS X, but it seems something like this will do:

ifconfig eth0 alias
ifconfig eth0 alias
ifconfig eth0 alias

etc... or maybe:

ifconfig eth0:1 alias
ifconfig eth0:2 alias

Another options is that if you're running a DNS server, just add CNAMEs (aliases) for your main A record. This is far more convenient and easier, IMHO. Let me know if you need any assistance with this.

share|improve this answer
Correct syntax for linux aliases is: ifconfig eth0:0 netmask ... ifconfig eth9:222 netmask Or, using the newer "ip" mode: ip addr add dev eth0 – LapTop006 May 26 '09 at 10:57

Maybe you are looking at this the wrong way. Setup your apache to use the host names instead of the IPs to distingish which files to serve. Then, you can simply use the name to redirect to your computer, or locally as the following:    localhost    name1    name2
share|improve this answer

I have setup my development machine like this

(hosts file) localhost project1.localhost project2.localhost

And then proceed to use name based virtual host config in the webserver of your choise.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.