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 not a complete newbie to networking but at the same time I've never attempted to do what I'm trying to do here.

I have Ubuntu Server (almost fresh install) box connected to a Linksys E3000 router, in my house is 3 Win7 powered machines, 2 OSX computers, 2 Android smartphone devices, and a PS3, 360, etc. Needless to say, I have a LOT of diverse devices in my house that use the internet regularly, so I need to tread carefully here.

This Ubuntu server acts as a local web server with a LAMP stack (works) and a fileserver as well with Samba. This also had BIND9 going for a bit but I NEVER got it working correctly. Heres the scenario im trying to get to here:

On ANY of my devices at ANY time (anything with a web browser in it anyways) I want to be able to visit "" and this url will resolve to a vhost in my apache configuration on my ubuntu server, if the url cannot be resolved, it defaults back to normal internet gateway to try and deliver a page from the internet. To set up a new development site (.dev) I only ever want to have to modify the apache vhost and create my appropriate folders on the system (i would even settle for having to restart my apache each time, i'd be cool with that)

I am to understand that to do this, I need to configure my router to throw all connections through to my Ubuntu box via an IP, this is where I already become stumped, because I'm not exactly sure which settings im supposed to find and modify.
NOTE: I HATE BIND9. I will use it if i absolutely MUST, but i have a pretty pricey linksys router, it should be able to do whats needed here.
At work just the other day this was accomplished, we avoided using BIND9 entirely and just used the router with a special configuration to resolve urls first to our apache and then to the internet, exactly what I'm trying to do here.

This is all to setup so i dont need to do

//UbuntuMan/mysite (which i have right now)

id rather do

and I will SPLIT THE SEAS in order to accomplish this. All my computers I use to develop websites with at all given points of the day and I have an extremely large set of orders coming in, and I switch computers regularly, so its important that I'm able to work on a server directory and have the pages delivered this way (which is why Samba is on there).

OPTIONAL QUESTION: If this does get setup, how easy would it be to setup where if the Ubuntu server is NOT present (ie: turned off) then it will default to just going to the internet normally?

share|improve this question

Hopefully your Linksys router will allow you to override default DNS Primary/Secondary servers that it hands out via DHCP. If so, set the primary to your Ubuntu server, and the secondary to the Linksys device itself (assuming it offers DNS services already, most do).

Once that is done the pain of BIND 9 (It's not that bad really!) can be avoided by installing yourself dnsmasq. I'm fairly sure it's available in the Ubuntu repositories. Out of the box it will:

  • Forward incoming DNS requests to the DNS servers listed in /etc/resolv.conf (set these to your router, or the DNS servers provided by your ISP.
  • "Shadow" results listed in /etc/hosts.

To that second point, add an entry in /etc/hosts like:

Where is the IP of your Ubuntu server. Then when any internal hosts look up, they will forward the request to their primary DNS server (the Ubuntu system) and it will return it's local record. If they send requests for, they will be forwarded upstream.

Now that being said, you can turn this Ubuntu server off and the DNS clients will fall to using the Secondary DNS server (your router, ISP, whatever you configured in the DHCP options on the Linksys). This isn't ideal as different DNS client implementations can be very slow when failing back to secondary DNS. Most desktop OSes will failover nicely and not re-attempt to connect to the primary for 5 minutes, but I've seen less good implementations that try the primary server on every request with a nasty 5 second timeout.

Hope this helps!

share|improve this answer
Dude awesome :D I just managed to get ahold of the server guy and i got a one word response "dnsmasq", since then I havent been able to check anything out lol. OUT OF CURIOSITY, so i dont have to modify hosts EVERYTIME, can i use wildcards?! *.dev www.*.dev ?? – RedactedProfile Jan 30 '12 at 1:25
I'm about 99% sure that wildcards are not allowed in /etc/hosts. DNSMasq has more advanced startup options that can used to respond to certain zones, etc. Check out: – Kyle Smith Jan 30 '12 at 2:29

Sounds like you need to create an A record for either on your router or DNS server so internal machines will get the ip of your local server.

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.