Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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 "mysite.dev" 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)
NOTE: I DO NOT WANT NOR NEED ANY OF THIS STUFF TO BE SEEN ON A REMOTE NETWORK. This is PURELY for in-house development.

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

http://mysite.dev

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
add comment

2 Answers

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:

192.168.1.42  mysite.dev www.mysite.dev

Where 192.168.1.42 is the IP of your Ubuntu server. Then when any internal hosts look up mysite.dev, 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 google.com, 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?! 192.168.1.42 *.dev www.*.dev ?? –  DJDarkViper 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: thekelleys.org.uk/dnsmasq/doc.html –  Kyle Smith Jan 30 '12 at 2:29
add comment

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

share|improve this answer
add comment

Your Answer

 
discard

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.